Skip to content

FlowerWrong/xmpp4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

xmpp4j

Dependencies

social_stream

Usage

gradle build
java -jar build/libs/xmpp4j-1.0.jar

Links

Register allow all ipaddress

    ##
    ## Only clients in the server machine can register accounts
    ##
    ip_access: all  # trusted_network Note here

  ## In-band registration allows registration of any possible username.
  ## To disable in-band registration, replace 'allow' with 'deny'.
  register:
    all: allow
  ## Only allow to register from localhost, Disable comment this two line
  ##trusted_network:
  ##  loopback: allow

Issue

ejabberd分析

Module development

Whatsapp-like group chat

XEP-45 was designed more then 10 years ago. Back then, the designers had something like IRC channels in mind. Everything of XEP-45 is designed based on the assumption that a user enters and leaves a room when he/she starts/terminates its client.

WhatsApp Groupchats are different: A user joins a groupchat is is able to view the (complete) history of that chat. Even if the users client is offline/unavailable, he is still considered part of the groupchat. The only extensions that providers roughly similar behavior of XEP-60 PubSub. But that again was written for a different use case.

So you have basically 3 options:

    Use XEP-45 with the mentioned workarounds in the other answers: XEP-198 and/or XEP-313
    Implement persistent groupchat based on PubSub
    Implement your own persistent groupchat XMPP extension

XEP-313 seems at first the best solution, although you likely have to implement a lot of code yourself. 2. Could be an option, but you would code against an implementation not especially designed for the use case. This could result in ugly workarounds or deviations from the standard. But Buddycloud proves that it's doable. Sometimes I think what the XMPP community needs is 3.: A new extensions written from scratch that is designed for persistent groupchats.
I faced your issue as I sought to implement groupchats for my chatting app. I faced the same problem of MUC not storing offline messages for each recipient. And I did not want to retrieve MUC history which requires the user to rejoin every MUC to update his messages database. What I wanted is for the server to save offline messages by recipient, and for the recipient to get all MUC messages when he gets online (without having to join each MUC).

The way I did it is through pubsub. Using pubsub will force the server to store offline message per recipient. When the user reconnects, he gets all the offline messages including the pubsub messages which are sent as normal messages - that is it. One issue I had with pubsub over MUC though is that it is hard to get the list of subscribers. So when my app creates a groupchat, it creates a pubsub node for messages, invite all participants to subscribe (including self) to the pubsub and my app also creates a MUC and makes every participant an owner of that MUC. This way the list of the groupchat participants can be retrieved by checking the list of owners of the MUC. The only purposes of the MUC are to hold the list of participants as well as the name of the groupchat. Everything else is handled by the pubsub node.

Anything unclear please let me know.
Shooting from the hip here, but it's similar to something I thought about a while ago..persistent MUC rooms.

Possible approach involving a modified mod_muc_room:

    On room creation create a Shared Roster group () named {room name}_Participants
    Whenever someone joins the room add them to the roster
    Whenever someone sends /me leaves then remove them from the roster
    Whenever a message is received for the room, send it wrapped in a 'While you were out...' style message to any user in shared roster who is not online
    When room is killed remove shared roster

Build ejabberd from source code

git clone git@github.com:processone/ejabberd.git
git tag -l
git checkout 15.07

./autogen.sh
./configure --prefix=$HOME/softwares/ejabberd/ --enable-mysql
make clean
make
make install

rm $HOME/softwares/ejabberd/etc/ejabberd/ejabberd.yml
ln -s $HOME/dev/java/xmpp4j/src/main/resources/ejabberd.yml $HOME/softwares/ejabberd/etc/ejabberd

# setup mysql
CREATE DATABASE `ejabberdmysql` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use ejabberdmysql;
SOURCE mysql.sql;

./sbin/ejabberdctl start
./sbin/ejabberdctl status
./sbin/ejabberdctl stop

./sbin/ejabberdctl register yang ejabberddemo.com 123456

Debug mnesia of ejabberd

ejabberdctl debug

mnesia:info().
observer:start().

TODO

  • only allow some ip for register
  • hack for friends chat
  • hack for save group users
  • write http api for chat history

smack demo

About

A xmpp demo written in java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published