public XmppClient(string url, string username, string password) { _url = url; _username = username; _password = password; Messanger = new Messanger(); }
private void RemakeXmpp() { if (Xmpp != null) { Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged; Xmpp.Close(); Xmpp = null; } Xmpp = new XmppClientConnection(_url); //ElementFactory.AddElementType("hostgamerequest", "octgn:hostgamerequest", typeof(HostGameRequest)); Xmpp.RegisterAccount = false; Xmpp.AutoAgents = true; Xmpp.AutoPresence = true; Xmpp.AutoRoster = true; Xmpp.Username = _username; Xmpp.Password = _password; Xmpp.Priority = 1; Xmpp.OnError += XmppOnOnError; Xmpp.OnAuthError += Xmpp_OnAuthError; Xmpp.OnStreamError += XmppOnOnStreamError; Xmpp.OnLogin += XmppOnLogin; Xmpp.KeepAlive = true; Xmpp.KeepAliveInterval = 60; Xmpp.OnAgentStart += XmppOnOnAgentStart; Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged; Xmpp.Open(); OnResetXmpp(); Messanger.OnResetXmpp(Xmpp); }
public virtual void Dispose() { if (Xmpp != null) { Xmpp.OnError -= XmppOnOnError; Xmpp.OnAuthError -= Xmpp_OnAuthError; Xmpp.OnStreamError -= XmppOnOnStreamError; Xmpp.OnAgentStart -= XmppOnOnAgentStart; Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged; Xmpp.OnLogin -= XmppOnLogin; try { Xmpp.Close(); } catch { } } if (Messanger != null) { Messanger.Dispose(); } }