Send a Reply on Receiving a Message

35 views
Skip to first unread message

hosein...@gmail.com

unread,
Dec 29, 2016, 3:45:54 PM12/29/16
to EasyRTC
Hi everyone

I added a listener function on event  easyrtcMsg and check type of messages. I wanna send a proper reply to sender of a this type message. for example:

easyrtc.events.on("easyrtcMsg",function(connectionObj, msg, socketCallback, next){

if( msg.msgType == 'type1'){
   replyMessage( replyMsg1 );
else if( msg.msgType == 'type2'){
   replyMessage( replyMsg2 );
}else{
easyrtc.events.defaultListeners.easyrtcMsg(connectionObj, msg, socketCallback, next);
}
}); 

How I can do this in EasyRTC? I really appreciate if you help me.

Eric Davies

unread,
Dec 29, 2016, 4:41:15 PM12/29/16
to EasyRTC
I would suggest looking at the implementation of eventListener.onEasyrtcCmd in easyrtc_default_event_listeners.js,
specifically at the handling of the  getRoomList" case.

The interesting line (when you drill deep enough) appears to be
          pub.util.sendSocketCallbackMsg(easyrtcid, socketCallback, {"msgType":"roomList", "msgData":{"roomList":roomList}}, appObj);



hosein...@gmail.com

unread,
Dec 30, 2016, 10:08:34 AM12/30/16
to EasyRTC
Thanks for your answer.

Do I understand correctly that you suggested to change easyrtc_default_event_listeners.js file, and add my customized commands and events?

I prefer do it in my server js file.

Eric Davies

unread,
Dec 30, 2016, 10:50:20 AM12/30/16
to EasyRTC
What I'm suggesting is that you look at the eventListener.onEasyrtcCmd to see how you implement your "replyMessage" function.
Reply all
Reply to author
Forward
0 new messages