|
|
|
@ -50,7 +50,7 @@ function convertRoomListEntry(name: string, room: any): RoomState { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function handleRoomListResponse(dispatch: AppDispatch, response) { |
|
|
|
function handleRoomListResponse(dispatch: AppDispatch, response): void { |
|
|
|
const { rooms } = response; |
|
|
|
if (rooms === undefined) { |
|
|
|
console.log("RoomListResponse has wrong shape:", response); |
|
|
|
@ -65,7 +65,7 @@ function handleRoomListResponse(dispatch: AppDispatch, response) { |
|
|
|
dispatch(roomSetAll(map)); |
|
|
|
} |
|
|
|
|
|
|
|
function handleRoomMessageResponse(dispatch: AppDispatch, response) { |
|
|
|
function handleRoomMessageResponse(dispatch: AppDispatch, response): void { |
|
|
|
dispatch( |
|
|
|
roomReceiveMessage({ |
|
|
|
roomName: response.room_name, |
|
|
|
@ -75,6 +75,24 @@ function handleRoomMessageResponse(dispatch: AppDispatch, response) { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function handleRoomJoinResponse(dispatch: AppDispatch, response): void { |
|
|
|
dispatch( |
|
|
|
roomSetMembership({ |
|
|
|
roomName: response.room_name, |
|
|
|
membership: RoomMembership.Joined, |
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function handleRoomLeaveResponse(dispatch: AppDispatch, response): void { |
|
|
|
dispatch( |
|
|
|
roomSetMembership({ |
|
|
|
roomName: response.room_name, |
|
|
|
membership: RoomMembership.Left, |
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function roomListRequest(): SocketMessage { |
|
|
|
return "RoomListRequest"; |
|
|
|
} |
|
|
|
@ -116,6 +134,10 @@ export const roomSocketMessageMiddleware: SocketMessageMiddleware = { |
|
|
|
handleRoomListResponse(dispatch, message["RoomListResponse"]); |
|
|
|
} else if ("RoomMessageResponse" in message) { |
|
|
|
handleRoomMessageResponse(dispatch, message["RoomMessageResponse"]); |
|
|
|
} else if ("RoomJoinResponse" in message) { |
|
|
|
handleRoomJoinResponse(dispatch, message["RoomJoinResponse"]); |
|
|
|
} else if ("RoomLeaveResponse" in message) { |
|
|
|
handleRoomLeaveResponse(dispatch, message["RoomLeaveResponse"]); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|