-
-
Save jgc128/8003229 to your computer and use it in GitHub Desktop.
Nutcracker Android code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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