Пример #1
0
 public void SendCommandFromAllClients(MessageDescript descript)
 {
     foreach (var client in Clients)
     {
         sendner.asynSendMessageFromClient(descript, client.Value, allocSendedMessageFromClient, allocDropClientSendMessage);
     }
 }
Пример #2
0
 public InfoSendRecvest(MessageDescript descript,
                        ClientInfo client,
                        Action <ClientInfo, MessageDescript> allocToSendedMessage,
                        Action <ClientInfo, Exception> allocToDropSendClient)
 {
     Descript              = descript;
     Client                = client;
     AllocToSendedMessage  = allocToSendedMessage;
     AllocToDropSendClient = allocToDropSendClient;
 }
Пример #3
0
        private void DoTemplate(NetServer server, NetClient client, MessageDescript descript)
        {
            if (client != null)
            {
                OnGetCommandClientLogic(client, descript.Message);
            }

            if (server != null)
            {
                OnGetCommandServerLogic(server, descript.Message);
            }
        }
Пример #4
0
 public void GetCommandTemplate(NetServer server, NetClient client, MessageDescript descript)
 {
     if (isWorkInMainThread)
     {
         var info = new InfoMethodLoop(server, client, descript, DoTemplate);
         TNFManager.Iterator.AddTask(info);
     }
     else
     {
         DoTemplate(server, client, descript);
     }
 }
Пример #5
0
        public void asynSendMessageFromClient(MessageDescript descript, ClientInfo client, Action <ClientInfo, MessageDescript> allocToSendedMessage, Action <ClientInfo, Exception> allocToDropSendClient)
        {
            InfoSendRecvest info = new InfoSendRecvest(descript, client, allocToSendedMessage, allocToDropSendClient);


            sendRecvests.Enqueue(info);

            if (sendingNow)
            {
                return;
            }

            sendingNow = true;
            StartProtectedThread(SendingQueue);
        }
Пример #6
0
        private void SendMessage(MessageDescript descript, ClientInfo client, Action <ClientInfo, MessageDescript> allocToSendedMessage, Action <ClientInfo, Exception> allocToDropSendClient)
        {
            lock (locker)
            {
                try
                {
                    var stream = client.ClientTCP.GetStream();

                    stream.Write(descript.Buffer, 0, descript.Buffer.Length);

                    allocToSendedMessage(client, descript);
                }
                catch (Exception e)
                {
                    lock (locker)
                    {
                        allocToDropSendClient(client, e);
                    }
                }
            }
        }
Пример #7
0
 private void allocSendedMessageFromClient(ClientInfo client, MessageDescript descript)
 {
 }
Пример #8
0
 private void allocSended(ClientInfo info, MessageDescript descript)
 {
     DebugAdapter.Log($"Sended: {descript.Message}");
 }