Kit room class.

Constructor

new (s:RoomServerKit, p:ProjectInfoKitRoom, t:_RoomType, vid:Int)

Fields

read only clients:Array<RoomClientKit>

Clients attached to the room.

clientsLength:Int

Current numbers of clients in this room.

read only createTS:Float

Timestamp of room creation.

id:Int

Unique room ID.

read only isDead:Bool

Marks this room as dead when set to true. This should be set to true when the room is no longer needed through the use of kit.room.SlaveModule.remove() API.

Room.tick() stops working and no updates and notifications will be sent to room clients anymore. Keep in mind that Room.leavePost() callback will not be executed for any clients.

read only lastLeaveTS:Float

state:String

Room state. Empty string by default. If the room state does not change in 60 seconds after its creation, the room is destroyed.

stateTS:Float

Timestamp of last state change.

read only typeID:String

Room type string ID.

vars:RoomVariables

Room-wide variables. They are not persistent in persistent rooms.

Methods

inline broadcast (type:String, msg:Dynamic):Void

Broadcasts the message to all clients in this room.

Parameters:

type

Message type.

msg

Message parameters.

inline error (source:String, msg:String):Void

join (c:RoomClientKit):Void

Marks room field as changed. This will put the field in a list of changed fields until the replicate() method is called. Should be called after each state change that will need to be propagated to the clients.

In case when the room is persistent, this will also update the block field which will be saved later.

Parameters:

key

Room instance field name.

kick (clientID:Int):Void

Kicks a client from this room. Room user record will stay intact. First calls leave() then notifies the game server to return the client to default state.

Parameters:

clientID

Client ID.

leave (c:RoomClientKit):Void

Removes this client from a list of clients and calls leavePost() callback.

Unsets the "roomID" and "roomTypeID" client variables.

If one of the clients in the room disconnects, this method will be called automatically.

If the room is dead, leavePost() callback will not be called.

Does not reset client state on game server. Use kick() to do it.

Parameters:

c

Client to remove from the room.

inline log (source:String, msg:String):Void

inline notifyBroadcast (msg:Dynamic):Void

Broadcasts the notification to all clients in this room.

Parameters:

msg

Message parameters.

tick (timePassed:Float):Void