aksonov / react-native-xmpp

XMPP library for React Native (iOS and Android native support)
BSD 2-Clause "Simplified" License
305 stars 96 forks source link

How to join a room? #82

Open jzhw0130 opened 6 years ago

jzhw0130 commented 6 years ago

Now I can connect the server, send message fro another account. If I want to join a chat room, chat with multi-users, how to implement?
Does the library support? If yes, which API should use?

Thanks

jzhw0130 commented 6 years ago

The library does not support the feature. Need to do by yourself. Code as follows:

Join a room:

var builder = require('xmlbuilder'); var xml = builder.begin() .ele('presence',{'to':${roomJID}/${nickName}}) .ele('x', {'xmlns':'http://jabber.org/protocol/muc'}) .end({ pretty: true}); XMPP.sendStanza(xml.toString());

Send group message:

        var builder = require('xmlbuilder');
        var xml = builder.begin()
                        .ele('message',{'to':`${roomJID}`, type:'groupchat'})
                        .ele('body', {}, message)
                        .end({ pretty: true});
        XMPP.sendStanza(xml.toString());
jzhw0130 commented 6 years ago

By the way, for the custom IQ message, Android needs to add custom Provider to support. Otherwise, parse will fail, you will get a UnParsed IQ.

CocktailZY commented 6 years ago

Hello, I also met the same problem, through the way you mentioned that the group chat messages have been solved, but can not monitor the group chat messages, do you have a similar problem?

jzhw0130 commented 6 years ago

Sorry, I have stopped using the library. Just use the service from PubNub.

heachou commented 6 years ago

@CocktailZY hello, how to monitor the group chat messages? Have you solved the problem?

andrzejbe commented 6 years ago

@heachou see my pull-request "multi-chat rooms"

vinayakb-pits commented 5 years ago

@andrzejbe How can I use your pull request into my project? is there any npm install available? or do I need to download all project?

andrzejbe commented 5 years ago

@vinayakb-pits - there's no npm as I (still) hope it will be merged with master branch at some point ;) for now you can use it as follows:

@import KissXML = replace with => #import "KissXML.h" @import CocoaAsyncSocket = replace with => #import "GCDAsyncSocket.h"

hope it helps

vinayakb-pits commented 5 years ago

@andrzejbe I added your code as a library in my project and add "react-native-xmpp": "file:./src/libs/react-native-xmpp-master", in package json . It's working perfectly. Thank you very much