- Client
- new Client(aedes, stream, request)
- client.conn
- client.req
- client.connecting
- client.connected
- client.closed
- client.id
- client.clean
- client.version
- Event: connected
- Event: error
- client.publish (packet, [callback])
- client.subscribe (subscriptions, [callback])
- client.unsubscribe (unsubscriptions, [callback])
- client.close ([callback])
- client.emptyOutgoingQueue ([callback])
- aedes
<Aedes> - stream:
<net.Socket>|<stream.Duplex> - request:
<http.IncomingMessage> - Returns:
<Client>
<net.Socket>|<stream.Duplex>
Client connection stream object.
In the case of net.createServer, conn passed to the connectionlistener function by node's net.createServer API.
In the case of websocket-stream, it's the stream argument passed to the websocket handle function in websocket-stream #on-the-server].
<http.IncomingMessage>
only for websocket-stream. It is a HTTP Websocket upgrade request object passed to websocket handle function in websocket-stream #on-the-server. It gives an option for accessing headers or cookies.
<boolean>Default:false
a read-only flag, it is true when Client is in CONNECT phase. Aedes emits connackSent event will not reset connecting to false until it received all its offline messagess to the Client.
<boolean>Default:false
a read-only flag, it is true when connected event is emitted, and false when client is closed.
<boolean>Default:false
a read-only flag indicates if client is closed or not.
<string>Default:aedes_${hyperid()}
Client unique identifier, specified by CONNECT packet.
It is available only after CONNACK (rc=0), otherwise it is null in cases:
- in
aedes.preConnectstage - after
CONNACK (rc!=0)response connectionErrorraised by aedes
<boolean>Default:true
Client clean flag, set by clean flag in CONNECT packet.
<number>Default:null
Client version, set by protocol version in CONNECT packet when CONNACK (rc=0) returns.
Same as aedes clientReady but in client-wise.
error<Error>
Emitted when an error occurs.
packet<object>PUBLISHcallback<Function>(error) => void- error
<Error>|null
- error
Publish the given packet to this client. QoS 1 and 2 are fully supported, while the retained flag is not.
callback will be invoked when the message has been sent, but not acked.
subscriptions<object>callback<Function>(error) => void- error
<Error>|null
- error
Subscribe client to the list of topics.
subscriptions can be:
- a single object in the format
{ topic: topic, qos: qos } - an array of the above
- a full
SUBSCRIBE, specifying amessageIdwill send suback to the client.
callback will be invoked when the subscription is completed.
unsubscriptions<object>callback<Function>(error) => void- error
<Error>|null
- error
Unsubscribe client to the list of topics.
unsubscriptions can be:
- a single object in the format
{ topic: topic, qos: qos } - an array of the above
- a full
UNSUBSCRIBE
callback will be invoked when the unsubscriptions are completed.
Disconnect client
callback will be invoked when client is closed.
Clear all outgoing messages (QoS > 1) related to this client from persistence
callback will be invoked when the operation ends.