예제 #1
0
        /// <summary>
        /// Loop handling listener
        /// </summary>
        public void Loop()
        {
            while (Client.CurrentUser != null && Client.Connection != null)
            {
                try
                {
                    // Listening
                    CustomPacket customPacket = Net.rcvMsg(Client.Connection.GetStream());
                    if (customPacket == null)
                    {
                        continue;
                    }
                    Console.Out.WriteLine(customPacket.ToString());

                    _connectTry = 0;
                }
                catch (Exception)
                {
                    // Fail

                    // If the client connection is null, it means that there has been a logout
                    if (Client.Connection != null)
                    {
                        if (Client.CurrentUser != null)
                        {
                            Console.Out.WriteLine("Connection error");
                        }

                        Timeout();
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Loop handling listener
        /// </summary>
        private void Loop()
        {
            while (CurrentUser != null && _connection != null)
            {
                try
                {
                    // Listening
                    CustomPacket customPacket = Net.rcvMsg(_connection.GetStream());
                    AddLineChat(customPacket.ToString());

                    _connectTry = 0;
                }
                catch (Exception)
                {
                    // Fail

                    // If the client connection is null, it means that there has been a logout
                    if (_connection != null)
                    {
                        if (CurrentUser != null)
                        {
                            AddLineChat("Connection error");
                        }

                        Timeout();
                    }
                }
            }
        }