public ChatClient() { _roster = new Dictionary <string, Contact>(); var xmppClientConnection = new XmppClientConnection(0) { AutoAgents = false, AutoPresence = true, AutoResolveConnectServer = false, AutoRoster = true, KeepAlive = true, Priority = 50, Resource = "xiff", UseSSL = true }; _connection = xmppClientConnection; _connection.OnRosterStart += ConnectiOnRosterStart; _connection.OnRosterEnd += ConnectiOnRosterEnd; _connection.OnRosterItem += ConnectiOnRosterItem; _connection.OnPresence += ConnectiOnPresence; _connection.OnMessage += ConnectiOnMessage; _connection.OnLogin += ConnectiOnLogin; _connection.OnClose += ConnectiOnClose; _connection.OnAuthError += ConnectiOnAuthError; _connection.OnError += ConnectiOnError; _connection.OnXmppConnectionStateChanged += ConnectiOnXmppConnectionStateChanged; SightstoneChat = new Chat(_connection); SightstoneMuc = new Muc(_connection); SightstoneContacts = new Contacts(_connection); SightstonePresence = new Presence(_connection); ConferenceServers = new List <string>(); }
/// <summary> /// /// </summary> /// <param name="file"></param> /// <returns></returns> public virtual IEnumerable <Tone> ImportToneFile(string file) { string ext = System.IO.Path.GetExtension(file); var Option = new Option(); IEnumerable <Tone> tones = null; try { string[] importFile = { file.ToLower(CultureInfo.InvariantCulture) }; switch (ext.ToUpper(CultureInfo.InvariantCulture)) { case ".MUC": tones = Muc.Reader(importFile, Option); break; case ".DAT": tones = Dat.Reader(importFile, Option); break; case ".MWI": tones = Fmp.Reader(importFile, Option); break; case ".MML": tones = Pmd.Reader(importFile, Option); break; case ".FXB": tones = Vopm.Reader(importFile, Option); break; case ".GWI": tones = Gwi.Reader(importFile, Option); break; case ".BNK": tones = BankReader.Read(file); break; case ".SYX": tones = SyxReaderTX81Z.Read(file); break; } } catch (Exception ex) { if (ex.GetType() == typeof(Exception)) { throw; } else if (ex.GetType() == typeof(SystemException)) { throw; } MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message); } return(tones); }
/// <summary> /// Join a Multi-user room /// </summary> /// <param name="room">room data object</param> /// <param name="loadAllHistory">request all history from server (10000 stanzas max)</param> public void joinRoom(Roomdata room, bool loadAllHistory = false) { // Program.db.SetOnlineStatus(room.RoomName, "off"); /// Setup Room agsXMPP.protocol.client.Presence MUCpresence = new Presence(); //MUCpresence.From = jabber.conn.MyJID; MUCpresence.To = room.jid; var xMuc = new Muc(); MUCpresence.AddChild(xMuc); //if (glob.para("notifications__" + roomJid.Bare) == "FALSE") xMuc.SetTag("show", "away"); if (room.Notify != Roomdata.NotifyMode.Always) { xMuc.SetTag("show", "away"); } agsXMPP.protocol.x.muc.History historyChild = new History(100); try { string since = room.LastMessageDt; //logs.GetLastmessageDatetime(room.jid.Bare); if (!String.IsNullOrEmpty(since)) { historyChild.RemoveAttribute("maxstanzas"); historyChild.SetAttribute("since", since); //addNoticeToView("Requesting since " + since); } } catch (Exception e) { } if (loadAllHistory) { historyChild = new History(10000); } xMuc.AddChild(historyChild); //MUCpresence.SetAttribute("type", "groupchat"); Console.WriteLine("-> " + MUCpresence.ToString()); Program.Jabber.conn.Send(MUCpresence); }
public static History GetHistroy(Presence presence) { Muc muc = GetMuc(presence); return(muc != null ? muc.History : null); }
/// <summary> /// </summary> /// <param name="presence"> /// </param> /// <returns> /// </returns> public static string GetPassword(Presence presence) { Muc muc = GetMuc(presence); return(muc != null ? muc.Password : null); }
/// <summary> /// Join a chatroom /// </summary> /// <param name="room"> /// jid of the room to join /// </param> /// <param name="nickname"> /// nickname to use in the room /// </param> /// <param name="password"> /// password for password protected chat rooms /// </param> /// <param name="disableHistory"> /// true for joining without chat room history /// </param> public void JoinRoom(Jid room, string nickname, string password, bool disableHistory) { /* <presence from='[email protected]/pda' to='[email protected]/thirdwitch'> <x xmlns='http://jabber.org/protocol/muc'> <password>cauldron</password> </x> </presence> join room and request no history <presence from='[email protected]/pda' to='[email protected]/thirdwitch'> <x xmlns='http://jabber.org/protocol/muc'> <history maxchars='0'/> </x> </presence> */ Jid to = new Jid(room.ToString()); to.Resource = nickname; Presence pres = new Presence(); pres.To = to; Muc x = new Muc(); if (password != null) { x.Password = password; } if (disableHistory) { History hist = new History(); hist.MaxCharacters = 0; x.History = hist; } pres.AddChild(x); m_connection.Send(pres); }