Example #1
0
        private void OnDisconnected(object sender, EventArgs eventArgs)
        {
            Status = ClientNetworkStatus.Disconnected;
            m_ClientSocket.OnConnect    -= OnConnected;
            m_ClientSocket.OnReceive    -= OnReceived;
            m_ClientSocket.OnDisconnect -= OnDisconnected;

            lock (m_MessageLocker)
            {
                m_Messages.Clear();
            }

            m_ClientSocket = null;
        }
Example #2
0
        public bool Connect(string ipString, int port)
        {
            if (m_ClientSocket != null)
            {
                NetUtil.LogError(NetUtil.CLIENT_LOG_TAG, "The socket has been created");
                return(false);
            }

            m_ClientSocket               = new TcpClientSocket();
            m_ClientSocket.OnConnect    += OnConnected;
            m_ClientSocket.OnReceive    += OnReceived;
            m_ClientSocket.OnDisconnect += OnDisconnected;

            Status = ClientNetworkStatus.Connecting;

            m_ClientSocket.Connect(IPAddress.Parse(ipString), port);

            return(true);
        }