@Override protected void onStart() { super.onStart(); try { Ortc ortc = new Ortc(); OrtcFactory factory; factory = ortc.loadOrtcFactory("IbtRealtimeSJ"); client = factory.createClient(); } catch (Exception e) { log(String.format("ORTC CREATE ERROR: %s", e.toString())); } if (client != null) { try { client.onConnected = new OnConnected() { public void run(final OrtcClient sender) { runOnUiThread( new Runnable() { public void run() { log(String.format("Connected to: %s", ((OrtcClient) sender).getUrl())); } }); } }; client.onDisconnected = new OnDisconnected() { public void run(OrtcClient arg0) { runOnUiThread( new Runnable() { public void run() { log("Disconnected"); } }); } }; client.onSubscribed = new OnSubscribed() { public void run(OrtcClient sender, String channel) { final String subscribedChannel = channel; runOnUiThread( new Runnable() { public void run() { log(String.format("Subscribed to channel: %s", subscribedChannel)); } }); } }; client.onUnsubscribed = new OnUnsubscribed() { public void run(OrtcClient sender, String channel) { final String subscribedChannel = channel; runOnUiThread( new Runnable() { public void run() { log(String.format("Unsubscribed from channel: %s", subscribedChannel)); } }); } }; client.onException = new OnException() { public void run(OrtcClient send, Exception ex) { final Exception exception = ex; runOnUiThread( new Runnable() { public void run() { log(String.format("Error: %s", exception.getMessage())); } }); } }; client.onReconnected = new OnReconnected() { public void run(final OrtcClient sender) { runOnUiThread( new Runnable() { public void run() { reconnectingTries = 0; log(String.format("Reconnected to: %s", ((OrtcClient) sender).getUrl())); } }); } }; client.onReconnecting = new OnReconnecting() { public void run(OrtcClient sender) { runOnUiThread( new Runnable() { public void run() { reconnectingTries++; log(String.format("Reconnecting %s...", reconnectingTries)); } }); } }; } catch (Exception e) { log(String.format("ORTC EXCEPTION: %s", e.toString())); } } }