4ib3r / StompBrokerJS

NodeJS StompBroker
MIT License
35 stars 28 forks source link

need to send individual message to client #5

Closed krtl closed 6 years ago

krtl commented 6 years ago

Please implement sending of individual messages to stomp client. Great thanks for your work!

krtl commented 6 years ago

I figured out how to do it

bjdash commented 6 years ago

@krtl Could you please share how you did it?

krtl commented 6 years ago

Unfortunately, I've done this by amending stompServer.js

2018-08-01 14:07 GMT+03:00 Bijay Dash notifications@github.com:

@krtl https://github.com/krtl Could you please share how you did it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/4ib3r/StompBrokerJS/issues/5#issuecomment-409538523, or mute the thread https://github.com/notifications/unsubscribe-auth/Ab6oZlzvq7vuxbnNu8ctxKGBrsgLfG_Iks5uMYvxgaJpZM4QwFZD .

bjdash commented 6 years ago

@krtl Will you be able to share any code snippets or the general idea/login on what changes you made, just an overview

krtl commented 6 years ago

ok, I made two things:

1) add socket param to emit of 'send' event line 112 in original stompServer.js: this.emit('send', {frame: {headers: frame.headers, body: bodyObj}, dest: args.dest, socket});

2) add following func to original stompServer.js

/** SendIndividual message to specific client

Usage: In my project I needed only to reply to individuals:

stompServer.on('send', (ev) => { //... stompServer.sendIndividual(ev.socket, TOPIC_NAME, {}, REPLY_TEXT); });

the same code for reply on subscribe:

stompServer.on('subscribe', (ev) => { //... stompServer.sendIndividual(ev.socket, TOPIC_NAME, {}, REPLY_TEXT); });