moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 508 forks source link

how to get Client Object by client id? #648

Closed ghost closed 7 years ago

ghost commented 7 years ago

my situation is:

all device's clientId is recoreded in DB, I need to publish message to some client filter by id. Is there any method to get the client object by id? or should I just use:

server.publish(packer, {
    id: 'clientId'
})
mcollina commented 7 years ago

Try server.clients[id], however this will return the client connected to that specific broker.

The best approach is for each client to have its own topic, and publish messages there.

ghost commented 7 years ago

thank you,solved my problem