Beispiel #1
0
        private void menuMainProgramTest_Click(object sender, EventArgs e)
        {
            string        chatMessageData = "<body><message xmlns=\"jabber:client\" type=\"groupchat\" from=\"[email protected]/masterast\" to=\"[email protected]/xiff-bosh\" id=\"m_466\"><body>Tool|230|Marble|100</body><bbmsg xmlns=\"bbmsg\" playerid=\"1033067\" playername=\"Masterast\" playertag=\"\"/></message></body>";
            DsoChatPacket chatPacket      = DsoChatPacket.Parse(chatMessageData);

            AddPacket(chatPacket);
        }
Beispiel #2
0
        private void mWorkingThread_DoWork(object sender, DoWorkEventArgs e)
        {
            PacketDevice packetDevice = (PacketDevice)e.Argument;

            // Open the device
            PacketCommunicator communicator = packetDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous | PacketDeviceOpenAttributes.NoCaptureLocal | PacketDeviceOpenAttributes.MaximumResponsiveness, 30000);

            communicator.SetFilter("net (87.119.203.0/24 or 94.236.0.0/16 or 31.222.148.0/24) and port 80");
            Debug.WriteLine("Worker listening on " + packetDevice.Description + "...");

            // Retrieve the packets
            Packet        packet;
            DsoChatPacket chatPacket = null;

            do
            {
                // Thread should exit/cancel work
                if (mWorkingThread.CancellationPending == true)
                {
                    communicator.Break();
                    break;
                }

                // Pause?
                if (mPauseCapture)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                // Wait for next packet
                PacketCommunicatorReceiveResult result = communicator.ReceivePacket(out packet);
                switch (result)
                {
                case PacketCommunicatorReceiveResult.Timeout:
                    continue;

                case PacketCommunicatorReceiveResult.Ok:
                    if (packet.Buffer != null && packet.Length > 0)
                    {
                        chatPacket = DsoChatPacket.Parse(packet.Buffer);
                        if (chatPacket == null || chatPacket.Messages.Count == 0)
                        {
                            // Failed to parse
                            mWorkingThread.ReportProgress(0);
                        }
                        else
                        {
                            mWorkingThread.ReportProgress(0, chatPacket.Clone());
                        }
                    }

                    break;

                default:
                    throw new InvalidOperationException("The result " + result + " should never be reached here");
                }
            } while (true);

            // Set result object to handle "Cancel" correctly
            e.Result = true;
        }
Beispiel #3
0
 public static void Main(string[] args)
 {
     string        xml    = "<body xmlns='http://jabber.org/protocol/httpbind'><message xmlns=\"jabber:client\" type=\"groupchat\" from=\"[email protected]/monika5\" id=\"m_45\" to=\"[email protected]/xiff-bosh\"><body>Plank|200|Coin|50</body><bbmsg xmlns=\"bbmsg\" playername=\"monika5\" playerid=\"1003212\" playertag=\"\"/></message><message xmlns=\"jabber:client\" type=\"groupchat\" to=\"[email protected]/xiff-bosh\" from=\"[email protected]/warkanoid\" id=\"m_295\"><body>GEILO!!</body></body><bbmsg xmlns=\"bbmsg\" playername=\"Warkanoid\" playertag=\"\" playerid=\"1096507\"/></message><presence xmlns=\"jabber:client\" to=\"[email protected]/xiff-bosh\" from=\"[email protected]/thorhaus\" type=\"unavailable\"><priority>0</priority><x xmlns=\"http://jabber.org/protocol/muc#user\"><item affiliation=\"none\" role=\"none\"/></x></presence><message xmlns=\"jabber:client\" id=\"m_1740\" from=\"[email protected]/maniac83\" to=\"[email protected]/xiff-bosh\" type=\"groupchat\"><body>guter mann:)</body><bbmsg xmlns=\"bbmsg\" playertag=\"\" playerid=\"1046129\" playername=\"Maniac83\"/></message></body>";
     DsoChatPacket packet = DsoChatPacket.Parse(Encoding.UTF8.GetBytes(xml));
 }