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);
}
});
}
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();
}
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();
}
});
}
}
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());
}
}
}
}
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();
}
Aggregations