Skip to content

Instantly share code, notes, and snippets.

@lukaspili
Last active May 12, 2017 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaspili/76ae40012a3e8366ff3830c25cd650ae to your computer and use it in GitHub Desktop.
Save lukaspili/76ae40012a3e8366ff3830c25cd650ae to your computer and use it in GitHub Desktop.
Island join
fun channel(island: ChatIsland, channel: ChatChannel): Instance {
val json = JSONObject()
json.put("id", island.id)
json.put("name", island.name)
json.put("room_id", channel.id)
json.put("room", channel.name)
json.put("expiration", channel.expiration)
json.put("anonymous", channel.isAnonymous)
return Instance(
"${island.id}_${channel.name}",
json.toString(),
island.id,
island.name,
channel.name,
Type.Channel
)
}
fun conversation(userId1: String, userId2: String, channel: ChatChannel): Instance {
val id = listOf(userId1, userId2).sorted().joinToString("_")
val json = JSONObject()
json.put("id", id)
json.put("ref_island_id", channel.island.id)
json.put("ref_channel_name", channel.name)
return Instance(
id,
json.toString(),
channel.island.id,
channel.island.name,
channel.name,
Type.Conversation
)
}
fun reply(messageId: String, channel: ChatChannel): Instance {
val json = JSONObject()
json.put("id", messageId)
json.put("ref_island_id", channel.island.id)
json.put("ref_channel_id", channel.id)
json.put("ref_channel_name", channel.name)
json.put("anonymous", channel.isAnonymous)
return Instance(
messageId,
json.toString(),
channel.island.id,
channel.island.name,
channel.name,
Type.Reply
)
}
SocketService D socket emit: [join island]
SocketService D socket ack: [join island]
MessagingService D join island success: [c07021b0-197d-11e7-8b1b-f1f5942855ad_anonymous]
SocketService D socket emit: [device token]
SocketService D socket on: [update people]
D socket on: [prepend chat]
D socket on: [add person]
D socket ack: [device token]
MessagingService D update person content: {"action":"add person","island":{"id":"c07021b0-197d-11e7-8b1b-f1f5942855ad","name":"Barney's","c
hannel":"c07021b0-197d-11e7-8b1b-f1f5942855ad_anonymous","room":"anonymous","room_id":1,"anonymous":true,"expira
tion":172800},"person":{"uid":"72e040c0-06c6-11e7-a94b-7fa8d04216b2","username":"lptest","name":"App Siu","image
":"http:\/\/s3-us-west-1.amazonaws.com\/islands.content\/accounts\/72e040c0-06c6-11e7-a94b-7fa8d04216b2.jpg?v2",
"platform":"facebook","social_id":"1872298686326336","created":"2017-03-12T01:51:45.868Z","first":"App","last":"
Siu","bio":"Test toto","location":"","status":"online"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment