Diarkis C# Client SDK
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Events | List of all members
Diarkis.Modules.Room Class Reference

Room allows clients in the same "room" to exchange packets freely. More...

Inheritance diagram for Diarkis.Modules.Room:
Diarkis.Modules.WsRoom

Classes

class  RoomChatData
 Represents a chat message data with its sender user ID and timestamp in milliseconds. More...
 
class  RoomListItem
 Represents a room data registered by Register. More...
 

Public Member Functions

delegate void CreateHandler (bool success, string roomID, uint roomCreatedTime)
 
delegate void JoinHandler (bool success, uint roomCreatedTime)
 
delegate void LeaveHandler (bool success)
 
delegate void MessageHandler (byte[] message)
 
delegate void UpdatePropsHandler (bool success)
 
delegate void GetPropsHandler (bool success, Dictionary< string, byte[]> props)
 
delegate void GetOwnerIDHandler (bool success, string ownerID)
 
delegate void IncrPropHandler (bool success, long numProp)
 
delegate void GetMemberIDsHandler (bool success, string ownerID, string[] memberIDs)
 
delegate void IncrPropertySyncHandler (long numProp)
 
delegate void GetNumberOfMembersHandler (bool success, string roomID, int number, int maxnumber)
 
delegate void ResponseHandler (bool success, byte[] msg)
 
delegate void FindRoomsHandler (bool success, List< RoomListItem > rooms)
 
delegate void ChatHandler (RoomChatData chatData)
 
delegate void ChatLogHandler (bool success, List< RoomChatData > chatLog, byte[] payload)
 
delegate void P2PSyncHandler (bool success, Packet.P2PClientAddr[] p2pClientAddrs)
 
delegate void ObjUpdateHandler (byte mode, string name, Dictionary< string, double > obj)
 
delegate void ObjSyncHandler (bool success, Dictionary< string, Dictionary< string, double >> objects)
 
delegate void PropertySyncHandler (bool success, Dictionary< string, byte[]> props)
 
bool SetupAsTcp (Tcp tcp)
 Sets up the instance of as a TCP client. More...
 
bool SetupAsUdp (Udp udp)
 Sets up the instance of as a UDP client. More...
 
bool SetTcp (Tcp tcp)
 Changes the TCP instance for the room. More...
 
bool SetUdp (Udp udp)
 Changes the UDP instance for the room. More...
 
virtual void Destroy ()
 Destroy all setup listeners and other internal properties. You will need to call SetupAs... to reuse the instance. More...
 
string GetLastErrorMessage ()
 Returns a last error message of either Create, Join, JoinRandom, Leave etc. More...
 
byte[] GetLastErrorBytes ()
 Returns a last error payload of either Create, Join, JoinRandom, Leave etc. More...
 
bool StartP2PSync (byte linkedClients=0)
 Starts peer-to-peer comminucations with the remote clients in the same room. This method raises OnStartP2PSync event. More...
 
virtual void SyncProperties ()
 Retrieve properties of the room. Raises OnPropertySync. Only properties with byte array value will be synchronized. More...
 
virtual void SyncObjects ()
 Retrieves all room objects with their names and values. OnSyncObjects event will be raised. More...
 
virtual void UpdateObject (byte mode, string name, Dictionary< string, double > obj, bool reliable)
 Manipulates a room object by its name. Successful execution of the operation raises OnObjectUpdate event on all room members including itself. There are 3 modes to manipulate a room object: More...
 
virtual void UpdateProperties (string roomID, Dictionary< string, byte[]> props, bool sync)
 Creates/Replaces room properties by the given property names. The property values are stored as byte array and retrieved as such. This raises OnUpdateProperties event. More...
 
virtual void GetProperties (string roomID, List< string > propNames)
 Gets room properties created/replaced by UpdateProperties method. all property values are retrived as byte array. This raises OnGetProperties event. More...
 
virtual void GetOwnerID ()
 Get the owner user ID of the room. The method raises OnGetOwnerID event. More...
 
virtual void IncrProperty (string propName, long delta, bool sync)
 Increments pre-created long type room property of the matching property name by given delta. More...
 
virtual void GetMemberIDs ()
 Raises OnGetMemberIDs event and retrieves a list of member IDs and the room owner ID. More...
 
virtual void GetNumberOfMembers (string roomID)
 Rasies OnGetNumberOfMembers event and retrieves number of a room. You may retrieve the number of members of a room that you are not part of as well. More...
 
virtual void Create (ushort maxMembers, bool allowEmpty, bool join, ushort ttl, uint interval=0)
 Creates a new room. More...
 
virtual void Join (string roomID, byte[] message)
 Joins a room. A client can NOT join more than one room at a time. More...
 
virtual void Migrate ()
 Migrates a rooom that the user is currently in. This operation can only be performed by the owner of the room. When successful, the owner user raises OnConnect event with reconnect flag true. All members of the room will automatically join the new migrated room without sending join broadcast. More...
 
void Move (string roomID, byte[] leaveMessage, byte[] joinMessage, Action< bool, uint > callback=null)
 Leaves the room that the client is currently in and joins a new room. Raises OnLeave and OnJoin and remotely raises OnMemberLeave and OnMemberJoin. You may callback use the callback instead of listening to the regular events. More...
 
virtual void Register (uint roomType, string roomName, string roomMetadata)
 Registers a room (the client is already a member of) with a type (used by FindRoomsByType). OnRegister event will be raised. More...
 
virtual void FindRoomsByType (uint roomType, uint limit)
 Finds a list of rooms that have been registered with a type. Raises OnFindRoomsByType event. More...
 
virtual void Reserve (List< string > userIDs)
 Reserves the spots for the users in the target room. More...
 
virtual void CancelReservation (List< string > userIDs)
 Cancel the reservations for the users in the target room. More...
 
virtual void CancelReservation (string roomID, List< string > userIDs)
 Cancel the reservations for the users in the target room. More...
 
virtual void JoinRandom (ushort maxMembers, ushort ttl, byte[] message, bool allowEmpty=false, uint interval=200)
 Joins a random room if there is at lease room created by JoinRandom available. If not it will create a new room. If it does not find a room to join, it will instead create a new room. More...
 
virtual void Leave (byte[] message)
 Leaves the room the client has joined. More...
 
virtual void Leave (string roomID, byte[] message)
 Leaves the room the client has joined. More...
 
virtual void Broadcast (byte[] message, bool reliable=true)
 Sends a message to all members of the room including the sender. More...
 
virtual void BroadcastTo (string roomID, byte[] message, bool reliable=true)
 Sends a message to all members of the room including the sender. It will raise OnMemberBroadcast. More...
 
void ExclusiveBroadcastTo (string roomID, byte[] message, bool reliable=true)
 Sends a message to all members of the room including the sender. It will raise OnMemberExclusiveBroadcast. More...
 
void ExclusiveMessageTo (string roomID, List< string > memberIDs, byte[] message, bool reliable=true)
 Sends a message to a selected members of the room. It raises OnMemberMessage. More...
 
virtual void MessageTo (List< string > memberIDs, byte[] message, bool reliable=true)
 Sends a message to a selected members of the room. It raises OnMemberMessage. More...
 
virtual void MessageTo (string roomID, List< string > memberIDs, byte[] message, bool reliable=true)
 Sends a message to a selected members of the room. More...
 
virtual void SendChatMessage (string message)
 Sends a chat message to the members of the room. All chat messages will be stored on the server and can be retrieved by GetChatLog. OnChatSyncResponse will be raised as the response from the server, and OnChatSyncwill be raised on the remote member clients as they receive the chat message. More...
 
virtual void GetChatLog ()
 Retrieves all chat messages as a list. OnChatLog will be raised. More...
 
string GetRoomID ()
 Returns the room ID that the client has joined. More...
 
void SetRoomID (string roomID)
 Sets room ID manually. More...
 
void OnCustomMessagePush (uint ver, uint cmd, Action< byte[]> callback)
 Registers a callback on custom broadcast and/or message by ver and cmd. Must be callback AFTER group.SetupAsUdp or group.SetupAsTcp This is method is NOT compatible with Broadcast. Use with Message and/or Announce ONLY. More...
 

Public Attributes

byte[] _exclusiveHeader = new byte[4]{ 0xc, 0xa, 0xf, 0xe }
 When a message (Broadcast and Message) starts with _exclusiveHeader, OnMemberBroadcast and OnMemberMessage will not raise. More...
 

Static Public Attributes

const byte OBJ_INC_MODE = 0x01
 
const byte OBJ_SET_MODE = 0x02
 
const byte OBJ_DEL_MODE = 0x03
 

Protected Member Functions

virtual void setupOnJoinEvent (uint ver, uint cmd)
 Sets up OnJoin event to ensure OnJoin event is triggered AFTER the reconnection (server to server transter of the client). Use this protected method to implement custom join commands. More...
 
void setRoomID (string roomID)
 Sets _roomID manually. More...
 
void setCreatedTime (uint createdTime)
 Sets _createdTime manually. More...
 

Protected Attributes

string _roomID
 
uint _createdTime = 0
 
string _lastErrMessage = ""
 
byte[] _lastErrBytes = new byte[0]
 

Static Protected Attributes

const uint BUILTIN_CMD_VER = 1
 
const uint CREATE_CMD = 100
 
const uint JOIN_CMD = 101
 
