-
Notifications
You must be signed in to change notification settings - Fork 30
Example WebSocket Messages
Mike Angstadt edited this page Jul 21, 2017
·
9 revisions
(event type = 1)
{
"r1" : {
"e" : [
{
"event_type" : 1,
"time_stamp" : 1498317444,
"content" : "test",
"id" : 76625573,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 37799434
}
],
"t" : 76625573,
"d" : 1
}
}(event type = 2)
{
"r1" : {
"e" : [
{
"event_type" : 2,
"time_stamp" : 1498317513,
"content" : "test4",
"id" : 76625602,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 37799446,
"message_edits" : 1
}
],
"t" : 76625602,
"d" : 1
}
}(event type = 10)
{
"r1" : {
"e" : [
{
"event_type" : 10,
"time_stamp" : 1498317513,
"id" : 76625609,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 37799446,
"message_edits" : 1
}
],
"t" : 76625609,
"d" : 1
}
}An event with an event_type of 18 gets broadcast to all rooms the user is in. In addition to this, a "new message" event gets sent to the room the message was posted in. If a reply was added to an existing message via an edit, then instead of a "new message" event being posted, a "message edited" event is posted (event_type = 2)
{
"r1" : {
"e" : [ {
"event_type" : 18,
"time_stamp" : 1500148961,
"content" : "@OakBot Test2",
"id" : 77322110,
"user_id" : 13379,
"target_user_id" : 4258326,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38145271,
"parent_id" : 38145269,
"show_parent" : true
}, {
"event_type" : 1,
"time_stamp" : 1500148961,
"content" : "@OakBot Test2",
"id" : 77322111,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38145271,
"parent_id" : 38145269,
"show_parent" : true
} ],
"t" : 77322111,
"d" : 2
},
"r139" : {
"e" : [ {
"event_type" : 18,
"time_stamp" : 1500148961,
"content" : "@OakBot Test2",
"id" : 77322110,
"user_id" : 13379,
"target_user_id" : 4258326,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38145271,
"parent_id" : 38145269,
"show_parent" : true
} ],
"t" : 77322111,
"d" : 2
}
}If multiple mentions exist in the message, only the first mention is considered.
An event with an event_type of 8 gets broadcast to all rooms the user is in. In addition to this, a "new message" event gets sent to the room the message was posted in.
{
"r1" : {
"e" : [ {
"event_type" : 8,
"time_stamp" : 1500332101,
"content" : "One @Oak two @Steven",
"id" : 77380914,
"user_id" : 13379,
"target_user_id" : 4258326,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38175407
}, {
"event_type" : 1,
"time_stamp" : 1500332101,
"content" : "One @Oak two @Steven",
"id" : 77380916,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38175407
} ],
"t" : 77380916,
"d" : 3
},
"r23262" : {
"e" : [ {
"event_type" : 8,
"time_stamp" : 1500332101,
"content" : "One @Oak two @Steven",
"id" : 77380914,
"user_id" : 13379,
"target_user_id" : 4258326,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38175407
} ],
"t" : 77380916,
"d" : 3
}
}{
"r1" : {
"e" : [ {
"event_type" : 6,
"time_stamp" : 1493352001,
"content" : "<i>"If you don't have confidence, you'll always find a way not to win"</i> -Carl Lewis <a href=\"https://theysaidso.com/quote/4sjGQiAAZhY6jCxr6XcV1QeF/carl-lewis-if-you-dont-have-confidence-youll-always-find-a-way-not-to-win\" rel=\"nofollow noopener noreferrer\">(source)</a>",
"id" : 77380798,
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 36846665,
"message_stars" : 3
} ],
"t" : 77380798,
"d" : 1
}
}{
"r1" : {
"e" : [ {
"event_type" : 19,
"time_stamp" : 1500664511,
"content" : "one",
"id" : 77537961,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38258010,
"moved" : true
}, {
"event_type" : 19,
"time_stamp" : 1500664518,
"content" : "two",
"id" : 77537963,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38258015,
"moved" : true
}, {
"event_type" : 19,
"time_stamp" : 1500664519,
"content" : "three",
"id" : 77537965,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38258017,
"moved" : true
}, {
"event_type" : 1,
"time_stamp" : 1500664587,
"content" : "→ <i><a href=\"http://chat.stackoverflow.com/transcript/message/38258010#38258010\">3 messages</a> moved to <a href=\"http://chat.stackoverflow.com/rooms/48058/trash\">Trash</a></i>",
"id" : 77537967,
"user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox",
"message_id" : 38258054
} ],
"t" : 77537970,
"d" : 10
}
}{
"r1" : {
"e" : [ {
"event_type" : 3,
"time_stamp" : 1500331806,
"id" : 77380786,
"user_id" : 13379,
"target_user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox"
} ],
"t" : 77380786,
"d" : 1
}
}{
"r1" : {
"e" : [ {
"event_type" : 4,
"time_stamp" : 1500331721,
"id" : 77380764,
"user_id" : 13379,
"target_user_id" : 13379,
"user_name" : "Michael",
"room_id" : 1,
"room_name" : "Sandbox"
} ],
"t" : 77380764,
"d" : 11
}
}