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 | SocketsPool |
| _alive | Boolean |
Add new socket into the room.
Delete a socket from the room.
Disconnect all sockets connected to the Room.
Destroy the whole room (the method will call disconnectAll() method and put alive property to false).
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);
}