Showing
2 changed files
with
16 additions
and
0 deletions
| ... | @@ -29,6 +29,12 @@ export class ServerInboundMessageRecordMap { | ... | @@ -29,6 +29,12 @@ export class ServerInboundMessageRecordMap { |
| 29 | result: Array(RoomDescriptionRecord), | 29 | result: Array(RoomDescriptionRecord), |
| 30 | }); | 30 | }); |
| 31 | 31 | ||
| 32 | + // 방을 만듭니다. | ||
| 33 | + createRoom = Record({ | ||
| 34 | + name: String, | ||
| 35 | + result: RoomInfoRecord, | ||
| 36 | + }); | ||
| 37 | + | ||
| 32 | // 방에 접속합니다. | 38 | // 방에 접속합니다. |
| 33 | joinRoom = Record({ | 39 | joinRoom = Record({ |
| 34 | uuid: String, | 40 | uuid: String, | ... | ... |
| ... | @@ -20,6 +20,16 @@ export class User { | ... | @@ -20,6 +20,16 @@ export class User { |
| 20 | roomList: (user, message) => { | 20 | roomList: (user, message) => { |
| 21 | return { ok: true, result: connection.roomManager.list() }; | 21 | return { ok: true, result: connection.roomManager.list() }; |
| 22 | }, | 22 | }, |
| 23 | + createRoom: (user, message) => { | ||
| 24 | + if (user.room) { | ||
| 25 | + return { ok: false }; | ||
| 26 | + } | ||
| 27 | + if (message.name.length >= 30 || message.name.trim().length === 0) { | ||
| 28 | + return { ok: false }; | ||
| 29 | + } | ||
| 30 | + const room = connection.roomManager.create(message.name, 8, user); | ||
| 31 | + return { ok: true, result: room.getInfo() }; | ||
| 32 | + }, | ||
| 23 | joinRoom: (user, message) => { | 33 | joinRoom: (user, message) => { |
| 24 | const room = connection.roomManager.get(message.uuid); | 34 | const room = connection.roomManager.get(message.uuid); |
| 25 | if (user.room || !room) { | 35 | if (user.room || !room) { | ... | ... |
-
Please register or login to post a comment