Search in sources :

Example 1 with PodChatException

use of com.fanap.podchat.util.PodChatException in project pod-chat-android-sdk by FanapSoft.

the class CacheDataSource method getWaitQueueUniqueIdList.

public Observable<List<String>> getWaitQueueUniqueIdList() {
    return Observable.create(emitter -> {
        try {
            databaseHelper.getWaitQueueUniqueIdList(o -> {
                try {
                    if (o != null) {
                        List<String> data = (List<String>) o;
                        emitter.onNext(data);
                    } else {
                        emitter.onError(new PodChatException("No uniqueId found", ChatConstant.ERROR_CODE_UNKNOWN_EXCEPTION));
                    }
                } catch (Exception e) {
                    emitter.onError(e);
                }
            });
        } catch (RoomIntegrityException e) {
            emitter.onError(e);
        }
    });
}
Also used : PodChatException(com.fanap.podchat.util.PodChatException) RoomIntegrityException(com.fanap.podchat.persistance.RoomIntegrityException) ArrayList(java.util.ArrayList) List(java.util.List) PodChatException(com.fanap.podchat.util.PodChatException) RoomIntegrityException(com.fanap.podchat.persistance.RoomIntegrityException)

Example 2 with PodChatException

use of com.fanap.podchat.util.PodChatException in project pod-chat-android-sdk by FanapSoft.

the class CallAsyncRequestsManager method createMuteCallParticipantMessage.

public static String createMuteCallParticipantMessage(MuteUnMuteCallParticipantRequest request, String uniqueId) throws PodChatException {
    if (request.getCallId() <= 0)
        throw new PodChatException(ChatConstant.ERROR_INVALID_THREAD_ID, ChatConstant.ERROR_CODE_INVALID_THREAD_ID);
    if (Util.isNullOrEmpty(request.getParticipantsIds()))
        throw new PodChatException(ChatConstant.MUTE_USER_LIST_IS_EMPTY, ChatConstant.ERROR_CODE_INVALID_DATA);
    String content = App.getGson().toJson(request.getParticipantsIds());
    AsyncMessage message = new AsyncMessage();
    message.setContent(content);
    message.setType(ChatMessageType.Constants.MUTE_CALL_PARTICIPANT);
    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();
}
Also used : PodChatException(com.fanap.podchat.util.PodChatException) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 3 with PodChatException

use of com.fanap.podchat.util.PodChatException in project pod-chat-android-sdk by FanapSoft.

the class Chat method startVideoCall.

private void startVideoCall(ChatResponse<StartedCallModel> info) {
    if (podVideoCall != null) {
        KafkaConfig kafkaConfig = new KafkaConfig.Builder(info.getResult().getChatDataDTO().getBrokerAddress()).setSsl(info.getResult().getCert_file()).build();
        podVideoCall.setKafkaConfig(kafkaConfig);
        ClientDTO localClient = info.getResult().getClientDTO();
        String sendVideoTopic = localClient.getTopicSendVideo();
        String sendAudioTopic = localClient.getTopicSendAudio();
        CallPartner.Builder lCallPartnerBuilder = new CallPartner.Builder();
        lCallPartnerBuilder.setPartnerType(PartnerType.LOCAL);
        lCallPartnerBuilder.setName(info.getResult().getClientDTO().getSendKey() + "" + sendVideoTopic);
        if (localClient.getVideo()) {
            visibleView(localPartnerView);
            localPartnerView.setPartnerId(CoreConfig.userId);
            localPartnerView.setPartnerName("You");
            lCallPartnerBuilder.setVideoTopic(sendVideoTopic);
            lCallPartnerBuilder.setVideoView(localPartnerView);
        }
        lCallPartnerBuilder.setAudioTopic(sendAudioTopic);
        podVideoCall.addPartner(lCallPartnerBuilder.build());
        if (Util.isNotNullOrEmpty(info.getResult().getOtherClientDtoList())) {
            prepareRemotePartnersByClientDTOList(info);
        } else {
            captureError(new PodChatException("Util.isNotNullOrEmpty(info.getResult().getOtherClientDtoList()) == false", ChatConstant.ERROR_CODE_INVALID_DATA));
        }
        try {
            podVideoCall.startCall();
        } catch (MicrophoneUnavailableException e) {
            captureError(new PodChatException(e.getMessage(), ChatConstant.ERROR_CODE_MICROPHONE_NOT_AVAILABLE, info.getUniqueId()));
            sendClientCallErrors(new CallClientErrorsRequest.Builder(info.getSubjectId(), ChatConstant.ERROR_CODE_MICROPHONE_NOT_AVAILABLE).build());
        } catch (CameraUnavailableException e) {
            captureError(new PodChatException(e.getMessage(), ChatConstant.ERROR_CODE_CAMERA_NOT_AVAILABLE, info.getUniqueId()));
            sendClientCallErrors(new CallClientErrorsRequest.Builder(info.getSubjectId(), ChatConstant.ERROR_CODE_CAMERA_NOT_AVAILABLE).build());
        }
        if (callServiceManager != null)
            callServiceManager.startCallService(info, new ICallState() {

                @Override
                public void onInfoEvent(String info) {
                }

                @Override
                public void onErrorEvent(String cause) {
                }

                @Override
                public void onEndCallRequested() {
                    endCall();
                    endCall(CallAsyncRequestsManager.createEndCallRequest(info.getSubjectId()));
                    listenerManager.callOnEndCallRequestFromNotification();
                }
            });
    }
}
Also used : CallClientErrorsRequest(com.fanap.podchat.call.request_model.CallClientErrorsRequest) PodChatException(com.fanap.podchat.util.PodChatException) MicrophoneUnavailableException(com.fanap.podcall.error.MicrophoneUnavailableException) PodCallBuilder(com.fanap.podcall.PodCallBuilder) ClientDTO(com.fanap.podchat.call.model.ClientDTO) CameraUnavailableException(com.fanap.podcall.error.CameraUnavailableException) ICallState(com.fanap.podchat.call.audio_call.ICallState) CallPartner(com.fanap.podcall.model.CallPartner) KafkaConfig(com.fanap.podcall.kafka.KafkaConfig)

