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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations