示例#1
0
        public void connect()
        {
            if (status == STATUS_CONNECT)
            {
                return;
            }

            try
            {
                Task <IChannel> task = bootstrap.ConnectAsync(IPAddress.Parse(host), port);

                this.currentChannel = task.Result;
                status = STATUS_CONNECT;
                _connectListener.onBuildConnectionSuccess(this.currentChannel?.LocalAddress?.ToString(), this.currentChannel?.RemoteAddress?.ToString());
            }
            catch (Exception ex)
            {
                _connectListener.onBuildConnectionFailure(this.currentChannel?.LocalAddress?.ToString(), ex.Message);
                status = STATUS_DISCONNECT;
                stop();
            }
        }