const uint LEAVE_CMD = 102
 
const uint BROADCAST_CMD = 103
 
const uint MESSAGE_CMD = 104
 
const uint UPDATE_PROP_CMD = 107
 
const uint GET_PROP_CMD = 108
 
const uint GET_OWNER_CMD = 109
 
const uint INCR_PROP_CMD = 10
 
const uint GET_MEMBERS_CMD = 11
 
const uint REG_ROOM_CMD = 115
 
const uint FIND_ROOMS_CMD = 116
 
const uint RESERVE_CMD = 117
 
const uint CANCEL_RES_CMD = 118
 
const uint MIGRATE_CMD = 12
 
const uint GET_NUM_OF_MEMBERS_CMD = 13
 
const uint OWNER_CHANGE_CMD = 14
 
const uint CHAT_CMD = 125
 
const uint CHAT_LOG_CMD = 126
 
const uint OBJ_SYNC_CMD = 128
 
const uint OBJ_UPDATE_CMD = 129
 
const uint PROP_SYNC_CMD = 130
 
const uint STATUS_OK = 1
 
const uint RAND_CREATE_CMD = 105
 
const uint RAND_JOIN_CMD = 106
 

Events

virtual CreateHandler OnCreate
 The event raised as a server response of Create. More...
 
virtual JoinHandler OnJoin
 The event raised as a server response of Join. More...
 
virtual LeaveHandler OnLeave
 The event raised as a server response of Leave. More...
 
virtual MessageHandler OnMemberJoin
 The event raised when a remote client joins the room that you are in. More...
 
virtual MessageHandler OnMemberLeave
 The event is raised when a remote member of the room you are in leaves the room. More...
 
virtual MessageHandler OnMemberBroadcast
 The event is raised when a remote member client(s) of the room you are in sends a message via BroadcastTo. More...
 
virtual MessageHandler OnMemberMessage
 The event is raised when a remote member client(s) of the room you are in sends a message via MessageTo. More...
 
virtual UpdatePropsHandler OnUpdateProperties
 The event raised as a server response of UpdateProperties. More...
 
GetPropsHandler OnUpdatePropertySync
 The event raised when properties are updated with sync flag. More...
 
virtual GetPropsHandler OnGetProperties
 The event raised as a server response of GetProperties. More...
 
virtual GetOwnerIDHandler OnGetOwnerID
 The event raised as a server response of GetOwnerID. More...
 
virtual IncrPropHandler OnIncrProperty
 The event raised as a server response of IncrProperty. More...
 
virtual IncrPropertySyncHandler OnIncrPropertySync
 The event raised when a remote member client of the room successfully executes IncrPorperty. More...
 
virtual GetMemberIDsHandler OnGetMemberIDs
 The event raised as a server response of GetMemberIDs. More...
 
virtual ResponseHandler OnRegister
 The event raised as a server response of Register. More...
 
virtual FindRoomsHandler OnFindRoomsByType
 The event raised as a server response of FindRoomByType. More...
 
virtual ResponseHandler OnReserve
 The event raised as a server response of Reserve. More...
 
virtual ResponseHandler OnCancelReservation
 The event raised as a server response of CancelReserve. More...
 
virtual GetNumberOfMembersHandler OnGetNumberOfMembers
 
virtual ResponseHandler OnChatSyncResponse
 Event raised when SendChatMessage is called. More...
 
virtual ChatHandler OnChatSync
 Event raised when a chat message from a remote member is received. More...
 
virtual ChatLogHandler OnChatLog
 Event raised when GetChatLog sends the history log of chat messages. More...
 
virtual P2PSyncHandler OnStartP2PSync
 Event raised when StartP2PSync is successfully invoked. The event callback receives a list of remote clients to start peer-to-peer with. More...
 
virtual ObjUpdateHandler OnObjectUpdate
 Event raised when UpdateObject is used to manipulate a room object. Any member of the room may maniplulate room objects and the event is raised. The event passes down the manipulated room object along with its name and value with mode that was used. There are 3 modes of manipulations: More...
 
virtual PropertySyncHandler OnPropertySync
 Event raised when SyncProperties is used to retrieve existing properties in the room. Only properties with byte array value will be synchronized. More...
 
virtual ObjSyncHandler OnObjectSync
 Event raised when SyncObjects is used as a response from the server. The event returns all room objects with their current values. More...
 
virtual GetOwnerIDHandler OnOwnerChange
 Event raised when a new room owner has been elected by the server. More...
 
virtual MessageHandler OnMemberExclusiveBroadcast
 
virtual MessageHandler OnMemberExclusiveMessage
 

Detailed Description

Room allows clients in the same "room" to exchange packets freely.

Member Function Documentation

◆ Broadcast()

virtual void Diarkis.Modules.Room.Broadcast ( byte[]  message,
bool  reliable = true 
)
inlinevirtual

Sends a message to all members of the room including the sender.

Parameters
messageMessage to be sent.
reliableThis parameter is only relevant for UDP. If true, the message will be delivered as an RUDP message.

◆ BroadcastTo()

virtual void Diarkis.Modules.Room.BroadcastTo ( string  roomID,
byte[]  message,
bool  reliable = true 
)
inlinevirtual

Sends a message to all members of the room including the sender. It will raise OnMemberBroadcast.

Parameters
roomIDRoom ID of the room that the message will be sent to.
messageMessage to be sent.
reliableThis parameter is only relevant for UDP. If true, the message will be delivered as an RUDP message.

Reimplemented in Diarkis.Modules.WsRoom.

◆ CancelReservation() [1/2]

virtual void Diarkis.Modules.Room.CancelReservation ( List< string >  userIDs)
inlinevirtual

Cancel the reservations for the users in the target room.

IMPORTANT: User canceling reservations must be a joined member of the room.

Parameters
userIDsList of user IDs to cancel the reservations in the room.

Reimplemented in Diarkis.Modules.WsRoom.

◆ CancelReservation() [2/2]

virtual void Diarkis.Modules.Room.CancelReservation ( string  roomID,
List< string >  userIDs 
)
inlinevirtual

Cancel the reservations for the users in the target room.

IMPORTANT: User canceling reservations must be a joined member of the room.

Parameters
roomIDRoom ID to remove the reservations from.
userIDsList of user IDs to cancel the reservations in the room.

◆ Create()

virtual void Diarkis.Modules.Room.Create ( ushort  maxMembers,
bool  allowEmpty,
bool  join,
ushort  ttl,
uint  interval = 0 
)
inlinevirtual

Creates a new room.

Parameters
maxMembersMaximum number of clients allowed to join the room.
allowEmptyIf true, the room will not be destroyed immediately when it is empty of clients.
joinIf true, the creator client of the room is automatically added to the room as a member.
ttlTTL of the room when it is empty of members in seconds.
intervalBroadcast push interval in milliseconds. Default is 0ms (Disabled). If 0 is given, broadcast packets will not be merged.

Reimplemented in Diarkis.Modules.WsRoom.

◆ Destroy()

virtual void Diarkis.Modules.Room.Destroy ( )
inlinevirtual

Destroy all setup listeners and other internal properties. You will need to call SetupAs... to reuse the instance.

Reimplemented in Diarkis.Modules.WsRoom.

◆ ExclusiveBroadcastTo()

void Diarkis.Modules.Room.ExclusiveBroadcastTo ( string  roomID,
byte[]  message,
bool  reliable = true 
)
inline

Sends a message to all members of the room including the sender. It will raise OnMemberExclusiveBroadcast.

Parameters
roomIDRoom ID of the room that the message will be sent to.
messageMessage to be sent.
reliableThis parameter is only relevant for UDP. If true, the message will be delivered as an RUDP message.

◆ ExclusiveMessageTo()

void Diarkis.Modules.Room.ExclusiveMessageTo ( string  roomID,
List< string >  memberIDs,
byte[]  message,
bool  reliable = true 
)
inline

Sends a message to a selected members of the room. It raises OnMemberMessage.

Parameters
roomIDRoom ID of the room that the message will be sent to.
memberIDsA list of member IDs to send the message to.
messageMessage to be sent.
reliableThis parameter is only relevant for UDP. If true, the message will be delivered as an RUDP message.

◆ FindRoomsByType()

virtual void Diarkis.Modules.Room.FindRoomsByType ( uint  roomType,
uint  limit 
)
inlinevirtual

Finds a list of rooms that have been registered with a type. Raises OnFindRoomsByType event.

Parameters
roomTypeA room type of find.
limitMaximum number of rooms to find by the given type.

Reimplemented in Diarkis.Modules.WsRoom.

◆ GetChatLog()

virtual void Diarkis.Modules.Room.GetChatLog ( )
inlinevirtual

Retrieves all chat messages as a list. OnChatLog will be raised.

◆ GetLastErrorBytes()

byte [] Diarkis.Modules.Room.GetLastErrorBytes ( )
inline

Returns a last error payload of either Create, Join, JoinRandom, Leave etc.

◆ GetLastErrorMessage()

string Diarkis.Modules.Room.GetLastErrorMessage ( )
inline

Returns a last error message of either Create, Join, JoinRandom, Leave etc.

◆ GetMemberIDs()

virtual void Diarkis.Modules.Room.GetMemberIDs ( )
inlinevirtual

Raises OnGetMemberIDs event and retrieves a list of member IDs and the room owner ID.

