Search in sources :

Example 21 with PodChatException

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

the class CallAsyncRequestsManager method createTurnOffVideoMessage.

public static String createTurnOffVideoMessage(TurnCallParticipantVideoOffRequest 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.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();
}
Also used : PodChatException(com.fanap.podchat.util.PodChatException) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 22 with PodChatException

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

the class CallAsyncRequestsManager method createGetActiveCallParticipantsMessage.

public static String createGetActiveCallParticipantsMessage(GetCallParticipantsRequest request, String uniqueId) throws PodChatException {
    if (request.getCallId() <= 0)
        throw new PodChatException("Invalid call id", ChatConstant.ERROR_CODE_INVALID_THREAD_ID, uniqueId);
    AsyncMessage message = new AsyncMessage();
    message.setType(ChatMessageType.Constants.GET_ACTIVE_CALL_PARTICIPANTS);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setSubjectId(request.getCallId());
    message.setTypeCode(Util.isNotNullOrEmpty(request.getTypeCode()) ? request.getTypeCode() : CoreConfig.typeCode);
    return App.getGson().toJson(message);
}
Also used : PodChatException(com.fanap.podchat.util.PodChatException) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 23 with PodChatException

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

the class Chat method handOnShareScreenStarted.

@Override
void handOnShareScreenStarted(ChatMessage chatMessage, Callback callback) {
    if (deviceIsInCall) {
        if (sentryResponseLog) {
            showLog("RECEIVE_SHARE_SCREEN_STARTED", gson.toJson(chatMessage));
        } else {
            showLog("RECEIVE_SHARE_SCREEN_STARTED");
        }
        if (podVideoCall != null) {
            ChatResponse<ScreenShareResult> response = CallAsyncRequestsManager.handleOnScreenShareStarted(chatMessage);
            if (Util.isNotNullOrEmpty(response.getResult().getScreenShare())) {
                if (callback != null) {
                    removeCallback(chatMessage.getUniqueId());
                    ScreenSharer screenSharer = new ScreenSharer.Builder().setPartnerType(PartnerType.LOCAL).setName("Your Screen").setVideoTopic(response.getResult().getScreenShare()).build();
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        podVideoCall.addScreenSharer(screenSharer);
                        listenerManager.callOnScreenShareStarted(response);
                    }
                } else {
                    addScreenSharer(response);
                }
            } else {
                captureError(new PodChatException(ChatConstant.ERROR_METHOD_NOT_IMPLEMENTED, ChatConstant.ERROR_CODE_METHOD_NOT_IMPLEMENTED, chatMessage.getUniqueId()));
            }
        }
    }
}
Also used : ScreenShareResult(com.fanap.podchat.call.request_model.screen_share.ScreenShareResult) PodChatException(com.fanap.podchat.util.PodChatException) ScreenSharer(com.fanap.podcall.screenshare.model.ScreenSharer) PodCallBuilder(com.fanap.podcall.PodCallBuilder)

Example 24 with PodChatException

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

the class Chat method setupCall.

@Deprecated
public void setupCall(VideoCallParam videoCallParam, AudioCallParam audioCallParam, List<CallPartnerView> remoteViews) {
    this.localPartnerView = videoCallParam.getCameraPreview();
    this.videoCallPartnerViews = new ArrayList<>(remoteViews);
    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("Camera is ready");
        }
    }).setVideoCallParam(videoCallParam).setAudioCallParam(audioCallParam).build();
    podVideoCall.initial();
}
Also used : 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