Пример #1
0
 // the connection might be a failed one
 public void OnSockMgrConnect(object sender, SockMgrConnectEventArgs e)
 {
     if (!e.Handler.GetSockBase().IsConnected)  // connection failed
     {
         Console.WriteLine(string.Format("[Connect] Failed | {0} times left | {1}", e.State.timesToTry, e.State.errorType.ToString()));
         Console.Write("> ");
         return;
     }
     // print: [Connect] local -> remote
     Console.WriteLine(string.Format("[Connect] {0} -> {1}",
                                     e.Handler.GetSockBase().GetSocket().LocalEndPoint.ToString(),
                                     e.Handler.GetSockBase().GetSocket().RemoteEndPoint.ToString()));
     Console.Write("> ");
     // send connection info to peer
     e.Handler.SendText(string.Format("{0} -> {1}",
                                      e.Handler.GetSockBase().GetSocket().LocalEndPoint.ToString(),
                                      e.Handler.GetSockBase().GetSocket().RemoteEndPoint.ToString()));
 }
Пример #2
0
 private void CallbackTest(object sender, SockMgrConnectEventArgs e)
 {
     // Console.WriteLine("[Test] Callback called");
     // Console.WriteLine((int)e.ExternalCallbackState);
 }
Пример #3
0
 private void OnSockMgrConnect(object sender, SockMgrConnectEventArgs e)
 {
     RegisterNewSockMgr(e.Handler);
     SockMgrConnectEvent?.Invoke(sender, e);
 }
Пример #4
0
 // return
 private void OnSocketConnect(object sender, SockMgrConnectEventArgs e)
 {
     SockMgrConnectEvent?.Invoke(sender, e);
 }