Example #1
0
        private void IQLost(object sender, TimeoutEventArgs e)
        {
            var iq      = (IQ)e.Data;
            var session = sessionManager.GetSession(iq.From);

            if (session != null)
            {
                xmppSender.SendTo(session, XmppStanzaError.ToServiceUnavailable(iq));
            }
        }
        private void IQLost(object sender, TimeoutEventArgs e)
        {
            var iq      = (IQ)e.Data;
            var session = sessionManager.GetSession(iq.From);

            if (session != null)
            {
                // iChat bug
                if (iq.Id == null || iq.Id.IndexOf("ichat", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    xmppSender.SendTo(session, XmppStanzaError.ToServiceUnavailable(iq));
                }
                else
                {
                    xmppSender.SendTo(session, ToResult(iq));
                }
            }
        }
Example #3
0
        public override void HandlePresence(XmppStream stream, Presence presence, XmppHandlerContext context)
        {
            var session = sessionManager.GetSession(presence.From);

            if (session == null)
            {
                context.Sender.SendTo(stream, XmppStanzaError.ToNotFound(presence));
                return;
            }

            if (presence.Type == PresenceType.available || presence.Type == PresenceType.invisible || presence.Type == PresenceType.unavailable)
            {
                sessionManager.SetSessionPresence(session, presence);
            }

            if (presence.HasTo && presence.To.ToString() != stream.Domain)
            {
                HandlePresence(presence, session);                //Presence to one of contacts
            }
            else
            {
                BroadcastPresence(presence);
            }
        }
 private XmppSession GetSession(IXmppConnection connection)
 {
     Args.NotNull(connection, "endpoint");
     return(sessionManager.GetSession(connection.SessionId) ?? new XmppSession(connection));
 }