Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis
Created August 9, 2017 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdyrrahitis/893e48f0ad81c991f6578357c17564cb to your computer and use it in GitHub Desktop.
Save gdyrrahitis/893e48f0ad81c991f6578357c17564cb to your computer and use it in GitHub Desktop.
Events emitted
{ // In createRoom method (line 29-55)
// Events are emitted in this order
this.emitLoggedUsersToRoom(socket, room);
callback({ access: true, roomId: room.id });
this.emitRoomsAllEventWithTotalRooms();
this.emitUsersAllEventWithTotalUsersInAllRooms();
}
// method declarations...
private emitLoggedUsersToRoom(socket: ISocket, room: Room) {
let roomShowAllEvent = new RoomShowAllEvent(room.users);
socket.server.to(room.id).emit(RoomShowAllEvent.eventName, roomShowAllEvent.users);
}
private emitRoomsAllEventWithTotalRooms() {
this.io.emit(RoomsAllEvent.eventName, this.rooms.length);
}
private emitUsersAllEventWithTotalUsersInAllRooms() {
this.io.emit(UsersAllEvent.eventName, this.rooms.length ? this.getAllUsersFromAllRooms() : 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment