示例#1
0
        public Client(TcpClient client, IEventDispatcher eventDispatcher, Parser.ParserMethod parseMethod, ClientConnectedHandler onConnect = null)
        {
            _client = client;
            Connected = true;
            _client.NoDelay = true;
            _eventDispatcher = eventDispatcher;
            _parseMethod = parseMethod;
            _networkInfos = _client.Client.RemoteEndPoint.ToString();

            if (onConnect != null)
                onConnect.BeginInvoke(this, null, null);

            new Task(Receive).Start();
        }
示例#2
0
        public Client(string ip, int port, IEventDispatcher eventDispatcher, Parser.ParserMethod parseMethod, ClientConnectedHandler onConnect = null)
        {
            try
            {
                _client = new TcpClient(ip, port);

                Connected = true;
                _client.NoDelay = true;
                _eventDispatcher = eventDispatcher;
                _parseMethod = parseMethod;
                _networkInfos = _client.Client.RemoteEndPoint.ToString();

                if (onConnect != null)
                    onConnect.BeginInvoke(this, null, null);

                new Task(Receive).Start();
            }
            catch (SocketException se)
            {
                Connected = false;
            }
        }
示例#3
0
 public Server(IEventDispatcher eventDispatcher, Parser.ParserMethod parseMethod)
 {
     _eventDispatcher = eventDispatcher;
     _parserMethod = parseMethod;
 }