Reimplemented in Diarkis.Modules.WsRoom.

◆ GetNumberOfMembers()

virtual void Diarkis.Modules.Room.GetNumberOfMembers ( string  roomID)
inlinevirtual

Rasies OnGetNumberOfMembers event and retrieves number of a room. You may retrieve the number of members of a room that you are not part of as well.

◆ GetOwnerID()

virtual void Diarkis.Modules.Room.GetOwnerID ( )
inlinevirtual

Get the owner user ID of the room. The method raises OnGetOwnerID event.

◆ GetProperties()

virtual void Diarkis.Modules.Room.GetProperties ( string  roomID,
List< string >  propNames 
)
inlinevirtual

Gets room properties created/replaced by UpdateProperties method. all property values are retrived as byte array. This raises OnGetProperties event.

Parameters
roomIDRoom ID of the properties to be retrieved.
propNamesList of property names to be retrieved.

◆ GetRoomID()

string Diarkis.Modules.Room.GetRoomID ( )
inline

Returns the room ID that the client has joined.

◆ IncrProperty()

virtual void Diarkis.Modules.Room.IncrProperty ( string  propName,
long  delta,
bool  sync 
)
inlinevirtual

Increments pre-created long type room property of the matching property name by given delta.

Parameters
propNameProperty name to increment. Property must be a type int64.
deltaIncremenal value. If a negative value is given, it will subtruct instead.
syncIf true, the change will be broadcasted to the other members of the room. This will raise OnIncrPropertySync event.

Reimplemented in Diarkis.Modules.WsRoom.

◆ Join()

virtual void Diarkis.Modules.Room.Join ( string  roomID,
byte[]  message 
)
inlinevirtual

Joins a room. A client can NOT join more than one room at a time.

Parameters
roomIDRoom ID that the client will try to join.
messageMessage that will be sent to the other members of the room when the client joins the room.

Reimplemented in Diarkis.Modules.WsRoom.

◆ JoinRandom()

virtual void Diarkis.Modules.Room.JoinRandom ( ushort  maxMembers,
ushort  ttl,
byte[]  message,
bool  allowEmpty = false,
uint  interval = 200 
)
inlinevirtual

Joins a random room if there is at lease room created by JoinRandom available. If not it will create a new room. If it does not find a room to join, it will instead create a new room.

Parameters
maxMembersMaximum number of clients allowed to join the room.
ttlTTL of the room when it is empty of members in seconds.
messageMessage that will be sent to the other members of the room when the client joins the room.
allowEmptyIf true, the room will not be destroyed immediately when it is empty of clients.
intervalBroadcast push interval in milliseconds. Default is 200ms. If 0 is given, broadcast packets will not be merged.

Reimplemented in Diarkis.Modules.WsRoom.

◆ Leave() [1/2]

virtual void Diarkis.Modules.Room.Leave ( byte[]  message)
inlinevirtual

Leaves the room the client has joined.

Parameters
messageMessage that will be sent to the other members of the room when the client leaves the room.

◆ Leave() [2/2]

virtual void Diarkis.Modules.Room.Leave ( string  roomID,
byte[]  message 
)
inlinevirtual

Leaves the room the client has joined.

Parameters
roomIDRoom ID that the client will try to leave from.
messageMessage that will be sent to the other members of the room when the client leaves the room.

Reimplemented in Diarkis.Modules.WsRoom.

◆ MessageTo() [1/2]

virtual void Diarkis.Modules.Room.MessageTo ( List< string >  memberIDs,
byte[]  message,
bool  reliable = true 
)
inlinevirtual

Sends a message to a selected members of the room. It raises OnMemberMessage.

Parameters
memberIDsA list of member IDs to send the message to.
messageMessage to be sent.
reliableThis parameter is only relevant for UDP. If true, the message will be delivered as an RUDP message.

Reimplemented in Diarkis.Modules.WsRoom.

◆ MessageTo() [2/2]

virtual void Diarkis.Modules.Room.MessageTo ( string  roomID,
List< string >  memberIDs,
byte[]  message,
bool  reliable = true 
)
inlinevirtual

Sends a message to a selected members of the room.

Parameters
roomIDRoom ID of the room that the message will be sent to.
Parameters
memberIDsA list of member IDs to send the message to.
messageMessage to be sent.
reliableThis parameter is only relevant for UDP. If true, the message will be delivered as an RUDP message.

Reimplemented in Diarkis.Modules.WsRoom.

◆ Migrate()

virtual void Diarkis.Modules.Room.Migrate ( )
inlinevirtual

Migrates a rooom that the user is currently in. This operation can only be performed by the owner of the room. When successful, the owner user raises OnConnect event with reconnect flag true. All members of the room will automatically join the new migrated room without sending join broadcast.

Reimplemented in Diarkis.Modules.WsRoom.

◆ Move()

void Diarkis.Modules.Room.Move ( string  roomID,
byte[]  leaveMessage,
byte[]  joinMessage,
Action< bool, uint >  callback = null 
)
inline

Leaves the room that the client is currently in and joins a new room. Raises OnLeave and OnJoin and remotely raises OnMemberLeave and OnMemberJoin. You may callback use the callback instead of listening to the regular events.

Parameters
roomIDA room ID to join
leaveMessageA byte array message to be broadcasted on leave.
Parameters
joinMessageA byte array message to be broadcasted on join.
callbackAn optional callback to be invoked when successfully joined a new room or failed to leave or join.

◆ OnCustomMessagePush()

void Diarkis.Modules.Room.OnCustomMessagePush ( uint  ver,
uint  cmd,
Action< byte[]>  callback 
)
inline

Registers a callback on custom broadcast and/or message by ver and cmd. Must be callback AFTER group.SetupAsUdp or group.SetupAsTcp This is method is NOT compatible with Broadcast. Use with Message and/or Announce ONLY.

◆ Register()

virtual void Diarkis.Modules.Room.Register ( uint  roomType,
string  roomName,
string  roomMetadata 
)
inlinevirtual

Registers a room (the client is already a member of) with a type (used by FindRoomsByType). OnRegister event will be raised.

Parameters
roomTypeRoom type to be used by FindRoomsByType.
roomNameA name of the room registered.
roomMetadataExtra string data for the room registered.

Reimplemented in Diarkis.Modules.WsRoom.

◆ Reserve()

virtual void Diarkis.Modules.Room.Reserve ( List< string >  userIDs)
inlinevirtual

Reserves the spots for the users in the target room.

IMPORTANT: User making reservations must be a joined member of the room.

Parameters
userIDsList of user IDs to reserve the spots in the room.

Reimplemented in Diarkis.Modules.WsRoom.

◆ SendChatMessage()

virtual void Diarkis.Modules.Room.SendChatMessage ( string  message)
inlinevirtual

Sends a chat message to the members of the room. All chat messages will be stored on the server and can be retrieved by GetChatLog. OnChatSyncResponse will be raised as the response from the server, and OnChatSyncwill be raised on the remote member clients as they receive the chat message.

Parameters
messageA UTF8 encoded text message data to be sent as a chat message.

◆ setCreatedTime()

void Diarkis.Modules.Room.setCreatedTime ( uint  createdTime)
inlineprotected

Sets _createdTime manually.

◆ setRoomID()

void Diarkis.Modules.Room.setRoomID ( string  roomID)
inlineprotected

Sets _roomID manually.

◆ SetRoomID()

void Diarkis.Modules.Room.SetRoomID ( string  roomID)
inline

Sets room ID manually.

◆ SetTcp()

bool Diarkis.Modules.Room.SetTcp ( Tcp  tcp)
inline

Changes the TCP instance for the room.

Parameters
tcpThe new TCP instance.

◆ SetUdp()

bool Diarkis.Modules.Room.SetUdp ( Udp  udp)
inline

Changes the UDP instance for the room.

Parameters
udpThe new UDP instance.

◆ SetupAsTcp()

bool Diarkis.Modules.Room.SetupAsTcp ( Tcp  tcp)
inline

Sets up the instance of as a TCP client.

Parameters
tcpAn instance of Tcp

◆ SetupAsUdp()

bool Diarkis.Modules.Room.SetupAsUdp ( Udp  udp)
inline

Sets up the instance of as a UDP client.

Parameters
udpAn instance of Udp

◆ setupOnJoinEvent()

virtual void Diarkis.Modules.Room.setupOnJoinEvent ( uint  ver,
uint  cmd 
)
inlineprotectedvirtual

Sets up OnJoin event to ensure OnJoin event is triggered AFTER the reconnection (server to server transter of the client). Use this protected method to implement custom join commands.

Reimplemented in Diarkis.Modules.WsRoom.

◆ StartP2PSync()

bool Diarkis.Modules.Room.StartP2PSync ( byte  linkedClients = 0)
inline

Starts peer-to-peer comminucations with the remote clients in the same room. This method raises OnStartP2PSync event.

Parameters
linkedClientsNumber of clients to be linked directly via peer-to-peer. Other remote clients in the room will be linked via relay.

◆ SyncObjects()

virtual void Diarkis.Modules.Room.SyncObjects ( )
inlinevirtual

Retrieves all room objects with their names and values. OnSyncObjects event will be raised.

Reimplemented in Diarkis.Modules.WsRoom.

◆ SyncProperties()

virtual void Diarkis.Modules.Room.SyncProperties ( )
inlinevirtual

Retrieve properties of the room. Raises OnPropertySync. Only properties with byte array value will be synchronized.

Reimplemented in Diarkis.Modules.WsRoom.

◆ UpdateObject()

virtual void Diarkis.Modules.Room.UpdateObject ( byte  mode,
string  name,
Dictionary< string, double >  obj,
bool  reliable 
)
inlinevirtual

Manipulates a room object by its name. Successful execution of the operation raises OnObjectUpdate event on all room members including itself. There are 3 modes to manipulate a room object:

  • OBJ_SET_MODE creates or replaces a room object by the given properties.
  • OBJ_INC_MODE increments an existing room object's properties.
  • OBJ_DEL_MODE deletes a room object by its name.
Parameters
modeDecides which mode of manipluation to execute.
  • OBJ_SET_MODE creates or replaces a room object by the given properties.
  • OBJ_INC_MODE increments an existing room object's properties.
  • OBJ_DEL_MODE deletes a room object by its name.
nameName of the object.
objThe object is represented as a dictionary and its keys and values represent the properties of the object.
// Object property as a dictionary
obj["x"] = 123.4;
obj["y"] = 567.8;
obj["hp"] = 300;
OBJ_DEL_MODE does not use this parameter because it deletes the target room object.
reliableFlag to decided if the operation command packet will be RUDP or UDP. True will sewnd the packet as an RUDP packet. [IMPORTANT] This is only applicable with UDP client.

Reimplemented in Diarkis.Modules.WsRoom.

◆ UpdateProperties()

virtual void Diarkis.Modules.Room.UpdateProperties ( string  roomID,
Dictionary< string, byte[]>  props,
bool  sync 
)
inlinevirtual

Creates/Replaces room properties by the given property names. The property values are stored as byte array and retrieved as such. This raises OnUpdateProperties event.

Parameters
roomIDRoom ID of create/replace its properties.
propsDictionary of room properties to be created/replaced.
syncIf true, the updated properties will be synchronized by raising OnUpdatePropertySync event.

Reimplemented in Diarkis.Modules.WsRoom.

Member Data Documentation

◆ _exclusiveHeader

byte [] Diarkis.Modules.Room._exclusiveHeader = new byte[4]{ 0xc, 0xa, 0xf, 0xe }

When a message (Broadcast and Message) starts with _exclusiveHeader, OnMemberBroadcast and OnMemberMessage will not raise.

Event Documentation

◆ OnCancelReservation

virtual ResponseHandler Diarkis.Modules.Room.OnCancelReservation

The event raised as a server response of CancelReserve.

Parameters
successIndicates if the operation on the server was success or failure.
msgError message byte array if success was false.

◆ OnChatLog

virtual ChatLogHandler Diarkis.Modules.Room.OnChatLog

Event raised when GetChatLog sends the history log of chat messages.

◆ OnChatSync

virtual ChatHandler Diarkis.Modules.Room.OnChatSync

Event raised when a chat message from a remote member is received.

◆ OnChatSyncResponse

virtual ResponseHandler Diarkis.Modules.Room.OnChatSyncResponse

Event raised when SendChatMessage is called.

◆ OnCreate

virtual CreateHandler Diarkis.Modules.Room.OnCreate

The event raised as a server response of Create.

Parameters
successIndicates if the operation on the server was success or failure.
roomCreatedTimePrepresents the server time of room creation in seconds.

◆ OnFindRoomsByType

virtual FindRoomsHandler Diarkis.Modules.Room.OnFindRoomsByType

The event raised as a server response of FindRoomByType.

Parameters
successIndicates if the operation on the server was success or failure.
roomsA list of rooms found.

◆ OnGetMemberIDs

virtual GetMemberIDsHandler Diarkis.Modules.Room.OnGetMemberIDs

The event raised as a server response of GetMemberIDs.

Parameters
successIndicates if the operation on the server was success or failure.
ownerIDThe room owner ID.
memberIDsAn array of member IDs.

◆ OnGetNumberOfMembers

virtual GetNumberOfMembersHandler Diarkis.Modules.Room.OnGetNumberOfMembers
Parameters
successIndicates if the operation on the server was success or failure.
roomIDThe room ID.
numberNumber of current members.
maxnumberMaximum number of members allowed.

◆ OnGetOwnerID

virtual GetOwnerIDHandler Diarkis.Modules.Room.OnGetOwnerID

The event raised as a server response of GetOwnerID.

Parameters
successIndicates if the operation on the server was success or failure.
ownerIDThe owner ID of the room that you are in.

◆ OnGetProperties

virtual GetPropsHandler Diarkis.Modules.Room.OnGetProperties

The event raised as a server response of GetProperties.

Parameters
successIndicates if the operation on the server was success or failure.
propsA dictionary that contains all requested room properties..

