Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whatsapp-like group chat and chat must be friends #719

Closed
FlowerWrong opened this issue Aug 28, 2015 · 16 comments
Closed

whatsapp-like group chat and chat must be friends #719

FlowerWrong opened this issue Aug 28, 2015 · 16 comments

Comments

@FlowerWrong
Copy link

I know this is not an issue. But it maked me confused for a long time.

How to implement a whatsapp-like group chat without hackcore?

As we know, the definition of XEP-45 is that after joined user goes to offline, the room will remove he or she. He or she can not get the offline messages. I do not what to that. In my requirement, he or she will not leave the room after it goes to offline, and he or she cat get all offline messages. Is there some customed module or new way to implement this?

Can chat but we must be friends.

In xmpp, we cat chat with each other if only know someone's jid. I do not want to this. They can chat when they are friends. If they are not friends, they can not chat. How can I implement this?

@zinid
Copy link
Contributor

zinid commented Aug 28, 2015

How to implement a whatsapp-like group chat without hackcore?

I never used chatrooms in Whatsapp, but I think you can implement it using MAM: when enabled in the conference, you can load chunks of history. Such functionality is implemented in development builds of Sawim for example.

Can chat but we must be friends

I don't think this could be done without hacks, XMPP is not designed for this, alas.

@FlowerWrong
Copy link
Author

@zinid Thanks for reply.
I agree with the second question. XMPP is not design for this.
In the first question, I can get the offline messages, But there is another problem, I can not hold the users of the room. I need to know the user list of the room at any time, the list included both online and offline users in this room. People can join and leave the room(not go offline). May be I can store it to another table, when someone joined, I joined it to this table, when someone leave(not go offline, just leave this room, he does not want to in it.), I delete it from the table.
Any other ways?

@zinid
Copy link
Contributor

zinid commented Aug 28, 2015

Just don't go offline. I don't think Whatsapp even has a concept of offline. If you're using a mobile app you can be always "almost online" due to new session management support.

@FlowerWrong
Copy link
Author

Could you give me a link which means new session management support. Is it a module or some otherthing?

@zinid
Copy link
Contributor

zinid commented Aug 29, 2015

This is XEP-0198 and is implemented in ejabberd since 14.05 and is enabled by default.

@FlowerWrong FlowerWrong mentioned this issue Sep 1, 2015
@FlowerWrong
Copy link
Author

@zinid I am using XEP-198. It can keep session for a while. But after I resume this session, the pid of this session had changed. And muc_online_users table in mnesia will also del this online user after resume this session. So I can not keep the group users.
2015-09-01 16 11 47
2015-09-01 16 15 53

The client code wrote with smack 4.1.3.

package cc.onecampus;

import org.jivesoftware.smack.*;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

import java.io.IOException;

/**
 * Created by yy on 15-9-1.
 */
public class LoginWithResume {
    public static void main(String[] args) {
        SmackConfiguration.DEBUG = true;
        SmackConfiguration.setDefaultPacketReplyTimeout(1000);
        // Open the StreamManagement support
        XMPPTCPConnection.setUseStreamManagementDefault(true);
        XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);

        // Create the configuration for this new connection
        XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
        configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

        configBuilder.setUsernameAndPassword("registeruser2", "123456");
        configBuilder.setServiceName("ejabberddemo.com");
        configBuilder.setDebuggerEnabled(true).build();

        AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());

        ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(connection);
        reconnectionManager.enableAutomaticReconnection();

        try {
            connection.connect().login();
        } catch (SmackException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XMPPException e) {
            e.printStackTrace();
        }
        while (true) ;
    }
}

Thanks a lot.

@zinid
Copy link
Contributor

zinid commented Sep 1, 2015

I don't understand the question. The session pid will be indeed changed, but it's unrelated to muc_online_users table. Also, in screenshot you showed sm table, not muc_online_users.

@FlowerWrong
Copy link
Author

Yes, I means the session keeped user will be removed after resume this session.
Desc:

  1. I joined a room with enabled stream management. And then broken the internet. The sm and muc_online_users tables still have this session.
  2. I resume this session. This session has changed the pid. and this user had be delete from muc_online_users table.
    Before resume.
    2015-09-01 17 34 02
After resme. The muc_online_users table is empty.

2015-09-01 16 15 53

@zinid
Copy link
Contributor

zinid commented Sep 1, 2015

I still don't understand. There is no session pid in muc_online_users table. Why should it be deleted?

@FlowerWrong
Copy link
Author

In sm table, The pid of this session changed, not in muc_online_users table.
2015-09-01 16 11 47
2015-09-01 16 15 53

The muc_online_users table delete the user who joined this room after resume the session.

Before resume.

2015-09-01 17 34 02

After resume. The muc_online_users table is empty.

2015-09-01 16 15 53

@zinid
Copy link
Contributor

zinid commented Sep 1, 2015

Probably someone else can look into that, I don't have a client with XEP-0198 support to check.

@weiss
Copy link
Member

weiss commented Sep 1, 2015

The muc_online_users table delete the user who joined this room after resume the session.

I can't reproduce that issue, sorry. My own personal sessions are resumed multiple times per day, and I'm never kicked out of any of the MUC rooms I've joined.

As @zinid said, the session PID is unrelated to the MUC presence. The MUC service may even be running on a remote server, that server won't be notified of successful XEP-0198 resumes in any way.

So there's probably something else going on. My guess would be that either your client is not only resuming the session but also sending some <presence/> stanza(s), or the session resume simply isn't successful. Did you check the ejabberd.log file? With loglevel: 4 (or 5), ejabberd generates two messages per successful resume, e.g.:

Closing former stream of resumed session for juliet@example.com/Foo
Resumed session for juliet@example.com/Foo

Do you see those?

@FlowerWrong
Copy link
Author

@zinid I am reading the source code. Now the main file I am reading are ejabberd_listener, ejabberd_socket, ejabberd_receiver and ejabberd_c2s.
After print plenty of log, I know the message from pid to pid (like one-to-one chat send message) was using do_route/3 function in ejabberd_sm file, but I can not see any receive code in ejabberd with search github.
Like:

receive
    chat ->
        ok.
end

Can you help me?

@zinid
Copy link
Contributor

zinid commented Sep 4, 2015

There are not receives. The code is written based on OTP principles. You better read something about Erlang, it's offtopic here. See http://www.erlang.org/doc/design_principles/gen_server_concepts.html and http://www.erlang.org/doc/design_principles/fsm.html

@FlowerWrong
Copy link
Author

I see, thanks a lot.

@lock
Copy link

lock bot commented Jun 12, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants