Class Handler
Satellite implementation of the handler. It defines methods only available from the satellite. A game on the rmb must at least implement the Satellite handler.
Namespace: rmb.satellite
Assembly: rmb.satellite.dll
Syntax
public class Handler : Handler
Methods
Create(log4net.ILog, String[], SatelliteHandler)
Handler factory method. Call this method in the main function of the satellite executable. This is the only way to create an object of type rmb.Satellite.Handler.
Declaration
public static Handler Create(log4net.ILog log, string[] args, SatelliteHandler msHandler)
Parameters
Type | Name | Description |
---|---|---|
log4net.ILog | log | The log object created using the initLogging method from the util namespace. |
System.String[] | args | Command line parameters received from the main function of the satellite's executable. Those should be passed as is, they come directly from the rmb with all the relevant info required to run. Expects Expects Expects |
SatelliteHandler | msHandler | Your implementation of the SatelliteHandler interface, implementing all the necessary methods. |
Returns
Type | Description |
---|---|
Handler | An instance of this class. |
Examples
Here's an example of how to create an instance of this class. the log object is created with the type of your game code.
static void Main(string[] args){Util.InitLogging();Util.SetDefaultLogging(typeof(Showdown));Util.log.Info("Args = " + (args != null ? string.Join(',', args) : null));var game = new Showdown();game.handler = rmb.satellite.Handler.Create(Util.log, args, game);while(game.handler != null){game.handler.Update();}Util.log.Info("Satellite showdown done.");}
As you can see the main method very simple and straightforward. All the hard word is done in the methods implementing SatelliteHandler
PlayerScored(String, Int32, String, String, BucketMode)
This method submits the player's score in the passed bucket's name of empty for the default score bucket.
This method renders the current cache invalid and a call to UpdateBucketCache(String) once scores have been submitted and you would like to send the scores to players.
Declaration
public bool PlayerScored(string playerID, int score, string jsonEncodedActions, string bucketName = "", BucketMode mode = default(BucketMode))
Parameters
Type | Name | Description |
---|---|---|
System.String | playerID | The player's ID |
System.Int32 | score | The value of the score earned by the player |
System.String | jsonEncodedActions | JSON formatted custom actions info that led the players to score. |
System.String | bucketName | The bucket's name or empty for the default score bucket. |
BucketMode | mode | The storing BucketMode: Adding or setting. |
Returns
Type | Description |
---|---|
System.Boolean | false if an error occured, otherwise true is returned |
RequestAllPlayers()
Send a request to the RMB for the IDs of all players belonging this satellite instance. The list will be return via the rmb.shared.SatelliteHandler.OnAllPlayersReceived(IList{`0}) method of the SatelliteHandler's interface
Declaration
public bool RequestAllPlayers()
Returns
Type | Description |
---|---|
System.Boolean | false if an error occured, otherwise true is returned |
SendRankAndScoreToPlayer(String, String)
Ask the RMB to send the player his/her score in the given bucket. The empty bucket is the default score bucket.
You should call UpdateBucketCache(String) for the used bucketName to update the cache if you have submitted new score since the last call of UpdateBucketCache(String)
Declaration
public bool SendRankAndScoreToPlayer(string playerID, string bucketName = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | playerID | The player's ID |
System.String | bucketName | The bucket's name or omit to send the default score. |
Returns
Type | Description |
---|---|
System.Boolean | false if an error occured, otherwise true is returned |
SendToController(Byte[], String)
Send the payload to a concrete player's controller indentified by a playerID.
this method and SendToPlayer(Byte[], String) use different message code. Controller is ready when a concrete game is on. So you should send to the controller unless you want to send a general purpose messages to the player not related to the current game.
Declaration
public bool SendToController(byte[] payload, string playerID)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | payload | The payload to be sent |
System.String | playerID | The targeted player's ID |
Returns
Type | Description |
---|---|
System.Boolean |
SendToControllers(Byte[], IList<String>)
Send the payload to concrete players controllers indentified by playerIDs.
This method behaves exactly like SendToController(Byte[], String) for a list or playerIDs.
Declaration
public bool SendToControllers(byte[] payload, IList<string> targets)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | payload | The payload to be sent |
IList<System.String> | targets |
Returns
Type | Description |
---|---|
System.Boolean | false if an error occured, otherwise true is returned |
SendToMothership(Byte[])
Declaration
public bool SendToMothership(byte[] payload)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | payload |
Returns
Type | Description |
---|---|
System.Boolean |
SendToPlayer(Byte[], String)
Send the payload to a concrete player indentified by a playerID.
Declaration
public bool SendToPlayer(byte[] payload, string playerID)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | payload | The payload to be sent |
System.String | playerID | The targeted player's ID |
Returns
Type | Description |
---|---|
System.Boolean |
SendToPlayers(Byte[], IList<String>)
Send the payload to a concrete list of players indentified by their playerIDs.
This method behaves exactly like SendToPlayer(Byte[], String) for a list or playerIDs.
Declaration
public bool SendToPlayers(byte[] payload, IList<string> targets)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | payload | The payload to be sent |
IList<System.String> | targets | The targeted players' IDs |
Returns
Type | Description |
---|---|
System.Boolean | false if an error occured, otherwise true is returned |
UpdateBucketCache(String)
Ask the RMB to send updated scores and ranks for all players belonging to this satellite.
You should call this method if you need to send scores to the players. The bing screen doesn't use this at all and is only relevant to the players using this satellite.
Declaration
public bool UpdateBucketCache(string bucketName = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | bucketName | The bucket's name or empty for the default score bucket. |
Returns
Type | Description |
---|---|
System.Boolean |