강동현

createRoom 메세지 구현

......@@ -29,6 +29,12 @@ export class ServerInboundMessageRecordMap {
result: Array(RoomDescriptionRecord),
});
// 방을 만듭니다.
createRoom = Record({
name: String,
result: RoomInfoRecord,
});
// 방에 접속합니다.
joinRoom = Record({
uuid: String,
......
......@@ -20,6 +20,16 @@ export class User {
roomList: (user, message) => {
return { ok: true, result: connection.roomManager.list() };
},
createRoom: (user, message) => {
if (user.room) {
return { ok: false };
}
if (message.name.length >= 30 || message.name.trim().length === 0) {
return { ok: false };
}
const room = connection.roomManager.create(message.name, 8, user);
return { ok: true, result: room.getInfo() };
},
joinRoom: (user, message) => {
const room = connection.roomManager.get(message.uuid);
if (user.room || !room) {
......