Beispiel #1
0
 /// <summary>
 /// Connect given two socket as p2p
 /// </summary>
 /// <param name="socket1">first socket</param>
 /// <param name="socket2">second socket</param>
 /// <param name="callback">callback object</param>
 /// <returns>true if paired otherwise false</returns>
 public bool ConnectPair(INetworkSocket socket1, INetworkSocket socket2, IP2PCallback callBackObj)
 {
     if (!Paired)
     {
         if (socket1 != null && socket2 != null && socket1 != socket2 && socket1.IsConnectionAlive && socket2.IsConnectionAlive)
         {
             lock (m_generalLock)
             {
                 m_socket1             = socket1;
                 m_socket2             = socket2;
                 m_socket1.CallBackObj = this;
                 m_socket2.CallBackObj = this;
                 Paired      = true;
                 CallBackObj = callBackObj;
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #2
0
 /// <summary>
 /// Connect given two socket as p2p
 /// </summary>
 /// <param name="socket1">first socket</param>
 /// <param name="socket2">second socket</param>
 /// <param name="callback">callback object</param>
 /// <returns>true if paired otherwise false</returns>
 public bool ConnectPair(INetworkSocket socket1, INetworkSocket socket2, IP2PCallback callBackObj)
 {
     if (!Paired)
     {
         if (socket1 != null && socket2 != null && socket1 != socket2 && socket1.IsConnectionAlive && socket2.IsConnectionAlive)
         {
             lock (m_generalLock)
             {
                 m_socket1 = socket1;
                 m_socket2 = socket2;
                 m_socket1.CallBackObj = this;
                 m_socket2.CallBackObj = this;
                 Paired = true;
                 CallBackObj = callBackObj;
                 return true;
             }
             
         }
     }
     return false;
 }