Search in sources :

Example 6 with CallParticipantVO

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

the class CallAsyncRequestsManager method handleOnParticipantRemoved.

public static ChatResponse<RemoveFromCallResult> handleOnParticipantRemoved(ChatMessage chatMessage) {
    ChatResponse<RemoveFromCallResult> response = new ChatResponse<>();
    ArrayList<CallParticipantVO> participantsLeft = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<CallParticipantVO>>() {
    }.getType());
    RemoveFromCallResult result = new RemoveFromCallResult();
    result.setCallId(chatMessage.getSubjectId());
    result.setCallParticipants(participantsLeft);
    if (Util.isNotNullOrEmpty(participantsLeft))
        result.setUserRemoved(isUserContains(participantsLeft));
    response.setResult(result);
    response.setSubjectId(chatMessage.getSubjectId());
    response.setUniqueId(chatMessage.getUniqueId());
    return response;
}
Also used : CallParticipantVO(com.fanap.podchat.call.model.CallParticipantVO) RemoveFromCallResult(com.fanap.podchat.call.result_model.RemoveFromCallResult) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse)

Example 7 with CallParticipantVO

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

the class CallAsyncRequestsManager method handleOnCallCanceled.

public static ChatResponse<CallCancelResult> handleOnCallCanceled(ChatMessage chatMessage) {
    ChatResponse<CallCancelResult> response = new ChatResponse<>();
    try {
        CallParticipantVO participantVO = App.getGson().fromJson(chatMessage.getContent(), CallParticipantVO.class);
        CallCancelResult result = new CallCancelResult(participantVO);
        response.setResult(result);
        response.setHasError(false);
        response.setUniqueId(chatMessage.getUniqueId());
        response.setSubjectId(chatMessage.getSubjectId());
        response.setCache(false);
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        response.setCache(false);
        response.setHasError(true);
        response.setUniqueId(chatMessage.getUniqueId());
        response.setSubjectId(chatMessage.getSubjectId());
        response.setErrorCode(ChatConstant.ERROR_CODE_INVALID_DATA);
        response.setErrorMessage(ChatConstant.ERROR_INVALID_DATA);
        return response;
    }
}
Also used : CallParticipantVO(com.fanap.podchat.call.model.CallParticipantVO) ChatResponse(com.fanap.podchat.model.ChatResponse) CallCancelResult(com.fanap.podchat.call.result_model.CallCancelResult) PodChatException(com.fanap.podchat.util.PodChatException) JsonSyntaxException(com.google.gson.JsonSyntaxException)

Example 8 with CallParticipantVO

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

the class CallAsyncRequestsManager method handleMuteUnMuteCallParticipant.

public static ChatResponse<MuteUnMuteCallParticipantResult> handleMuteUnMuteCallParticipant(ChatMessage chatMessage) {
    ChatResponse<MuteUnMuteCallParticipantResult> response = new ChatResponse<>();
    try {
        ArrayList<CallParticipantVO> mutedParticipants = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<CallParticipantVO>>() {
        }.getType());
        MuteUnMuteCallParticipantResult result = new MuteUnMuteCallParticipantResult(mutedParticipants);
        result.setCallId(chatMessage.getSubjectId());
        response.setResult(result);
        response.setCache(false);
        response.setSubjectId(chatMessage.getSubjectId());
        response.setUniqueId(chatMessage.getUniqueId());
        response.setHasError(false);
        return response;
    } catch (Exception e) {
        response.setCache(false);
        response.setSubjectId(chatMessage.getSubjectId());
        response.setUniqueId(chatMessage.getUniqueId());
        response.setHasError(true);
        response.setErrorMessage(e.getMessage());
        response.setErrorCode(ChatConstant.ERROR_CODE_INVALID_DATA);
        return response;
    }
}
Also used : CallParticipantVO(com.fanap.podchat.call.model.CallParticipantVO) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) MuteUnMuteCallParticipantResult(com.fanap.podchat.call.result_model.MuteUnMuteCallParticipantResult) PodChatException(com.fanap.podchat.util.PodChatException) JsonSyntaxException(com.google.gson.JsonSyntaxException)

Example 9 with CallParticipantVO

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

the class CallAsyncRequestsManager method reformatActiveCallParticipant.

