Peer-to-Peer client that uses Diarksi Udp class instance internally. NOTE: If the client is a mobile device and the client address changes, peer-to-peer communication will break.
More...
|
delegate void | ReadyHandler (string addr, int port, double holePunchTimeInMilliseconds) |
| Event raised when peer-to-peer comminucation is successfully established. More...
|
|
delegate void | TerminateHandler (string addr, int port) |
| Event raised when peer-to-peer comminucation fails to establish. More...
|
|
delegate void | MessageHandler (string addr, int port, byte[] packet) |
| Event raised when the peer sends a message via Send or RSend. More...
|
|
delegate void | ExceptionHandler (int errCode, string errMsg) |
| Event raised when socket related exception is thrown. More...
|
|
| P2P (Udp udp) |
| Creates a P2P peer and communication wit the peer. One P2P instance = One P2P peer. More...
|
|
void | SetEncryptionKeys (byte[] key, byte[] iv, byte[] mackey) |
| Sets up encryption and decryption of packets. More...
|
|
void | SetResendTime (ushort resendTime) |
| Sets resend time in milliseconds for RSend. Default value of resent time is 1000ms. NOTE: Setting this value too small may lead to unecessary CPU workloads. 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...
|
|
string | GetPeerAddress () |
| Rerturns the peer address and port as a string. More...
|
|
bool | IsSamePeer (string addr, int port) |
| Returns true if the address and port match its address and port. More...
|
|
void | Connect (string publicAddress, string[] localAddresses, ushort timeoutInMilliseconds=3000) |
| 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...
|
|
void | RSend (byte[] msg) |
| Sends a P2P message as a reliable packet. Guarantees the delivery and order of the message. More...
|
|
|
string | UID |
| Client unique user ID to be set and used. More...
|
|
Peer-to-Peer client that uses Diarksi Udp class instance internally. NOTE: If the client is a mobile device and the client address changes, peer-to-peer communication will break.
◆ P2P()
Diarkis.Modules.P2P.P2P |
( |
Udp |
udp | ) |
|
|
inline |
Creates a P2P peer and communication wit the peer. One P2P instance = One P2P peer.
◆ Connect()
void Diarkis.Modules.P2P.Connect |
( |
string |
publicAddress, |
|
|
string[] |
localAddresses, |
|
|
ushort |
timeoutInMilliseconds = 3000 |
|
) |
| |
|
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
-
publicAddress | Public address of the peer to start P2P with. The string format is "{address}:{port}". |
- Parameters
-
localAddresses | An array of local addresses of the peer. If the public address of the peer is the same as yours, hole punching fails. The local address list will be used to complete the hole punch instead. |
timeoutInMilliseconds | Timeout in milliseconds. When this time exceeds before successfully completing hole punching with the peer. It will trigger OnFail event. Default is 3000ms. |
◆ Disconnect()
void Diarkis.Modules.P2P.Disconnect |
( |
| ) |
|
|
inline |
Stops P2P communication with the peer.
◆ ExceptionHandler()
delegate void Diarkis.Modules.P2P.ExceptionHandler |
( |
int |
errCode, |
|
|
string |
errMsg |
|
) |
| |
Event raised when socket related exception is thrown.
◆ GetPeerAddress()
string Diarkis.Modules.P2P.GetPeerAddress |
( |
| ) |
|
|
inline |
Rerturns the peer address and port as a string.
◆ IsConnected()
bool Diarkis.Modules.P2P.IsConnected |
( |
| ) |
|
|
inline |
Returns true if we are connected (hole punch successfully completed) with the peer.
◆ IsSamePeer()
bool Diarkis.Modules.P2P.IsSamePeer |
( |
string |
addr, |
|
|
int |
port |
|
) |
| |
|
inline |
Returns true if the address and port match its address and port.
◆ MessageHandler()
delegate void Diarkis.Modules.P2P.MessageHandler |
( |
string |
addr, |
|
|
int |
port, |
|
|
byte[] |
packet |
|
) |
| |
Event raised when the peer sends a message via Send or RSend.
- Parameters
-
addr | Peer client address. |
port | Peer client port. |
packet | Message byte array sent from the peer. |
◆ ReadyHandler()
delegate void Diarkis.Modules.P2P.ReadyHandler |
( |
string |
addr, |
|
|
int |
port, |
|
|
double |
holePunchTimeInMilliseconds |
|
) |
| |
Event raised when peer-to-peer comminucation is successfully established.
- Parameters
-
addr | Peer client address. |
port | Peer client port. |
holePunchTimeInMilliseconds | Time in milliseconds it took to complete hole punching (establishing peer-to-peer communication). |
◆ RSend()
void Diarkis.Modules.P2P.RSend |
( |
byte[] |
msg | ) |
|
|
inline |
Sends a P2P message as a reliable packet. Guarantees the delivery and order of the message.
- Parameters
-
msg | Message byte array to be sent. |
◆ Send()
void Diarkis.Modules.P2P.Send |
( |
byte[] |
msg | ) |
|
|
inline |
Sensd a P2P message to the peer.
- Parameters
-
◆ SetEncryptionKeys()
void Diarkis.Modules.P2P.SetEncryptionKeys |
( |
byte[] |
key, |
|
|
byte[] |
iv, |
|
|
byte[] |
mackey |
|
) |
| |
|
inline |
Sets up encryption and decryption of packets.
- Parameters
-
key | Encryption key. |
iv | Encryption initialization vector (IV). |
mackey | Mac key used sign encrypted payload of a packet. |
◆ SetResendTime()
void Diarkis.Modules.P2P.SetResendTime |
( |
ushort |
resendTime | ) |
|
|
inline |
Sets resend time in milliseconds for RSend. Default value of resent time is 1000ms. NOTE: Setting this value too small may lead to unecessary CPU workloads.
◆ TerminateHandler()
delegate void Diarkis.Modules.P2P.TerminateHandler |
( |
string |
addr, |
|
|
int |
port |
|
) |
| |
Event raised when peer-to-peer comminucation fails to establish.
- Parameters
-
addr | Peer client address. |
port | Peer client port. |
◆ Update()
void Diarkis.Modules.P2P.Update |
( |
| ) |
|
|
inline |
Must be called a certain interval from the main thread. For Unity application this must be called in Update.
◆ UID
string Diarkis.Modules.P2P.UID |
Client unique user ID to be set and used.
The documentation for this class was generated from the following file: