// Set up P2P class instance with Diarkis UPD client instancep2pClientA =shared_ptr<IDiarkisP2P>(DiarkisCreateP2P(diarkisUdpClient));// Set up Event listeners// This event is raised when peer-to-peer connection is successful and ready to send and receive messagesREG_EVENT(p2pClientA->GetReadyEvent(), [this](void*, const DiarkisReadyEventArgs& args) { /* do something magical here */ });
// This event is raised when peer-to-peer connection failedREG_EVENT(p2pClientA->GetFailEvent(), [this](void*, const DiarkisFailEventArgs& args) { /* do something magical here */ });
// This event is raised when you receive a message from the peerREG_EVENT(p2pClientA->GetMessageEvent(), [this](void*, const DiarkisMessageEventArgs& args) { /* do something magical here */ });
// This event is raised when socket related exception is caughtREG_EVENT(p2pClientA->GetExceptionEvent(), [this](void*, const DiarkisExceptionEventArgs& args) { /* do something magical here */ });
// Pass a client address// The format of client address is 0.0.0.0:0 as a string// where 0.0.0.0 would be the address and 0 after : is the port// We need to separate the address from the portp2p->Connect(address, port);