Search in sources :

Example 16 with AsyncMessage

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

the class CallAsyncRequestsManager method createRemoveCallParticipantMessage.

public static String createRemoveCallParticipantMessage(RemoveParticipantRequest request, String uniqueId) {
    JsonArray participantsJsonArray = new JsonArray();
    for (Long participantId : request.getParticipantIds()) {
        participantsJsonArray.add(participantId);
    }
    AsyncMessage chatMessage = new AsyncMessage();
    chatMessage.setTokenIssuer(CoreConfig.tokenIssuer);
    chatMessage.setToken(CoreConfig.token);
    chatMessage.setContent(participantsJsonArray.toString());
    chatMessage.setSubjectId(request.getThreadId());
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setType(ChatMessageType.Constants.REMOVE_CALL_PARTICIPANT);
    chatMessage.setTypeCode(Util.isNullOrEmpty(request.getTypeCode()) ? CoreConfig.typeCode : request.getTypeCode());
    JsonObject messageObj = (JsonObject) App.getGson().toJsonTree(chatMessage);
    return messageObj.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 17 with AsyncMessage

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

the class CallAsyncRequestsManager method createAddCallParticipantMessage.

public static String createAddCallParticipantMessage(RequestAddParticipants request, String uniqueId) {
    JsonArray participantsJsonArray = new JsonArray();
    if (request.getContactIds() != null) {
        for (Long p : request.getContactIds()) {
            participantsJsonArray.add(p);
        }
    } else if (request.getUserNames() != null) {
        for (String username : request.getUserNames()) {
            Invitee invitee = new Invitee();
            invitee.setId(username);
            invitee.setIdType(InviteType.Constants.TO_BE_USER_USERNAME);
            JsonElement jsonElement = App.getGson().toJsonTree(invitee);
            participantsJsonArray.add(jsonElement);
        }
    } else {
        for (Long coreUserId : request.getCoreUserIds()) {
            Invitee invitee = new Invitee();
            invitee.setId(coreUserId);
            invitee.setIdType(InviteType.Constants.TO_BE_USER_ID);
            JsonElement jsonElement = App.getGson().toJsonTree(invitee);
            participantsJsonArray.add(jsonElement);
        }
    }
    AsyncMessage chatMessage = new AsyncMessage();
    chatMessage.setTokenIssuer("1");
    chatMessage.setToken(CoreConfig.token);
    chatMessage.setContent(participantsJsonArray.toString());
    chatMessage.setSubjectId(request.getThreadId());
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setType(ChatMessageType.Constants.ADD_CALL_PARTICIPANT);
    chatMessage.setTypeCode(Util.isNullOrEmpty(request.getTypeCode()) ? CoreConfig.typeCode : request.getTypeCode());
    JsonObject messageObj = (JsonObject) App.getGson().toJsonTree(chatMessage);
    return messageObj.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) Invitee(com.fanap.podchat.mainmodel.Invitee) JsonElement(com.google.gson.JsonElement) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 18 with AsyncMessage

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

the class CallAsyncRequestsManager method createTerminateCallMessage.

public static String createTerminateCallMessage(TerminateCallRequest request, String uniqueId) {
    AsyncMessage message = new AsyncMessage();
    message.setType(ChatMessageType.Constants.TERMINATE_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 19 with AsyncMessage

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

the class CallAsyncRequestsManager method createStartRecordCall.

public static String createStartRecordCall(StartOrEndCallRecordRequest request, String uniqueId) {
    AsyncMessage message = new AsyncMessage();
    message.setType(ChatMessageType.Constants.START_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 20 with AsyncMessage

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

the class CallAsyncRequestsManager method createGroupCallRequestMessage.

public static String createGroupCallRequestMessage(CallRequest request, String uniqueId) {
    CreateCallVO createCallVO = new CreateCallVO();
    createCallVO.setGroup(true);
    createCallVO.setCreatorId(CoreConfig.userId);
    if (request.getSubjectId() <= 0)
        createCallVO.setInvitees(request.getInvitees());
    else
        createCallVO.setThreadId(request.getSubjectId());
    createCallVO.setType(request.getCallType());
    CreateCallThread callThread = null;
    if (Util.isNotNullOrEmpty(request.getTitle())) {
        callThread = new CreateCallThread();
        callThread.setTitle(request.getTitle());
    }
    if (Util.isNotNullOrEmpty(request.getImage())) {
        if (callThread == null)
            callThread = new CreateCallThread();
        callThread.setImage(request.getImage());
    }
    if (Util.isNotNullOrEmpty(request.getDescription())) {
        if (callThread == null)
            callThread = new CreateCallThread();
        callThread.setDescription(request.getDescription());
    }
    if (Util.isNotNullOrEmpty(request.getMetadata())) {
        if (callThread == null)
            callThread = new CreateCallThread();
        callThread.setMetadata(request.getMetadata());
    }
    if (Util.isNotNullOrEmpty(request.getUniqueName())) {
        if (callThread == null)
            callThread = new CreateCallThread();
        callThread.setUniqueName(request.getUniqueName());
    }
    if (callThread != null) {
        createCallVO.setCreateCallThreadRequest(callThread);
    }
    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);
    if (callThread == null) {
        contentObj.remove("createCallThreadRequest");
    }
    AsyncMessage message = new AsyncMessage();
    message.setContent(contentObj.toString());
    message.setType(ChatMessageType.Constants.GROUP_CALL_REQUEST);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    JsonObject 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) CreateCallThread(com.fanap.podchat.call.model.CreateCallThread)

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