This repository was archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Room
Gentilhomme edited this page Aug 25, 2017
·
4 revisions
uVyper Room. Create a new room where you can manage connection and disconnect like a socket server.
const {Room} = require('uvyper');
const RoomA = new Room('RoomA');
RoomA.on('connection',function(socket) {
console.log(`socket ${socket.id} connected to RoomA!`);
RoomA.deleteSocket(socket);
});
RoomA.on('disconnect',function(socket) {
console.log(`socket ${socket.id} disconnected from RoomA!`);
});| name | type |
|---|---|
| name | String |
| sockets | SocketMap |
| alive | Boolean |
A new socket into the room.
Delete a socket from the room.
Disconnect all sockets connected to the room.
Disconnect all clients and delete the room from the global registery. You should put the room variable to undefined to let the garbage collector destroy the room completely.
const { Server } = require('uvyper');
Server.EventsObserver.on('new_room',function(room) {
console.log(`room ${room.name} has been created!`);
});
Server.EventsObserver.on('delete_room',function(room) {
console.log(`room ${room.name} has been deleted!`);
});
for(let room of Server.EventsObserver.rooms) {
console.log(room.name);
}