use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class CallAsyncRequestsManager method createTurnOffVideoMessage.
public static String createTurnOffVideoMessage(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_OFF_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();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class CallAsyncRequestsManager method createEndShareScreenMessage.
public static String createEndShareScreenMessage(EndShareScreenRequest request, String uniqueId) {
AsyncMessage message = new AsyncMessage();
message.setType(ChatMessageType.Constants.END_SHARE_SCREEN);
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 jsonObject = (JsonObject) App.getGson().toJsonTree(message);
return jsonObject.toString();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method getThreadAdminsMain.
private String getThreadAdminsMain(int count, int offset, long threadId, String typeCode, boolean useCache, ChatHandler handler) {
String uniqueId = generateUniqueId();
final int mCount = count != 0 ? count : 50;
PodThreadManager podThreadManager = new PodThreadManager();
podThreadManager.addTask(() -> {
if (cache && useCache) {
loadAdminsFromCache(uniqueId, mCount, offset, threadId);
}
});
podThreadManager.addTask(() -> {
if (chatReady) {
JsonObject content = new JsonObject();
content.addProperty("count", mCount);
content.addProperty("offset", offset);
content.addProperty("admin", true);
AsyncMessage chatMessage = new AsyncMessage();
chatMessage.setContent(content.toString());
chatMessage.setType(Constants.THREAD_PARTICIPANTS);
chatMessage.setTokenIssuer(String.valueOf(TOKEN_ISSUER));
chatMessage.setToken(getToken());
chatMessage.setUniqueId(uniqueId);
chatMessage.setSubjectId(threadId);
chatMessage.setTypeCode(typeCode != null ? typeCode : getTypeCode());
JsonObject jsonObject = (JsonObject) gson.toJsonTree(chatMessage);
String asyncContent = jsonObject.toString();
setCallBacks(null, null, null, true, Constants.THREAD_PARTICIPANTS, (long) offset, uniqueId);
sendAsyncMessage(asyncContent, AsyncAckType.Constants.WITHOUT_ACK, "SEND_GET_THREAD_ADMINS");
if (handler != null) {
handler.onGetThreadParticipant(uniqueId);
}
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
}
});
podThreadManager.runTasksSynced();
return uniqueId;
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method updateThreadInfo.
private String updateThreadInfo(long threadId, ThreadInfoVO threadInfoVO, String userGroupHash, RequestUploadImage requestUploadThreadPicture, ChatHandler handler) {
String uniqueId = generateUniqueId();
try {
if (Util.isNullOrEmpty(userGroupHash)) {
captureError(ChatConstant.ERROR_INVALID_USER_GROUP_HASH, ChatConstant.ERROR_CODE_INVALID_USER_GROUP_HASH, uniqueId);
return uniqueId;
}
if (chatReady) {
JsonObject threadMetadataObject;
if (Util.isNullOrEmpty(threadInfoVO.getMetadata())) {
threadMetadataObject = new JsonObject();
} else {
threadMetadataObject = parser.parse(threadInfoVO.getMetadata()).getAsJsonObject();
}
JsonObject contentObject = new JsonObject();
contentObject.addProperty("name", threadInfoVO.getTitle());
contentObject.addProperty("description", threadInfoVO.getDescription());
Runnable updateThreadTask = () -> {
String content = contentObject.toString();
AsyncMessage chatMessage = new AsyncMessage();
chatMessage.setContent(content);
chatMessage.setTokenIssuer("1");
chatMessage.setToken(getToken());
chatMessage.setSubjectId(threadId);
chatMessage.setUniqueId(uniqueId);
chatMessage.setType(Constants.UPDATE_THREAD_INFO);
JsonObject jsonObject = (JsonObject) gson.toJsonTree(chatMessage);
jsonObject.remove("contentCount");
jsonObject.remove("systemMetadata");
// jsonObject.remove("metadata");
jsonObject.remove("repliedTo");
if (Util.isNullOrEmpty(typeCode)) {
if (Util.isNullOrEmpty(getTypeCode())) {
jsonObject.remove("typeCode");
} else {
jsonObject.addProperty("typeCode", getTypeCode());
}
} else {
jsonObject.addProperty("typeCode", typeCode);
}
setCallBacks(null, null, null, true, Constants.UPDATE_THREAD_INFO, null, uniqueId);
sendAsyncMessage(jsonObject.toString(), AsyncAckType.Constants.WITHOUT_ACK, "SEND_UPDATE_THREAD_INFO");
if (handler != null) {
handler.onUpdateThreadInfo(uniqueId);
}
};
uploadImageToThread(requestUploadThreadPicture, userGroupHash, uniqueId, null, hashCode -> {
if (hashCode != null) {
String imageHashCode = (String) hashCode;
String imageLink = getPodSpaceImageUrl(imageHashCode);
threadMetadataObject.addProperty("fileHash", imageHashCode);
contentObject.addProperty("metadata", threadMetadataObject.toString());
contentObject.addProperty("image", imageLink);
updateThreadTask.run();
}
});
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
}
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(uniqueId, e);
}
return uniqueId;
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method signalMessage.
private void signalMessage(RequestSignalMsg requestSignalMsg, String logMessage, String uniqueId) {
int signalType = requestSignalMsg.getSignalType();
long threadId = requestSignalMsg.getThreadId();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("type", String.valueOf(signalType));
AsyncMessage chatMessage = new AsyncMessage();
chatMessage.setContent(jsonObject.toString());
chatMessage.setType(Constants.SYSTEM_MESSAGE);
chatMessage.setToken(getToken());
chatMessage.setTokenIssuer(String.valueOf(TOKEN_ISSUER));
chatMessage.setUniqueId(uniqueId);
chatMessage.setSubjectId(threadId);
sendAsyncMessage(gson.toJson(chatMessage), AsyncAckType.Constants.WITHOUT_ACK, logMessage);
}
Aggregations