public static ChatResponse<GetCallParticipantResult> reformatActiveCallParticipant(ChatMessage chatMessage) {
    try {
        ArrayList<CallParticipantVO> callParticipantVOS = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<CallParticipantVO>>() {
        }.getType());
        ChatResponse<GetCallParticipantResult> response = new ChatResponse<>();
        GetCallParticipantResult result = new GetCallParticipantResult(callParticipantVOS);
        result.setThreadId(chatMessage.getSubjectId());
        response.setResult(result);
        response.setSubjectId(chatMessage.getSubjectId());
        response.setUniqueId(chatMessage.getUniqueId());
        response.setCache(false);
        response.setHasError(false);
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        ChatResponse<GetCallParticipantResult> response = new ChatResponse<>();
        response.setErrorMessage(e.getMessage());
        response.setErrorCode(ChatConstant.ERROR_CODE_UNKNOWN_EXCEPTION);
        response.setHasError(true);
        return response;
    }
}
Also used : CallParticipantVO(com.fanap.podchat.call.model.CallParticipantVO) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) PodChatException(com.fanap.podchat.util.PodChatException) JsonSyntaxException(com.google.gson.JsonSyntaxException) GetCallParticipantResult(com.fanap.podchat.call.result_model.GetCallParticipantResult)

Example 10 with CallParticipantVO

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

the class Chat method addVideoCallPartner.

private void addVideoCallPartner(ChatResponse<JoinCallParticipantResult> response) {
    for (CallParticipantVO callParticipant : response.getResult().getJoinedParticipants()) {
        if (callParticipant.getUserId().equals(CoreConfig.userId)) {
            CallPartner.Builder lCallPartnerBuilder = new CallPartner.Builder();
            lCallPartnerBuilder.setPartnerType(PartnerType.LOCAL);
            lCallPartnerBuilder.setName("You");
            if (localPartnerView != null) {
                visibleView(localPartnerView);
                localPartnerView.setPartnerId(CoreConfig.userId);
                localPartnerView.setPartnerName("You");
                lCallPartnerBuilder.setVideoTopic(callParticipant.getSendTopicVideo());
                lCallPartnerBuilder.setVideoView(localPartnerView);
            }
            podVideoCall.addPartner(lCallPartnerBuilder.build());
        // todo fire an event for local partner
        } else {
            Long userId = callParticipant.getUserId();
            if (hasRemotePartnerView()) {
                CallPartnerView view = assignCallPartnerView(callParticipant.getUserId());
                if (view != null) {
                    view.setPartnerName(callParticipant.getParticipantVO() != null ? callParticipant.getParticipantVO().getName() : "");
                    visibleView(view);
                    podVideoCall.addPartnerVideo(userId, view);
                    listenerManager.callOnCallParticipantStartedVideo(response);
                } else {
                    listenerManager.callOnNoViewToAddNewPartnerError();
                }
            }
        }
    }
}
Also used : CallParticipantVO(com.fanap.podchat.call.model.CallParticipantVO) PodCallBuilder(com.fanap.podcall.PodCallBuilder) CallPartner(com.fanap.podcall.model.CallPartner) CallPartnerView(com.fanap.podcall.view.CallPartnerView)

Aggregations

CallParticipantVO (com.fanap.podchat.call.model.CallParticipantVO)18 CallPartnerView (com.fanap.podcall.view.CallPartnerView)7 ChatResponse (com.fanap.podchat.model.ChatResponse)7 PodChatException (com.fanap.podchat.util.PodChatException)5 JsonSyntaxException (com.google.gson.JsonSyntaxException)5 TypeToken (com.google.gson.reflect.TypeToken)5 PodCallBuilder (com.fanap.podcall.PodCallBuilder)2 CallPartner (com.fanap.podcall.model.CallPartner)2 JoinCallParticipantResult (com.fanap.podchat.call.result_model.JoinCallParticipantResult)2 ClientDTO (com.fanap.podchat.call.model.ClientDTO)1 SendClientDTO (com.fanap.podchat.call.model.SendClientDTO)1 ScreenShareResult (com.fanap.podchat.call.request_model.screen_share.ScreenShareResult)1 CallCancelResult (com.fanap.podchat.call.result_model.CallCancelResult)1 CallDeliverResult (com.fanap.podchat.call.result_model.CallDeliverResult)1 CallStartResult (com.fanap.podchat.call.result_model.CallStartResult)1 GetCallParticipantResult (com.fanap.podchat.call.result_model.GetCallParticipantResult)1 LeaveCallResult (com.fanap.podchat.call.result_model.LeaveCallResult)1 MuteUnMuteCallParticipantResult (com.fanap.podchat.call.result_model.MuteUnMuteCallParticipantResult)1 RemoveFromCallResult (com.fanap.podchat.call.result_model.RemoveFromCallResult)1 MainThreadExecutor (com.fanap.podchat.chat.MainThreadExecutor)1