Esempio n. 1
0
        /// <summary>
        /// Lấy dữ liệu từ máy khác
        /// </summary>
        /// <param name="obj"></param>
        void NhanTinVe(object obj)
        {
            var client = (MayKhach)obj;

            try
            {
                while (true)
                {
                    var data    = client.Receive();
                    var message = ObjectConvert.Binnary2Object(data);
                    Logging.Debug("Recieved data from:" + client.TenMay);
                    var processor = new ServerMessageProcessor(clientManager, client);
                    message.Accept(processor);
                    foreach (var item in processor.Response)
                    {
                        if (item.Client != null)
                        {
                            SendToClient(item.Client as MayKhach, item);
                        }
                        else
                        {
                            SendToClient(client, item);
                        }
                    }
                }
            }
            catch
            {
                clientManager.Remove(client);
            }
        }
Esempio n. 2
0
        void WaitMessage()
        {
            try
            {
                while (true)
                {
                    var data = new byte[1024];
                    client.Receive(data);
                    var message = ObjectConvert.Binnary2Object(data);
                    foreach (var item in this.Processors)
                    {
                        message.Accept(item);
                    }

                    Logging.Info("Recieved data from server, data leng:" + data.Length);
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Error on WaitMessage", ex);
                client.Close();
            }
        }