I'm using node-xmpp server as a chat server for 2 clients:Psi and Spark.I register an account for every client.I want to send from Psi account a message to Spark account.Every time when i send a message from an account the same account receive the message.I want to add friend to my list(i don't know why doesn'w work..probably is not implemented) and to send messages correctly.I'm using node xmpp server/examples/server-and-client.js.Thanks for advices.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
This complete code work pretty well for me:
When a message stanza arrives, I check wether the receiver is connected or not and if so I send the stanza to it.
Send the message with the correct client connection i.e.
1). Store all the connection of the clients in an array at the time of authentication.
2). When a message come find the correct client associated with the "to" field in the message stanza.
var receiverCleint = getClient(msgStanza.attrs.to)
3). return the correct client and send the message through that client.
receiverCleint.send(msgStanza)
I am also working on the same demo, my only concern is when more user adds then it will be a problem as it has to iterate on each message through all clients.
Any better approach appreciated.
Code: