Search in sources :

Example 71 with AsyncMessage

use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.

the class CallAsyncRequestsManager method createEndRecordCall.

public static String createEndRecordCall(StartOrEndCallRecordRequest request, String uniqueId) {
    AsyncMessage message = new AsyncMessage();
    message.setType(ChatMessageType.Constants.END_RECORD_CALL);
    message.setToken(CoreConfig.token);
    message.setSubjectId(request.getCallId());
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setTypeCode(Util.isNullOrEmpty(request.getTypeCode()) ? request.getTypeCode() : CoreConfig.typeCode);
    JsonObject a = (JsonObject) App.getGson().toJsonTree(message);
    return a.toString();
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 72 with AsyncMessage

use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.

the class CallAsyncRequestsManager method createAcceptCallRequest.

public static String createAcceptCallRequest(AcceptCallRequest request, String uniqueId) {
    AsyncMessage message = new AsyncMessage();
    SendClientDTO sendClientDTO = new SendClientDTO();
    sendClientDTO.setVideo(request.isVideoCall());
    sendClientDTO.setMute(request.isMute());
    sendClientDTO.setClientType(ClientType.Constants.ANDROID);
    JsonElement clientDtoObj = App.getGson().toJsonTree(sendClientDTO);
    message.setContent(clientDtoObj.toString());
    message.setType(ChatMessageType.Constants.ACCEPT_CALL);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setSubjectId(request.getCallId());
    message.setUniqueId(uniqueId);
    JsonObject messageObj = (JsonObject) App.getGson().toJsonTree(message);
    return messageObj.toString();
}
Also used : SendClientDTO(com.fanap.podchat.call.model.SendClientDTO) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject)

Example 73 with AsyncMessage

use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.

the class CallAsyncRequestsManager method createTurnOnVideoMessage.

public static String createTurnOnVideoMessage(long callId, String uniqueId) {
    ArrayList<Long> ids = new ArrayList<>();
    ids.add(CoreConfig.userId);
    TurnCallParticipantVideoOffRequest request = new TurnCallParticipantVideoOffRequest.Builder(callId, ids).build();
    AsyncMessage message = new AsyncMessage();
    message.setType(ChatMessageType.Constants.TURN_ON_VIDEO_CALL);
    message.setToken(CoreConfig.token);
    message.setSubjectId(request.getCallId());
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setTypeCode(Util.isNullOrEmpty(request.getTypeCode()) ? request.getTypeCode() : CoreConfig.typeCode);
    JsonObject a = (JsonObject) App.getGson().toJsonTree(message);
    return a.toString();
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) TurnCallParticipantVideoOffRequest(com.fanap.podchat.call.request_model.TurnCallParticipantVideoOffRequest) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject)

Example 74 with AsyncMessage

use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.

the class CallAsyncRequestsManager method createCallRequestMessage.

public static String createCallRequestMessage(CallRequest request, String uniqueId) {
    CreateCallVO createCallVO = new CreateCallVO();
    createCallVO.setCreatorId(CoreConfig.userId);
    if (request.getSubjectId() <= 0)
        createCallVO.setInvitees(request.getInvitees());
    else
        createCallVO.setThreadId(request.getSubjectId());
    createCallVO.setType(request.getCallType());
    SendClientDTO sendClientDTO = new SendClientDTO();
    sendClientDTO.setVideo(request.getCallType() == CallType.Constants.VIDEO_CALL);
    sendClientDTO.setMute(false);
    sendClientDTO.setClientType(ClientType.Constants.ANDROID);
    JsonObject contentObj = (JsonObject) App.getGson().toJsonTree(createCallVO);
    JsonElement clientDtoObj = App.getGson().toJsonTree(sendClientDTO);
    contentObj.add("creatorClientDto", clientDtoObj);
    AsyncMessage message = new AsyncMessage();
    message.setContent(contentObj.toString());
    message.setType(ChatMessageType.Constants.CALL_REQUEST);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    JsonObject messageObj;
    if (Util.isNullOrEmpty(request.getInvitees())) {
        message.setSubjectId(request.getSubjectId());
        messageObj = (JsonObject) App.getGson().toJsonTree(message);
    } else {
        messageObj = (JsonObject) App.getGson().toJsonTree(message);
        messageObj.remove("subjectId");
    }
    return messageObj.toString();
}
Also used : SendClientDTO(com.fanap.podchat.call.model.SendClientDTO) JsonElement(com.google.gson.JsonElement) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject) CreateCallVO(com.fanap.podchat.call.model.CreateCallVO)

Example 75 with AsyncMessage

use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.

the class CallAsyncRequestsManager method createGetCallHistoryRequest.

public static String createGetCallHistoryRequest(GetCallHistoryRequest request, String uniqueId) {
    request.setCount(request.getCount() > 0 ? request.getCount() : 50);
    JsonObject content = (JsonObject) App.getGson().toJsonTree(request);
    if (request.getCreatorSsoId() == 0)
        content.remove("creatorSsoId");
    if (request.getCreatorCoreUserId() == 0)
        content.remove("creatorCoreUserId");
    if (request.getThreadId() == null || request.getThreadId() <= 0)
        content.remove("threadId");
    content.remove("useCache");
    AsyncMessage message = new AsyncMessage();
    message.setContent(content.toString());
    message.setType(ChatMessageType.Constants.GET_CALLS);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setTypeCode(Util.isNullOrEmpty(request.getTypeCode()) ? CoreConfig.typeCode : request.getTypeCode());
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(message);
    jsonObject.remove("subjectId");
    return jsonObject.toString();
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Aggregations

AsyncMessage (com.fanap.podchat.mainmodel.AsyncMessage)78 JsonObject (com.google.gson.JsonObject)53 ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)20 PodChatException (com.fanap.podchat.util.PodChatException)7 JsonElement (com.google.gson.JsonElement)6 JsonArray (com.google.gson.JsonArray)5 ChatMessageContent (com.fanap.podchat.mainmodel.ChatMessageContent)4 ArrayList (java.util.ArrayList)4 SendClientDTO (com.fanap.podchat.call.model.SendClientDTO)3 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)3 PodThreadManager (com.fanap.podchat.util.PodThreadManager)3 CreateCallVO (com.fanap.podchat.call.model.CreateCallVO)2 TurnCallParticipantVideoOffRequest (com.fanap.podchat.call.request_model.TurnCallParticipantVideoOffRequest)2 Invitee (com.fanap.podchat.mainmodel.Invitee)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 TypeToken (com.google.gson.reflect.TypeToken)2 SentryException (io.sentry.core.protocol.SentryException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 JSONException (org.json.JSONException)2