Example #1
0
        protected void DisconnectEventHandler(UdpClient client, bool remoteTrigger = false)
        {
            if (serverMode == false)
            {
                if (!socketClosed)
                {
                    socket.Close();
                    socketClosed = true;
                }
                else
                {
                    return;
                }
            }

            if (ClientDisconnected != null)
            {
                Array.ForEach(ClientDisconnected.GetInvocationList(), d => d.DynamicInvoke(this));
            }

            lock (sentReliableDataLock)
            {
                sentReliablePacketInfo.Clear();
            }
        }
Example #2
0
 private void RemoveAllEventHandels()
 {
     lock (this)
     {
         if (NewClientConnected != null)
         {
             var del = NewClientConnected.GetInvocationList();
             for (int i = 0; i < del.Length; i++)
             {
                 NewClientConnected -= del[i] as Action <IRemoteXTMF>;
             }
         }
         if (NewClientConnected != null)
         {
             var del = NewClientConnected.GetInvocationList();
             for (int i = 0; i < del.Length; i++)
             {
                 NewClientConnected -= del[i] as Action <IRemoteXTMF>;
             }
         }
         if (ClientDisconnected != null)
         {
             var del = ClientDisconnected.GetInvocationList();
             for (int i = 0; i < del.Length; i++)
             {
                 ClientDisconnected -= del[i] as Action <IRemoteXTMF>;
             }
         }
         if (ProgressUpdated != null)
         {
             var del = ProgressUpdated.GetInvocationList();
             for (int i = 0; i < del.Length; i++)
             {
                 ProgressUpdated -= del[i] as Action <IRemoteXTMF, float>;
             }
         }
         if (ClientRunComplete != null)
         {
             var del = ClientRunComplete.GetInvocationList();
             for (int i = 0; i < del.Length; i++)
             {
                 ClientRunComplete -= del[i] as Action <IRemoteXTMF, int, string>;
             }
         }
         if (AllModelSystemRunsComplete != null)
         {
             var del = AllModelSystemRunsComplete.GetInvocationList();
             for (int i = 0; i < del.Length; i++)
             {
                 AllModelSystemRunsComplete -= del[i] as Action;
             }
         }
         RemoveAll(_CustomHandlers);
         RemoveAll(_CustomReceivers);
         RemoveAll(_CustomSenders);
     }
 }
Example #3
0
        protected void DisconnectEventHandler(UdpClient client, bool remoteTrigger = false)
        {
            if (!remoteTrigger)
            {
                client.SendF(1, PacketFlags.SystemMessage);
            }

            int cIndex = clientList.FindIndex(c => c == client);

            if (cIndex > -1)
            {
                clientList.RemoveAt(cIndex);
            }

            lock (client.sentReliableDataLock)
            {
                client.sentReliablePacketInfo.Clear();
            }

            if (ClientDisconnected != null)
            {
                Array.ForEach(ClientDisconnected.GetInvocationList(), d => d.DynamicInvoke(client));
            }
        }