Skip to content

Instantly share code, notes, and snippets.

@jgc128
Created December 17, 2013 11:02
Show Gist options
  • Save jgc128/8003229 to your computer and use it in GitHub Desktop.
Save jgc128/8003229 to your computer and use it in GitHub Desktop.
Nutcracker Android code
if(client != null) {
try {
client.onConnected = new OnConnected() {
public void run(final OrtcClient sender) {
Log.i(LOG_TAG, "connected to " + sender.getUrl());
client.subscribe(notificationChannel, true, new OnMessage() {
public void run(OrtcClient sender, String channel, String message) {
handleMessage(message);
Log.i(LOG_TAG, "message received: " + message);
}
});
}
};
client.onSubscribed = new OnSubscribed() {
public void run(OrtcClient sender, String channel) {
final String subscribedChannel = channel;
Log.i(LOG_TAG, "subscribed to " + subscribedChannel);
}
};
} catch (Exception e) {
Log.i(LOG_TAG, "Exception " + e.toString());
}
if (isCluster) {
client.setClusterUrl(serverAddress);
}
else {
client.setUrl(serverAddress);
}
client.setConnectionMetadata(connectionMetadata);
client.connect(appKey,authToken);
}
public static ArrayList<Participant> fromJSONArray(JSONArray json)
{
try {
int i;
int len = json.length();
ArrayList<Participant> result = new ArrayList<Participant>(len);
for(i=0;i<len;i++)
{
JSONObject o = json.getJSONObject(i);
if(o != null)
result.add(fromJSONObject(o));
}
return result;
} catch (JSONException e) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment