Diarkis C# Client SDK
Classes | Public Member Functions | Events | List of all members
Diarkis.P2P Class Reference

Public Member Functions

delegate void ReadyHandler (string addr, int port, double holePunchTimeInMilliseconds)
 
delegate void FailHandler (string addr, int port)
 
delegate void MessageHandler (string addr, int port, byte[] packet)
 
delegate void ExceptionHandler (int errCode, string errMsg)
 
 P2P (Udp udp)
 Creates a P2P peer and communication wit the peer. One P2P instance = One P2P peer. More...
 
void Update ()
 Must be called a certain interval from the main thread. For Unity application this must be called in Update. More...
 
bool IsConnected ()
 Returns true if we are connected (hole punch successfully completed) with the peer. More...
 
void Connect (string addr, int port, ushort timeoutInMilliseconds=10000)
 Starts P2P connection with a peer: When it's successful, it triggers OnReady event and when it fails triggers OnFail event. The peer must be invoking Connect also for this to work as this is a hole punching operation. More...
 
void Connect (string address, ushort timeoutInMilliseconds=10000)
 Starts P2P connection with a peer: When it's successful, it triggers OnReady event and when it fails triggers OnFail event. The peer must be invoking Connect also for this to work as this is a hole punching operation. More...
 
void Disconnect ()
 Stops P2P communication with the peer. More...
 
void Send (byte[] msg)
 Sensd a P2P message to the peer. More...
 

Events

ReadyHandler OnReady
 
FailHandler OnFail
 
MessageHandler OnMessage
 
ExceptionHandler OnException
 

Constructor & Destructor Documentation

◆ P2P()

Diarkis.P2P.P2P ( Udp  udp)
inline

Creates a P2P peer and communication wit the peer. One P2P instance = One P2P peer.

Member Function Documentation

◆ Connect() [1/2]

void Diarkis.P2P.Connect ( string  addr,
int  port,
ushort  timeoutInMilliseconds = 10000 
)
inline

Starts P2P connection with a peer: When it's successful, it triggers OnReady event and when it fails triggers OnFail event. The peer must be invoking Connect also for this to work as this is a hole punching operation.

Parameters
addrAddress of the peer to connect.
portPort of the peer to connect.
timeoutInMillisecondsTimeout in milliseconds. When this time exceeds before successfully completing hole punching with the peer. It will trigger OnFail event. Default is 10000ms.

◆ Connect() [2/2]

void Diarkis.P2P.Connect ( string  address,
ushort  timeoutInMilliseconds = 10000 
)
inline

Starts P2P connection with a peer: When it's successful, it triggers OnReady event and when it fails triggers OnFail event. The peer must be invoking Connect also for this to work as this is a hole punching operation.

Parameters
addressPeer address to start P2P with. The string format is "{address}:{port}".
Parameters
timeoutInMillisecondsTimeout in milliseconds. When this time exceeds before successfully completing hole punching with the peer. It will trigger OnFail event. Default is 10000ms.

◆ Disconnect()

void Diarkis.P2P.Disconnect ( )
inline

Stops P2P communication with the peer.

◆ IsConnected()

bool Diarkis.P2P.IsConnected ( )
inline

Returns true if we are connected (hole punch successfully completed) with the peer.

◆ Send()

void Diarkis.P2P.Send ( byte[]  msg)
inline

Sensd a P2P message to the peer.

Parameters
msgMessage byte array.

◆ Update()

void Diarkis.P2P.Update ( )
inline

Must be called a certain interval from the main thread. For Unity application this must be called in Update.


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