Search in sources :

Example 76 with AsyncMessage

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

the class CallAsyncRequestsManager method createRejectCallRequest.

public static String createRejectCallRequest(RejectCallRequest request, String uniqueId) {
    AsyncMessage message = new AsyncMessage();
    message.setType(ChatMessageType.Constants.REJECT_CALL);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setSubjectId(request.getCallId());
    message.setUniqueId(uniqueId);
    JsonObject a = (JsonObject) App.getGson().toJsonTree(message);
    return a.toString();
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 77 with AsyncMessage

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

the class PodNotificationManager method createUpdateUserDeviceRequest.

private static void createUpdateUserDeviceRequest(String newToken) {
    String uniqueId = generateUniqueId();
    STATE = NEED_REFRESH_TOKEN;
    Map<String, String> tokensMap = new HashMap<>();
    tokensMap.put(fcmToken, newToken);
    AsyncMessage message = new AsyncMessage();
    message.setContent(App.getGson().toJson(tokensMap));
    message.setType(ChatMessageType.Constants.UPDATE_FCM_APP_USERS_DEVICE);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setTypeCode(CoreConfig.typeCode);
    messageUniqueId = uniqueId;
    listener.sendAsyncMessage(App.getGson().toJson(message), "UPDATE_FCM_APP_USERS_DEVICE");
}
Also used : HashMap(java.util.HashMap) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 78 with AsyncMessage

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

the class PodNotificationManager method createRegisterUserDeviceRequest.

private static void createRegisterUserDeviceRequest(Context context, long userId) {
    if (userId <= 0) {
        if (listener != null)
            listener.onNotificationEvent("Try to register device but user id was 0");
        return;
    }
    String uniqueId = generateUniqueId();
    STATE = NEED_REGISTER_USER_DEVICE;
    Map<String, String> userDeviceTokenMap = new HashMap<>();
    userDeviceTokenMap.put(fcmToken, String.valueOf(userId));
    FcmAppUsersVO fcmAppUsersVO = new FcmAppUsersVO();
    fcmAppUsersVO.setAppId(context.getApplicationInfo().packageName);
    fcmAppUsersVO.setUserDeviceTokenMap(userDeviceTokenMap);
    AsyncMessage message = new AsyncMessage();
    message.setContent(App.getGson().toJson(fcmAppUsersVO));
    message.setType(ChatMessageType.Constants.REGISTER_FCM_USER_DEVICE);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setTypeCode(CoreConfig.typeCode);
    messageUniqueId = uniqueId;
    listener.sendAsyncMessage(App.getGson().toJson(message), "Register notification device and user");
}
Also used : HashMap(java.util.HashMap) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

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