Class Handler
Handler is the main driver for your game, it will translate data from the wire as necessary and relay clean data to your game thru either of the mothership or satellite interface
Namespace: rmb.shared
Assembly: rmb.shared.dll
Syntax
public abstract class Handler : BusClientHandler
Constructors
Handler(ILog, String, String)
Protected constructor called by Satellite and Mothership handlers.
Declaration
protected Handler(ILog log, string gameName, string key)
Parameters
| Type | Name | Description |
|---|---|---|
| ILog | log | The log object used to output log messages |
| System.String | gameName | The name used for the current game |
| System.String | key | The unique identifier of this process received from the RMB. It is used for the handshake between this actor and the RMB. |
Fields
bus
Declaration
protected BusClient.BusClient bus
Field Value
| Type | Description |
|---|---|
| BusClient.BusClient |
Properties
CustomTarget
The saved custom target value received with the OnStart call. Use this property to refer to the value through the game life cycle.
Declaration
public byte CustomTarget { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Key
The Key proprerty is used to uniquely identify this instance of your game. This ensure that it cannot be any confusion with any other instance of this code running by mistake.
Declaration
public string Key { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Log
The main log object.
Declaration
public ILog Log { get; set; }
Property Value
| Type | Description |
|---|---|
| ILog |
MainHandler
This is the interface used to get the data to your game. It is either a satellite or mothership implementation.
Declaration
public BaseHandler MainHandler { get; set; }
Property Value
| Type | Description |
|---|---|
| BaseHandler |
Name
The name of your game. It should match the one added in the RMB configuration file.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Players
Saved list of players before calling satellite's on AllPlayers Received. Always empty for the mothership.
Declaration
public List<string> Players { get; set; }
Property Value
| Type | Description |
|---|---|
| List<System.String> |
Methods
CheckActive(String)
Internal use.
Declaration
protected bool CheckActive(string failedMsg)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | failedMsg | The message displayed in the case of a negative outcome. |
Returns
| Type | Description |
|---|---|
| System.Boolean | false if the current connection is not active. |
Connect(String, BaseHandler)
Reserved. It could be used for some custom behavior.
Declaration
protected bool Connect(string url, BaseHandler handler)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The connection url |
| BaseHandler | handler | The main object used to work with the connection. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Connected(RoomBusConnection, Int32)
Called when connected to the rmb.
Declaration
public void Connected(RoomBusConnection conn, int peerID)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | The connection object that was just connected |
| System.Int32 | peerID | The connection's unique identifier |
Disconnected(RoomBusConnection)
Call when the connection is lost with the rmb. The actors library is designed to be hosted on the same machine as the rmb, this method will only be called if the RMB cashes.
Declaration
public bool Disconnected(RoomBusConnection conn)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | The connection object that was just disconnected |
Returns
| Type | Description |
|---|---|
| System.Boolean | true |
IDAndBucketBytes(String, String)
Internal use.
Declaration
protected byte[] IDAndBucketBytes(string ID, string bucket = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | ID | generic identifier |
| System.String | bucket | The bucket's name |
Returns
| Type | Description |
|---|---|
| System.Byte[] | The bytes array containing the packed ID and bucket's name |
OnChatMessages(RoomBusConnection, Byte[][])
Driver's stud method. never called.
Declaration
public void OnChatMessages(RoomBusConnection conn, byte[][] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | main connection object |
| System.Byte[][] | bytes | chat message bytes |
OnCustomTargetSet(RoomBusConnection, Byte, String)
Called to link the custom target byte value with the current game.
Declaration
public void OnCustomTargetSet(RoomBusConnection conn, byte peerType, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | The connection that is delivering the data |
| System.Byte | peerType | The custom target value used as a peer type to route data to your game. |
| System.String | name |
OnData(RoomBusConnection, Byte[])
Processed the received data and call the appropriate methods.
Declaration
public bool OnData(RoomBusConnection conn, byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | The connection object that is delivering the data |
| System.Byte[] | bytes | The payload in bytes |
Returns
| Type | Description |
|---|---|
| System.Boolean | false if an error occured, otherwise true is returned |
OnError(Error, Exception, String)
Driver's stud method. never called.
Declaration
public void OnError(Error error, Exception ex, string msg)
Parameters
| Type | Name | Description |
|---|---|---|
| Error | error | custom error object |
| Exception | ex | passed exception |
| System.String | msg | text used to build the exception about to be thrown. |
OnLatestScores(RoomBusConnection, Int32, Object[][])
Driver's stud method. never called.
Declaration
public bool OnLatestScores(RoomBusConnection conn, int limit, object[][] players)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | |
| System.Int32 | limit | |
| System.Object[][] | players |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnPlayerReject(RejectReason)
Driver's stud method. never called.
Declaration
public void OnPlayerReject(RejectReason reason)
Parameters
| Type | Name | Description |
|---|---|---|
| RejectReason | reason | The rejection's reason |
OnPlayersReady(RoomBusConnection, Byte[][])
Driver's stud method. never called.
Declaration
public void OnPlayersReady(RoomBusConnection conn, byte[][] infoJsons)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | main network connection |
| System.Byte[][] | infoJsons | players data |
OnSession(String)
Driver's stud method. never called.
Declaration
public void OnSession(string session)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | session | current session ID |
OnTopPlayers(RoomBusConnection, Int32, Object[][])
Driver's stud method. never called.
Declaration
public bool OnTopPlayers(RoomBusConnection conn, int limit, object[][] players)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomBusConnection | conn | network TCP connection |
| System.Int32 | limit | N/A |
| System.Object[][] | players | N/A |
Returns
| Type | Description |
|---|---|
| System.Boolean | throws an exception instead |
SendIntra(Byte[], IntraKey)
Internal use.
Declaration
protected bool SendIntra(byte[] payload, IntraKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | payload | The message's payload |
| IntraKey | key | The message's key |
Returns
| Type | Description |
|---|---|
| System.Boolean | false if an error occurs |
Update()
basic update method, used to read and write data from and to the wire.
Declaration
public virtual void Update()