Diarkis C# Client SDK
Public Member Functions | Events | List of all members
Diarkis.Modules.WsGroup Class Reference
Inheritance diagram for Diarkis.Modules.WsGroup:
Diarkis.Modules.Group

Public Member Functions

bool Setup (Ws ws)
 Sets up the instance of as a Ws client. More...
 
override void Destroy ()
 Destroy all setup listeners and other internal properties. You will need to call SetupAs... to reuse the instance. More...
 
override void Create (bool allowEmpty, bool join, ushort ttl)
 Creates a new group. More...
 
override void Join (string groupID, byte[] message)
 Joins a group. A client can join multiple groups at a time. More...
 
override void JoinRandom (ushort ttl, byte[] message, bool allowEmpty=false, uint interval=200)
 Joins a random group if there is at least a group created by JoinRandom available. If not it will create a new group. If it does not find a group to join, it will instead create a new group. The group will be available for 60 seconds for random join. More...
 
override void Leave (string groupID, byte[] message)
 Leaves the group the client has joined. More...
 
override void BroadcastTo (string groupID, byte[] message, bool reliable=true)
 Sends a message to all members of the group. More...
 
- Public Member Functions inherited from Diarkis.Modules.Group
delegate void CreateHandler (bool success, string groupID, byte[] payload)
 
delegate void ResponseHandler (bool success, string groupID, byte[] payload)
 
delegate void MessageHandler (byte[] message)
 
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 SetUdp (Tcp tcp)
 Changes the TCP instance for the group. More...
 
bool SetUdp (Udp udp)
 Changes the UDP instance for the group. More...
 
string GetLastErrorMessage ()
 Returns a last error message of either Create, Join, JoinRandom, Leave etc. More...
 
byte[] GetLastErrorBytes ()
 Returns a last error message bytes of either Create, Join, JoinRandom, Leave etc. More...
 
List< string > GetGroupIDs ()
 Rerturns the list of group IDs that the client has joined. The returned list is a reference, please becareful with it. More...
 
void OnCustomBroadcast (uint ver, uint cmd, Action< byte[]> callback)
 Registers a callback on custom broadcast by ver and cmd More...
 

Events

override CreateHandler OnCreate
 
override ResponseHandler OnJoin
 
override ResponseHandler OnLeave
 
override MessageHandler OnMemberJoin
 
override MessageHandler OnMemberLeave
 
override MessageHandler OnMemberBroadcast
 
- Events inherited from Diarkis.Modules.Group
virtual CreateHandler OnCreate
 The event raised as a server response of Create. More...
 
virtual ResponseHandler OnJoin
 The event raised as a server response of Join. More...
 
virtual ResponseHandler OnLeave
 The event raised as a server response of Leave. More...
 
virtual MessageHandler OnMemberJoin
 The event is raised when a remote client joins the group. More...
 
virtual MessageHandler OnMemberLeave
 The event is raised when a remote client leaves the group. More...
 
virtual MessageHandler OnMemberBroadcast
 The event raised when a remote client sends a broadcast message via BroadcastTo. More...
 

Additional Inherited Members

- Protected Attributes inherited from Diarkis.Modules.Group
List< string > _groupIDs
 
string _lastErrMessage = ""
 
- Static Protected Attributes inherited from Diarkis.Modules.Group
const uint BUILTIN_CMD_VER = 1
 
const uint CREATE_CMD = 110
 
const uint JOIN_CMD = 111
 
const uint LEAVE_CMD = 112
 
const uint BROADCAST_CMD = 113
 
const uint STATUS_OK = 1
 
const uint RAND_JOIN_CMD = 114
 

Member Function Documentation

◆ BroadcastTo()

override void Diarkis.Modules.WsGroup.BroadcastTo ( string  groupID,
byte[]  message,
bool  reliable = true 
)
inlinevirtual

Sends a message to all members of the group.

Parameters
groupIDGroup ID of the group 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 from Diarkis.Modules.Group.

◆ Create()

override void Diarkis.Modules.WsGroup.Create ( bool  allowEmpty,
bool  join,
ushort  ttl 
)
inlinevirtual

Creates a new group.

Parameters
allowEmptyIf true, the group will not be destroyed immediately when it is empty of clients.
joinIf true, the creator client of the group is automatically added to the group as a member.
ttlTTL of the group when it is empty of members in seconds.

Reimplemented from Diarkis.Modules.Group.

◆ Destroy()

override void Diarkis.Modules.WsGroup.Destroy ( )
inlinevirtual

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

Reimplemented from Diarkis.Modules.Group.

◆ Join()

override void Diarkis.Modules.WsGroup.Join ( string  groupID,
byte[]  message 
)
inlinevirtual

Joins a group. A client can join multiple groups at a time.

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

Reimplemented from Diarkis.Modules.Group.

◆ JoinRandom()

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

Joins a random group if there is at least a group created by JoinRandom available. If not it will create a new group. If it does not find a group to join, it will instead create a new group. The group will be available for 60 seconds for random join.

Parameters
ttlTTL of the group when it is empty of members in seconds.
messageMessage that will be sent to the other members of the group when the client joins the group.
intervalBroadcast push interval in milliseconds. Default is 200ms. If 0 is given, broadcast packets will not be merged.

Reimplemented from Diarkis.Modules.Group.

◆ Leave()

override void Diarkis.Modules.WsGroup.Leave ( string  groupID,
byte[]  message 
)
inlinevirtual

Leaves the group the client has joined.

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

Reimplemented from Diarkis.Modules.Group.

◆ Setup()

bool Diarkis.Modules.WsGroup.Setup ( Ws  ws)
inline

Sets up the instance of as a Ws client.

Parameters
wsAn instance of Ws

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