예제 #1
0
        // Event map on disconnected
        static void MyServer_eventOnDisconnected(MyCommunication client)
        {
            Log("MyServer_eventOnDisconnected : " + client.NAME);

            if (mutex_clientlist.WaitOne())
            {
                Log("Remove client from list");

                CLIENT_LIST.Remove(client);
                mutex_clientlist.ReleaseMutex();
            }
            else
            {
                Log("MyServer_eventOnDisconnected : Can't enter to locked thread " + Thread.CurrentThread.ManagedThreadId, true);
            }

            Console.Title = TITLE + "(" + CLIENT_LIST.Count + " client)";
        }
예제 #2
0
 // Event map on link data
 static void MyServer_eventOnLinkData(MyCommunication client, string ADDR, string DATA)
 {
     if (mutex_clientlist.WaitOne())
     {
         foreach (var dst in CLIENT_LIST)
         {
             // find match destinetion
             if (ADDR == dst.NAME)
             {
                 // transmit data
                 dst.SendData(client.NAME, DATA);
                 //break;
             }
         }
         mutex_clientlist.ReleaseMutex();
     }
     else
     {
         Log("MyServer_eventOnLinkData : Can't enter to locked thread " + Thread.CurrentThread.ManagedThreadId, true);
     }
 }