Ejemplo n.º 1
0
 /// <summary>
 /// Performs whatever functions we might so desire when we receive an incoming ChatMessage
 /// </summary>
 /// <param name="header">The PacketHeader corresponding with the received object</param>
 /// <param name="connection">The Connection from which this object was received</param>
 /// <param name="incomingMessage">The incoming ChatMessage we are after</param>
 protected virtual void HandleIncomingChatMessage(PacketHeader header, Connection connection, DataReceiveModel incomingMessage)
 {
     DisplayValuesFromServer(incomingMessage.Value);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs whatever functions we might so desire when we receive an incoming ChatMessage
        /// </summary>
        /// <param name="header">The PacketHeader corresponding with the received object</param>
        /// <param name="connection">The Connection from which this object was received</param>
        /// <param name="incomingMessage">The incoming ChatMessage we are after</param>
        protected virtual void HandleIncomingChatMessage(PacketHeader header, Connection connection, DataReceiveModel incomingMessage)
        {
            var         x       = connection.ConnectionInfo.RemoteEndPoint.ToString();
            var         temp    = x.Split(':');
            ClientModel newData = new ClientModel()
            {
                IP     = temp[0],
                Port   = int.Parse(temp[1]),
                Name   = incomingMessage.SourceName,
                Value  = incomingMessage.Value,
                Value2 = incomingMessage.Value2
            };
            bool checkExsisted = false;

            foreach (var i in ls)
            {
                if (i.IP == newData.IP && i.Port == newData.Port)
                {
                    i.Name        = newData.Name;
                    i.Value       = newData.Value;
                    i.Value2      = newData.Value2;
                    checkExsisted = true;
                }
            }
            if (!checkExsisted)
            {
                ls.Add(newData);
            }
            // Hien thi gia tri nhan duoc
            DisplayValuesFromClient(ls);
        }