|
@@ -675,7 +675,7 @@ export default class ChatRoom extends Listenable {
|
675
|
675
|
}
|
676
|
676
|
|
677
|
677
|
/**
|
678
|
|
- *
|
|
678
|
+ * Send text message to the other participants in the conference
|
679
|
679
|
* @param body
|
680
|
680
|
* @param nickname
|
681
|
681
|
*/
|
|
@@ -694,6 +694,29 @@ export default class ChatRoom extends Listenable {
|
694
|
694
|
this.eventEmitter.emit(XMPPEvents.SENDING_CHAT_MESSAGE, body);
|
695
|
695
|
}
|
696
|
696
|
|
|
697
|
+ /**
|
|
698
|
+ * Send private text message to another participant of the conference
|
|
699
|
+ * @param id id/muc resource of the receiver
|
|
700
|
+ * @param body
|
|
701
|
+ * @param nickname
|
|
702
|
+ */
|
|
703
|
+ sendPrivateMessage(id, body, nickname) {
|
|
704
|
+ const msg = $msg({ to: `${this.roomjid}/${id}`,
|
|
705
|
+ type: 'chat' });
|
|
706
|
+
|
|
707
|
+ msg.c('body', body).up();
|
|
708
|
+ if (nickname) {
|
|
709
|
+ msg.c('nick', { xmlns: 'http://jabber.org/protocol/nick' })
|
|
710
|
+ .t(nickname)
|
|
711
|
+ .up()
|
|
712
|
+ .up();
|
|
713
|
+ }
|
|
714
|
+
|
|
715
|
+ this.connection.send(msg);
|
|
716
|
+ this.eventEmitter.emit(XMPPEvents.SENDING_PRIVATE_CHAT_MESSAGE, body);
|
|
717
|
+ }
|
|
718
|
+
|
|
719
|
+
|
697
|
720
|
/**
|
698
|
721
|
*
|
699
|
722
|
* @param subject
|
|
@@ -864,8 +887,16 @@ export default class ChatRoom extends Listenable {
|
864
|
887
|
}
|
865
|
888
|
|
866
|
889
|
if (txt) {
|
867
|
|
- this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
|
868
|
|
- from, nick, txt, this.myroomjid, stamp);
|
|
890
|
+ if (type === 'chat') {
|
|
891
|
+ logger.log('privatechat', nick, txt);
|
|
892
|
+ this.eventEmitter.emit(XMPPEvents.PRIVATE_MESSAGE_RECEIVED,
|
|
893
|
+ from, nick, txt, this.myroomjid, stamp);
|
|
894
|
+ }
|
|
895
|
+ if (type === 'groupchat') {
|
|
896
|
+ logger.log('chat', nick, txt);
|
|
897
|
+ this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
|
|
898
|
+ from, nick, txt, this.myroomjid, stamp);
|
|
899
|
+ }
|
869
|
900
|
}
|
870
|
901
|
}
|
871
|
902
|
|