Search in sources :

Example 1 with ResultSignalMessage

use of com.fanap.podchat.model.ResultSignalMessage in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method handleSystemMessage.

private void handleSystemMessage(Callback callback, ChatMessage chatMessage, String messageUniqueId) {
    if (callback != null && callback.isResult()) {
        messageCallbacks.remove(messageUniqueId);
    }
    ChatResponse<ResultSignalMessage> result = reformatSignalMessage(chatMessage);
    listenerManager.callOnGetSignalMessage(result);
    if (result == null) {
        return;
    }
    OutputSignalMessage output = new OutputSignalMessage();
    output.setResultSignalMessage(result.getResult());
    output.setSubjectId(result.getSubjectId());
    output.setUniqueId(result.getUniqueId());
    ResultSignalMessage sm = result.getResult();
    output.setSignalMessageType(getSignalMessageType(sm.getSmt()));
    output.setSignalSenderName(sm.getUser());
    if (sentryResponseLog) {
        showLog("RECEIVE_SIGNAL_MESSAGE", gson.toJson(output));
    } else {
        showLog("RECEIVE_SIGNAL_MESSAGE");
    }
    listenerManager.callOnGetSignalMessage(output);
}
Also used : OutputSignalMessage(com.fanap.podchat.model.OutputSignalMessage) ResultSignalMessage(com.fanap.podchat.model.ResultSignalMessage)

Example 2 with ResultSignalMessage

use of com.fanap.podchat.model.ResultSignalMessage in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method reformatSignalMessage.

private ChatResponse<ResultSignalMessage> reformatSignalMessage(ChatMessage chatMessage) {
    ChatResponse<ResultSignalMessage> result = new ChatResponse<>();
    ResultSignalMessage signalMessage;
    try {
        signalMessage = gson.fromJson(chatMessage.getContent(), ResultSignalMessage.class);
    } catch (JsonSyntaxException e) {
        showErrorLog(e.getMessage());
        onUnknownException(chatMessage.getUniqueId(), e);
        return null;
    }
    result.setSubjectId(chatMessage.getSubjectId());
    result.setUniqueId(chatMessage.getUniqueId());
    result.setResult(signalMessage);
    return result;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) ResultSignalMessage(com.fanap.podchat.model.ResultSignalMessage) ChatResponse(com.fanap.podchat.model.ChatResponse)

Aggregations

ResultSignalMessage (com.fanap.podchat.model.ResultSignalMessage)2 ChatResponse (com.fanap.podchat.model.ChatResponse)1 OutputSignalMessage (com.fanap.podchat.model.OutputSignalMessage)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1