Room manager package slave server module.

ALPHA: This module and all underlying classes are currently in alpha.

Include in slave server with:

    loadModules([
      snipe.packages.room.SlaveModule,
      ]);

Cache server configuration variables:

*

Slave server configuration variables:

  • "packages/room.logEnabled" - (0/1) Enables optional package logs. Disabled by default.

Constructor

new (srv:Server)

Methods

create (typeID:String, ?roomID:Int):Room

Creates a new room with a given type and returns it.

Note that you can't use manual and automatic room IDs in your code at the same time for a single room type, the automatic IDs might overlap with manually set ones.

Creating persistent room instances of the same type and with the same ID on different slave server threads will result in an exception.

Parameters:

typeID

Room type ID.

roomID

(optional) Room ID. Will use this specific room ID when creating the room. Will return the existing room instance if the room with this ID exists.

Returns:

Room instance.

get (typeID:String, id:Int):Room

Returns a room with a given type and ID.

Parameters:

typeID

Room type ID.

id

Room ID.

Returns:

Room instance. Null if not found or is already dead.

getClientRoom (c:ClientInfo):Room

Returns a room that this client is in using package client variables.

Parameters:

c

Client instance.

Returns:

Room instance. Null if not found.

inline notify (serverType:String, serverID:Int, typeID:String, roomID:Int, params:Dynamic):Void

Sends the notification to the specific room instance located on another slave server.

All notifications are handled in snipe.packages.room.Room.event().

If the destination room does not exists at this point, it will be created.

Parameters:

serverType

Slave server type.

serverID

Global slave server ID. -1 will pick a random slave server of this type.

typeID

Room type ID.

roomID

Room ID.

params

Message data.

registerType (t:_RoomType):Void

Registers a new room type with the given parameters. Should be called only during the server initialization.

Parameters:

t

Room type description.

remove (typeID:String, id:Int):Void

Removes a room with a given type and ID. If any clients are present in the room, calls leave for each one of them.

If the room is persistent, all persistent fields will be stored into the room block.

Parameters:

typeID

Room type ID.

id

Room ID.