Example 4 with PodChatException

use of com.fanap.podchat.util.PodChatException in project pod-chat-android-sdk by FanapSoft.

the class Chat method replacePartnersView.

public void replacePartnersView(ReplaceViewsRequest request) {
    if (podVideoCall != null) {
        if (viewPool != null) {
            if (viewPool.isScreenShareViewChanging(request.getPartnerToRemoveVideoUserId(), request.getView())) {
                captureError(new PodChatException("It's not possible to change screen share view during call", ChatConstant.ERROR_CODE_INVALID_REQUEST));
                return;
            }
            if (viewPool.isScreenShareViewChanging(request.getPartnerToAddVideoUserId(), request.getView())) {
                captureError(new PodChatException("It's not possible to change screen share view during call", ChatConstant.ERROR_CODE_INVALID_REQUEST));
                return;
            }
            boolean result = viewPool.setPartnerView(request.getPartnerToAddVideoUserId(), request.getView());
            if (result) {
                turnOffIncomingVideo(request.getPartnerToRemoveVideoUserId());
                if (viewPool != null) {
                    viewPool.releasePartnerView(request.getPartnerToRemoveVideoUserId());
                }
                podVideoCall.addPartnerVideo(request.getPartnerToAddVideoUserId(), request.getView());
            }
        }
    }
}
Also used : PodChatException(com.fanap.podchat.util.PodChatException)

Example 5 with PodChatException

use of com.fanap.podchat.util.PodChatException in project pod-chat-android-sdk by FanapSoft.

the class Chat method setupCall.

public void setupCall(VideoCallParam videoCallParam, AudioCallParam audioCallParam, ScreenShareParam screenShareParam, CallConfig callConfig) {
    this.localPartnerView = videoCallParam.getCameraPreview();
    callServiceManager = new CallServiceManager(context, callConfig);
    podVideoCall = new PodCallBuilder(context, new IPodCall() {

        @Override
        public void onError(String s) {
            captureError(new PodChatException(s, ChatConstant.ERROR_CODE_CALL_INITIAL_ERROR));
        }

        @Override
        public void onEvent(String s) {
            showLog(s);
        }

        @Override
        public void onCameraReady(PodCall podCall) {
            showLog("Call is ready");
        }

        @Override
        public void onCameraIsNotAvailable(String message) {
            captureError(new PodChatException(ChatConstant.ERROR_CAMERA_NOT_AVAILABLE, ChatConstant.ERROR_CODE_CAMERA_NOT_AVAILABLE));
        }

        @Override
        public void onMicrophoneIsNotAvailable(String message) {
            captureError(new PodChatException(ChatConstant.ERROR_MICROPHONE_NOT_AVAILABLE, ChatConstant.ERROR_CODE_MICROPHONE_NOT_AVAILABLE));
        }

        @Override
        public void onDeviceIsNear() {
            listenerManager.callOnDeviceIsNear();
        }

        @Override
        public void onDeviceGotFar() {
            listenerManager.callOnDeviceGotFar();
        }
    }).setVideoCallParam(videoCallParam).setAudioCallParam(audioCallParam).setScreenShareParam(screenShareParam).build();
    podVideoCall.initial();
}
Also used : CallServiceManager(com.fanap.podchat.call.audio_call.CallServiceManager) PodChatException(com.fanap.podchat.util.PodChatException) PodCallBuilder(com.fanap.podcall.PodCallBuilder) IPodCall(com.fanap.podcall.IPodCall) IPodCall(com.fanap.podcall.IPodCall) PodCall(com.fanap.podcall.PodCall)

Aggregations

PodChatException (com.fanap.podchat.util.PodChatException)24 NonNull (android.support.annotation.NonNull)8 ChatResponse (com.fanap.podchat.model.ChatResponse)7 Response (retrofit2.Response)7 Context (android.content.Context)6 BitmapFactory (android.graphics.BitmapFactory)6 Uri (android.net.Uri)6 Log (android.util.Log)6 UploadingQueueCache (com.fanap.podchat.cachemodel.queue.UploadingQueueCache)6 TAG (com.fanap.podchat.chat.Chat.TAG)6 FileUpload (com.fanap.podchat.mainmodel.FileUpload)6 FileImageUpload (com.fanap.podchat.model.FileImageUpload)6 ResultFile (com.fanap.podchat.model.ResultFile)6 ResultImageFile (com.fanap.podchat.model.ResultImageFile)6 ProgressRequestBody (com.fanap.podchat.networking.ProgressRequestBody)6 FileApi (com.fanap.podchat.networking.api.FileApi)6 RetrofitHelperFileServer (com.fanap.podchat.networking.retrofithelper.RetrofitHelperFileServer)6 ChatConstant (com.fanap.podchat.util.ChatConstant)6 FilePick (com.fanap.podchat.util.FilePick)6 FileUtils (com.fanap.podchat.util.FileUtils)6