コード例 #1
0
        public void notify(Packet packet)
        {
            /* od Ch 7
             * if (packet.Session.Status != Session.SessionStatus.authenticated) {
             *  JabberServer.output.WriteLine("Dropping packet (no auth): " + packet.ToString());
             *  return;
             * } */
            String recipient = packet.To;

            if (recipient == null)   // to server
            {
                JabberServer.output.WriteLine("Dropping packet: " + packet.ToString());
                return;
            }

            if (recipient.Equals(JabberServer.server_name, StringComparison.OrdinalIgnoreCase))    // to server
            {
                JabberServer.output.WriteLine("Dropping packet: " + packet.ToString());
                return;
            }

            // Fill in sender as resource that sent message (anti-spoofing)
            packet.setFrom(packet.getSession().getJID().ToString());

            if (packet.getAttribute("type") != null && packet.getAttribute("type").Equals("groupchat", StringComparison.OrdinalIgnoreCase))
            {
                if (chatMan.isChatPacket(packet))
                {
                    chatMan.handleChatMessage(packet);
                }
                else
                {
                    JabberServer.output.WriteLine("Dropping packet: " + packet.ToString());
                }
                return;
            }

            JabberServer.output.WriteLine("Delivering packet To: " + packet.To);
            deliverPacket(packet);
        }