◆ OnIncrProperty

virtual IncrPropHandler Diarkis.Modules.Room.OnIncrProperty

The event raised as a server response of IncrProperty.

Parameters
successIndicates if the operation on the server was success or failure.
numPropUpdated property value.

◆ OnIncrPropertySync

virtual IncrPropertySyncHandler Diarkis.Modules.Room.OnIncrPropertySync

The event raised when a remote member client of the room successfully executes IncrPorperty.

Parameters
numPropUpdated property value.

◆ OnJoin

virtual JoinHandler Diarkis.Modules.Room.OnJoin

The event raised as a server response of Join.

`

Parameters
successIndicates if the operation on the server was success or failure.
roomCreatedTimePrepresents the server time of room creation in seconds.

◆ OnLeave

virtual LeaveHandler Diarkis.Modules.Room.OnLeave

The event raised as a server response of Leave.

Parameters
successIndicates if the operation on the server was success or failure.

◆ OnMemberBroadcast

virtual MessageHandler Diarkis.Modules.Room.OnMemberBroadcast

The event is raised when a remote member client(s) of the room you are in sends a message via BroadcastTo.

Parameters
messageA byte array message from a remote member client.

◆ OnMemberJoin

virtual MessageHandler Diarkis.Modules.Room.OnMemberJoin

The event raised when a remote client joins the room that you are in.

Parameters
messageA message from the newly join remote client as a byte array. The message is the same message byte array sent from Join.

◆ OnMemberLeave

virtual MessageHandler Diarkis.Modules.Room.OnMemberLeave

The event is raised when a remote member of the room you are in leaves the room.

Parameters
messageA message from the member client that has just left the room you are in. The message is the same message byte array sent from Leave.

◆ OnMemberMessage

virtual MessageHandler Diarkis.Modules.Room.OnMemberMessage

The event is raised when a remote member client(s) of the room you are in sends a message via MessageTo.

Parameters
messageA byte array message from a remote member client.

◆ OnObjectSync

virtual ObjSyncHandler Diarkis.Modules.Room.OnObjectSync

Event raised when SyncObjects is used as a response from the server. The event returns all room objects with their current values.

// Synchronized room objects example:
objects["Table"]["x"] = 1234.5;
objects["Table"]["y"] = 67.8;
objects["Table"]["width"] = 400;
objects["Table"]["height"] = 100;
objects["AngryCat"]["x"] = 1400.2;
objects["AngryCat"]["y"] = 80.3;
objects["AngryCat"]["width"] = 13;
objects["AngryCat"]["height"] = 9;
objects["AngryCat"]["hp"] = 2048;

◆ OnObjectUpdate

virtual ObjUpdateHandler Diarkis.Modules.Room.OnObjectUpdate

Event raised when UpdateObject is used to manipulate a room object. Any member of the room may maniplulate room objects and the event is raised. The event passes down the manipulated room object along with its name and value with mode that was used. There are 3 modes of manipulations:

  • OBJ_SET_MODE creates or replaces a room object by the given name and value.
  • OBJ_INC_MODE increments an existing room object's value by its name.
  • OBJ_DEL_MODE deletes a room object by its name.

◆ OnOwnerChange

virtual GetOwnerIDHandler Diarkis.Modules.Room.OnOwnerChange

Event raised when a new room owner has been elected by the server.

◆ OnPropertySync

virtual PropertySyncHandler Diarkis.Modules.Room.OnPropertySync

Event raised when SyncProperties is used to retrieve existing properties in the room. Only properties with byte array value will be synchronized.

◆ OnRegister

virtual ResponseHandler Diarkis.Modules.Room.OnRegister

The event raised as a server response of Register.

Parameters
successIndicates if the operation on the server was success or failure.
msgError message byte array if success was false.

◆ OnReserve

virtual ResponseHandler Diarkis.Modules.Room.OnReserve

The event raised as a server response of Reserve.

Parameters
successIndicates if the operation on the server was success or failure.
msgError message byte array if success was false.

◆ OnStartP2PSync

virtual P2PSyncHandler Diarkis.Modules.Room.OnStartP2PSync

Event raised when StartP2PSync is successfully invoked. The event callback receives a list of remote clients to start peer-to-peer with.

◆ OnUpdateProperties

virtual UpdatePropsHandler Diarkis.Modules.Room.OnUpdateProperties

The event raised as a server response of UpdateProperties.

Parameters
successIndicates if the operation on the server was success or failure.
propsThe dictionary that contains update properties.

◆ OnUpdatePropertySync

GetPropsHandler Diarkis.Modules.Room.OnUpdatePropertySync

The event raised when properties are updated with sync flag.


The documentation for this class was generated from the following file: