Room class. Should be extended by the actual room implementation.
Note: The room class that extends this one can make a convenience link to the proper game (or slave) server class in its constructor like this:
var server: ServerTest;
public function new(s, t, vid)
{
super(s, t, vid);
server = cast _server;
}
Marks this room as dead when set to true. This should be set to true when the room is no longer needed.
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.
inline broadcast (type:String, msg:Dynamic):Void
Broadcasts the message to all clients in this room.
Parameters:
type
Message type.
msg
Message parameters.
dynamic event (msg:Dynamic):Void
This hook should handle remote room notifications sent with snipe.package.room.SlaveModule.notify()
.
It can also be used to communicate with the room instance locally.
Parameters:
msg
Notification message.
join (c:ClientInfo):Void
Adds this client to room clients and calls joinPost()
callback.
Does not check whether this client is already in another room.
Sets "packages/room.id" and "packages/room.type" client variables.
Parameters:
c
Client to join the room.
leave (c:ClientInfo):Void
Removes this client from a list of clients and calls leavePost()
callback.
Unsets the "packages/room.id" and "packages/room.type" 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.
Parameters:
c
Client to remove from the room.
Replicates updated or full public room state to clients. Public state consists of fields defined in the _RoomType.replicated array.
The message will have a "packages/room.state" type with message fields containing room state fields.
Parameters:
doFull
If set to true, will do full state replication. Optional. If not enabled, will only replicate room fields that were updated. Always clears the list of updated fields.
dynamic tick (timePassed:Float):Void
Room time passage. Called periodically in the main server thread (the exact amount is specified in the room type).
Since the server cannot guarantee that this precise amount of time will pass since the last call, it will pass the time that passed since the last tick finished into the method call.
Parameters:
timePassed
How much time has actually passed since the last tick finished in seconds.
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.