Esempio n. 1
0
        internal NamedConnection Run(NetworkConnection connection)
        {
            MqttCommand command = _reader.Read(connection);

            if (command.CommandMessage != Types.CommandMessage.CONNECT)
            {
                throw new ProtocolException(command.CommandMessage, "Expected CONNECT");
            }

            Connect connect = (Connect)command;

            _writer.Send(connection, new ConnAck());

            return(new NamedConnection(connect.ClientIdentifier, connection));
        }
Esempio n. 2
0
        public Task Send(MqttCommand command)
        {
            var tcs = new TaskCompletionSource <object>();

            try
            {
                _writer.Send(_connection, command);
                tcs.SetResult(null);
            }
            catch (Exception ex)
            {
                tcs.SetException(ex);
            }

            return(tcs.Task);
        }
Esempio n. 3
0
 public Task Send(MqttCommand command)
 {
     return(_writer.Send(_connection, command));
 }