Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
hardmanii #1
Member since Apr 2011 · 20 posts · Location: seoul
Group memberships: Members
Show profile · Link to this post
Subject: How do I implement a group chat?
Hi.

How do I implement a group chat?
Do you have sample source implementation of a group chat?
Answer me please.

how to send Message ?

var msg = new Message { Type = MessageType.chat, To = _Jid, Body = msgBody  };

var msg = new Message { Type = MessageType.groupchat, To = _Jid, Body = msgBody }; ????

i want to make 3 people chat room .


Have a nice day~
thanks.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by hardmanii:
How do I implement a group chat?
Do you have sample source implementation of a group chat?
The following Silverlight groupchat example is included in the Silverlight download.
The API is exactly the same for the full .NET version.
http://matrix.ag-software.de/silverlight_muc.html

Quote by hardmanii:
var msg = new Message { Type = MessageType.groupchat, To = _Jid, Body = msgBody }; ????
this is correct. The To attribute is the Jid of the chatroom.

Alex
Avatar
hardmanii #3
Member since Apr 2011 · 20 posts · Location: seoul
Group memberships: Members
Show profile · Link to this post
Subject: good! but.
Thank you! alex!

my source code :

public ChatForm(XmppClient xmppClient, Jid jid, string nickName, Login login)
        {
            this._XmppClient = xmppClient;
            this._Jid = jid;
            this._NickName = nickName;
            this._Login = login;
            this.CommitInComingMessage = false;

            InitializeComponent();

            // source code add. 2 line
            this._MucManager = new MucManager(_XmppClient);
            _MucManager.EnterRoom(_Jid, _NickName, true);


            // MessageFilter
            Util.ChatForms.Add(_Jid.Bare.ToLower(), this);
            xmppClient.MessageFilter.Add(jid, new BareJidComparer(), OnMessage); << this source code remove?

            currentFont = rtfChat.SelectionFont;


            // file trans ..
            fm.XmppClient = _XmppClient;
            fm.OnFile += fm_OnFile;
            fm.OnError += fm_OnError;
            fm.OnEnd += fm_OnEnd;
            fm.OnStart += fm_OnStart;
            fm.OnProgress += fm_OnProgress;
        }




            Util.ChatForms.Add(_Jid.Bare.ToLower(), this);
            xmppClient.MessageFilter.Add(jid, new BareJidComparer(), OnMessage);    << this source code remove?


3 people chat room talk about ... but new chat room.

why? jid object?
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
sorry, but I don't understand what you are saying.

mucManager.EnterRoom brings a user in an existing room, or creates the room when it does not exist.

You probably want to create a new instant room for your 3 users, then do a:
mucManager.RequestInstantRoom() after you created a new room with EnterRoom.

Then the other 2 users can join the room after its ready.

Alex
Avatar
ahoffman #5
Member since May 2011 · 10 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex!

I also want to do this, to basically use the very basic example that you have on your asgXMPP homepage, but instead of sending the message to a singleton, instead send it to a chatroom/chatgroup.

It sounds like I need to login to the xmpp server, then OnLogin, create a mucManager then EnterRoom or RequestInstantRoom()

Question: what is the difference between EnterRoom(when the room doesn't exists), and RequestInstantRoom()?
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
for agsXMPP please look at the MiniClient example, it has also group chat functionality.

Alex
Avatar
ahoffman #7
Member since May 2011 · 10 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex!

Got a question for you when you have the time.
I now know how to manage a connection to a server to maintain connections with the different connection states and things.
Is there anything like that for a muc?
There is OnPresence for detecting when you're successfully connected to a room, but what about when you're rejected/banned/timed out/room doesn't exist?
Do these cases trigger one of the error triggers?

Any help is much appreciated!
Avatar
Alex #8
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you get all this info in OnPresence. Eg. when you get banned then you and all other occupats get a presence which looks like the following:

  1. <presence
  2.    from='harfleur@henryv.shakespeare.lit/pistol'
  3.    to='pistol@shakespeare.lit/harfleur'
  4.    type='unavailable'>
  5.  <x xmlns='http://jabber.org/protocol/muc#user'>
  6.     <item affiliation='none' role='none'>
  7.       <actor jid='fluellen@shakespeare.lit'/>
  8.       <reason>Avaunt, you cullion!</reason>
  9.     </item>
  10.     <status code='307'/>
  11.  </x>
  12. </presence>

I suggest to check the status code of the presence packet. The current status codes are described here:
http://xmpp.org/extensions/xep-0045.html#registrar-statusc…

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: