Skip to content
黃健旻 edited this page Jan 31, 2019 · 2 revisions
class BroadcastMsg {
     title: String,
     content: String,
}
class ChatMsg {
     from: String,
     to: String,
     content: String,
}
class RoomIdName {
     id: String,
     name: String,
}
class MemberInfo {
     account: String,
     character: String,
     status: String,
}
class Protocol {
     roomId: String,
     name: String,
     type: String,
     rooms: List<RoomIdName>,
     membersInfo: List<MemberInfo>,
     killWho: String,
     beatWho: String,
     from: String,
     msg: String,
     isPublic: Boolean
}

Create

  • send
socket.emit('Game', JSON.stringify({"type": "CreateRoom", "name": "Room 123", "isPublic": true}), function (acknowledgement) { ... });
  • listen
socket.on('Game', function (msg: ProtocolMsg) {
    ...
});

List

  • send
socket.emit('Game', JSON.stringify({"type": "ListRooms"}), function (acknowledgement) { ... });
  • listen
socket.on('Game', function (msg: ProtocolMsg) {
    ...
});

Join

  • send
socket.emit('Game', JSON.stringify({"roomId":"RFCVG-FGBJM-VGHBJM-SRTGBI", "type": "Join"}), function (acknowledgement) { ... });
  • listen
socket.on('Game', function (msg: ProtocolMsg) {
    ...
});

Leave

  • send
socket.emit('Game', JSON.stringify({"roomId":"RFCVG-FGBJM-VGHBJM-SRTGBI", "type": "LeaveRoom"}), function (acknowledgement) { ... });
  • listen
socket.on('Game', function (msg: ProtocolMsg) {
    ...
});
Clone this wiki locally