How to configure XMPP to allow all logged in user to see each other and chat with each other? - xmpp

I am new to XMPP.
I am using Openfire server, and created a console client using Smack library.
My usecase:
All users anonymous, logged in (In future, website visitors) will be able to see other anonymous, logged-in users. And they can initiate a private chat (one-to-one) with any of them.
So, I am able to logged in as Anonymous user, but I am not able to see other Anon / Logged in users (using Roster), because they are not in anon user's roster.
So, What should be configuration OR custom=component/code to to achieve this usecase?
Do I need to create server component? Any hint? OR
It can be done using proper configuration?
Cheers

You should create Multi chat room MUC, and join users after login to this room.After user joins muc room they can get paricipiants list.

Related

Conversejs groupchat subscriptions (ejabberd)

I have been struggling to configure a group chat using conversejs and ejabberd. From the documentation I've stumbled across, it seems like it is possible to have a persistent group chat that users can be subscribed to, which will allow them to receive messages from the group chat while not present in the group chat.
For example: I would like to be able to simply close the group chat on my conversejs client, but still get notifications from that group chat.
This is a fresh ejabberd 21.04 and conversejs 7.0.6 install (using websockets).
What I tried to do was create a room through the conversejs client, and then add a subscription through the ejabberd cli:
ejabberdctl subscribe_room user#my.example.com/muc user test_room#conference.my.example.com urn:xmpp:mucsub:nodes:messages
One of the things I'm most confused by is the field in the configuration panel of a group chat that is titled "XMPP URI of Associated Publish-Subscribe Node." I have no clue how to format this, but have found a few clues online... What I have tried is a number of different configurations of something like:
xmpp:my.example.com?;node=messages
but I'm really just grasping at straws here.
If anyone can help me figure out what I'm doing wrong with this URI, or can show me a working example of this, that would be amazing. If what I'm trying to do simply isn't possible with XMPP, please let me know as well.
Thanks!
it is possible to have a persistent group chat that users can be subscribed to, which will allow them to receive messages from the group chat while not present in the group chat.
Exactly.
ejabberdctl create_room room1 conf.localhost localhost
ejabberdctl change_room_option room1 conf.localhost persistent true
ejabberdctl change_room_option room1 conf.localhost allow_subscription true
ejabberdctl subscribe_room user1#localhost User1 room1#conf.localhost urn:xmpp:mucsub:nodes:messages
Now I'll use the send_message API call to send a message to the room. This requires the sender to be online, so for this example register and login to admin#localhost. And of course, login to user1#localhost to receive the notification from the room. Those clients do not need to join the room.
ejabberdctl send_message groupchat admin#localhost room1#conf.localhost Sub Body

How can i login ejabberd anonymously with given name?

I'm building a chat app, and i wanna manage my users in my own database. how can i use ejabberd to transmit my users's messages , who does not registered on ejabberd?
if it possible to login all the users anonymous, and still store their off-line messages?
if it not possible, what should i do ?

allow members to search for chat rooms they belong in XMPP with Smack API

I'm creating a chatroom website were each user can create a room and add his friends to that room and then start chatting!:D I'm using XMPP as the tool for this site with ejabberd server and smack API as client for room configuration! as you've already understood rooms are member only but I'm looking for a way to let each user see all rooms that she is a member of!
is it possible with xmpp protocol(to get all rooms that I'm member of)?how?
Does making the rooms public solve the problem? BTW how can I do it with smack API?
or better say, how can I choose to set a room public or hidden
thanks in advance
No, it is not possible in XMPP. This has been asked before, see: Is there a way to determine which Mulit User Conferences (MUC) a user has joined?
You could however keep track of these rooms yourself in a separate data store each time an user would enter (and/or leave) the room, but this is outside the scope of XMPP as mentioned earlier.

Creating a chat feature?

I need to include chat, in my application. People sign in the chat and create their user and chat to other users. However it needs to be like facebook chat or pingchat where you add friends you want to talk to.
Can anyone give me pointers to what i need to do? I've heard about xmpp servers but not sure if that is the right thing for my app. Any help would be much appreciated
Thanks
Is your app going to create new users, and add them in the chat list, or going to use existing users (like Gtalk, Y! Messenger etc) on existing protocols (like IRC, XMPP etc)...?
If you are going to implement your own chat system, where your users are registering in your website, then you are going to do these things:
Setup your website
Create a protocol (that's, how you pass messages)
Write and implement an API (in PHP, ASP etc)
Connect that API with your iPhone app.
How it works?
You keep a table of chat messages. The table include:
Chat_From
Chat_To
Chat_Message
Timestamp
All what you do is, when you start a Chat session from Alice to Bob, you just enter them in the table. Next, you fetch the row from the Web Server to your App, by calling your PHP file (say, http://mychatserver.com/getChat.php) based on the condition SELECT CHAT_MESSAGE FROM CHAT_TABLE WHERE CHAT_FROM="ALICE" AND CHAT_TO="BOB";. This message is displayed in your App.
This process should be performed repeatedly, with an interval of, say 1 sec.
I hope you got this idea.

How can anonymous users exchange presence information with valid users on Jabber (Ejabberd)

I am working on a social network that should allow members to chat with visitors on the site. The concept is simple.
Users who have registered signup get their own account with rosters
When a visitor comes to the home page of the social network, he can see some of the online members of the community
Now he should be able to initiate a chat with them, by clicking on their name.
I have already got members to chat with their roster mates. My question is, how can I get an anonymous user to chat with a member and exchange presence info with him?
I have successfully managed to create anonymous accounts, members accounts and even send messages from an anonymous user to other members. But I cant get presence information from anonymous-user to member or vice versa?
BTW, the chat is JS based.
You're trying to break the XMPP model. Presence is an opt-in permission based system. You ask me if you can see my presence, I say yes. Generally my client will then automatically ask you if I can see your presence, and your client says yes. That's what the roster is -- yes's and no's to presence subscription requests.
You can make chat rooms (MUC, multi user chat) that are anonymous, as well as do presence in them. It's not a roster, though. It's the closest to what you're describing without going into crazy-land with pubsub, and I don't know if you could even bend that tool far enough to have anonymous roster entries.