Search in sources :

Example 1 with SendClientDTO

use of com.fanap.podchat.call.model.SendClientDTO 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)

Example 2 with SendClientDTO

use of com.fanap.podchat.call.model.SendClientDTO 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 3 with SendClientDTO

use of com.fanap.podchat.call.model.SendClientDTO 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)

Aggregations

SendClientDTO (com.fanap.podchat.call.model.SendClientDTO)3 AsyncMessage (com.fanap.podchat.mainmodel.AsyncMessage)3 JsonElement (com.google.gson.JsonElement)3 JsonObject (com.google.gson.JsonObject)3 CreateCallVO (com.fanap.podchat.call.model.CreateCallVO)2 CreateCallThread (com.fanap.podchat.call.model.CreateCallThread)1