Exemple #1
0
        public void Connect()
        {
            SetState(ConnectionState.CONNECTING);
            Boolean willPresent = false;

            if (_will != null)
            {
                willPresent = true;
            }

            SNConnect connect = new SNConnect(_isClean, _keepalive, _clientID, willPresent);

            if (_timers != null)
            {
                _timers.StopAllTimers();
            }

            _timers = new TimersMap(this, _client, RESEND_PERIOND, _keepalive * 1000);
            _timers.StoreConnectTimer(connect);

            if (_client.IsConnected())
            {
                _client.Send(connect);
            }
        }
        public Boolean Disconnect()
        {
            if (_client.IsConnected())
            {
                _client.Close();
            }

            SetState(ConnectionState.NONE);
            return(true);
        }