Quantcast
Channel: Ignite Realtime : Discussion List - Openfire Support
Viewing all articles
Browse latest Browse all 4596

Delayed group messaging in openfire

$
0
0

I have built a chat application using an Openfire (xmpp) server. One-to-one person chats are working fine and the messages are delivered instantly. But when we send a message inside a group, the first message gets delayed and the second message is delivered instantly.         

 

 

    MultiUserChatManager groupChat =

              MultiUserChatManager.getInstanceFor(connection).getMultiUserChat("group_name");

    groupChat.send("Message object");

 

 

 

 

Why is the first message getting delayed?

 

 

MUC Creation is

 

 

     MultiUserChatManager mchatManager = MultiUserChatManager.getInstanceFor(xmpptcpConnection);

          MultiUserChat mchat = mchatManager.getMultiUserChat(group);

          if (!mchat.isJoined()) {

            Log.d("CONNECT", "Joining room !! " + group + " and username " + username);

            boolean createNow = false;

            try {

              mchat.createOrJoin(username);

              createNow = true;

            } catch (Exception e) {

              Log.d("CONNECT", "Error while creating the room " + group + e.getMessage());

            }

   

            if (createNow) {

   

              Form form = mchat.getConfigurationForm();

              Form submitForm = form.createAnswerForm();

   

              List<FormField> formFieldList = submitForm.getFields();

              for (FormField formField : formFieldList) {

                if(!FormField.Type.hidden.equals(formField.getType()) && formField.getVariable() != null) {

                  submitForm.setDefaultAnswer(formField.getVariable());

                }

              }

   

              submitForm.setAnswer("muc#roomconfig_persistentroom", true);

              submitForm.setAnswer("muc#roomconfig_publicroom", true);

   

              mchat.sendConfigurationForm(submitForm);

   

              //mchat.sendConfigurationForm(

              //    new Form(DataForm.Type.submit)); //this is to create the room immediately after join.

            }

          }

          Log.d("CONNECT", "Room created!!");

          return true;

        } catch (SmackException e) {

          e.printStackTrace();

        } catch (XMPPException.XMPPErrorException e) {

          e.printStackTrace();

        }


Viewing all articles
Browse latest Browse all 4596

Trending Articles