void CheckForPresence(XElement Doc) { XElement presence = Doc.Name.LocalName == "presence" ? Doc : null; if (presence == null) { return; } if (OnPresence != null) { OnPresence.Invoke(presence); } }
public override void StreamParserOnStreamElement(object sender, Node e) { base.StreamParserOnStreamElement(sender, e); if (e is Handshake) { this.m_Authenticated = true; OnLogin?.Invoke(this); if (this.KeepAlive) { this.CreateKeepAliveTimer(); } } else if (e is Route) { OnRoute?.Invoke(this, e as Route); } else if (e is Protocol.XmppStreamError) { var streamErr = e as Protocol.XmppStreamError; switch (streamErr.Condition) { // Auth errors are important for the users here, so throw catch auth errors // in a separate event here case Protocol.XmppStreamErrorCondition.NotAuthorized: // Authentication Error OnAuthError?.Invoke(this, e as Element); break; default: OnStreamError?.Invoke(this, e as Element); break; } } else if (e is Message) { OnMessage?.Invoke(this, e as Message); } else if (e is Presence) { OnPresence?.Invoke(this, e as Presence); } else if (e is IQ) { OnIq?.Invoke(this, e as IQ); } }