-
Notifications
You must be signed in to change notification settings - Fork 0
Chat
黃健旻 edited this page Jan 31, 2019
·
6 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
}var socket = io.connect('http://localhost:9092');- send
socket.emit('Bind', JSON.stringify({"account": "Vincent"}), function (acknowledgement) { ... });- send
socket.emit('Broadcast', JSON.stringify({"title": "test", "content": "test 123 broadcast"}), function (acknowledgement) { ... });- listen
socket.on('Broadcast', function (msg: BroadcastMsg) {
...
});- send
socket.emit('Chat', JSON.stringify({"to": "Vincent", "content": "test 123 to Vincent"}), function (acknowledgement) { ... });- listen
socket.on('Chat', function (msg: ChatMsg) {
...
});- send
socket.emit('Game', JSON.stringify({"roomId": roomId, "name": "RoomChat", "content": "I'm Human"}), function (acknowledgement) { ... });- listen
socket.on('Room', function (msg: ProtocolMsg)) {
...
});- send
socket.emit('Game', JSON.stringify({"roomId": roomId, "name": "WooChat", "content": "I'm werewolf"}), function (acknowledgement) { ... });- listen
socket.on('Woo', function (msg: ProtocolMsg) {
...
});Copyright (c) 2019 CommonMarvel