in sdk/communication/azure-communication-chat/src/main/java/com/azure/android/communication/chat/implementation/notifications/signaling/CommunicationSignalingClient.java [217:261]
private void start(Context context, ISkypetokenProvider skypetokenProvider, String skypeUserToken) {
if (this.isRealtimeNotificationsStarted) {
return;
}
// Get trouterUrl from calling chat gateway
RealtimeNotificationConfig realTimeNotificationConfig = realtimeNotificationConfigClient.getRealtimeConfigs(skypeUserToken, serviceEndpoint, TROUTER_REALTIMECONFIG_API_VERSION);
// Remove the "https://" prefix from the URLs
String trouterHostname = realTimeNotificationConfig.getTrouterServiceUrl().replace("https://", "");
String registrarBasePath = realTimeNotificationConfig.getRegistrarServiceUrl().replace("https://", "");
logger.verbose(String.format("Received config from service. Trouter Hostname: %s, Registrar Base Path: %s", trouterHostname, registrarBasePath));
ITrouterAuthHeadersProvider trouterAuthHeadersProvider =
new TrouterSkypetokenAuthHeaderProvider(skypetokenProvider);
TrouterUrlRegistrationData registrationData = new TrouterUrlRegistrationData(
null,
TROUTER_APPLICATION_ID,
PLATFORM,
PLATFORM_UI_VERSION,
TROUTER_TEMPLATE_KEY,
null,
""
);
TrouterUrlRegistrar registrar = new TrouterUrlRegistrar(
skypetokenProvider,
registrationData,
registrarBasePath,
Integer.parseInt(TROUTER_MAX_REGISTRATION_TTLS)
);
try {
trouterListeners.clear();
trouterClientHost = TrouterClientHost.initialize(context, TROUTER_CLIENT_VERSION);
trouter = trouterClientHost.createTrouterClient(trouterAuthHeadersProvider,
new InMemoryConnectionDataCache(), trouterHostname);
trouter.withRegistrar(registrar);
trouter.start();
trouter.setUserActivityState(UserActivityState.ACTIVITY_ACTIVE);
this.isRealtimeNotificationsStarted = true;
} catch (Throwable e) {
logger.error(e.getMessage());
}
}