Exemple #1
0
        void AppClient_PacketReceived(PacketReceivedArgs e)
        {
            Connection REQ = PacketBuilder.GetConnectionContentFormByte(e.Packet.Content, e.Packet.ContentEncoding);

            if (REQ.Method == "GIVE")
            {
                if (REQ.DataType == ConnectionDataType.IMAGE)
                {
                    if (REQ.Content == "kk8dc2UJYJ4")
                    {
                        Sender.SendTakeImage(CLIENT.Properties.Resources.kk8dc2UJYJ4, e.Packet.SourceAdress, ".", e.Packet.SessionID);
                    }
                    else
                    {
                    }
                }
                else
                {
                }
            }
            else if (REQ.Method == "READ")
            {
                MessageBox.Show(REQ.PROCESS + " SAID : " + REQ.Content, this.Text);
                Sender.SendAnswer(REQ.Content + " THANK YOU", e.Packet.SourceAdress, ".", e.Packet.SessionID);
            }
            else if (REQ.Method == "PROCESS")
            {
                string replace = REQ.Content.Replace("<shit>", " ");
                MessageBox.Show("Processed " + " : " + replace, this.Text);
                Sender.SendRProcess(replace, e.Packet.SourceAdress, ".", e.Packet.SessionID);
            }
            else
            {
            }
        }
Exemple #2
0
        void AppClient_PacketReceived(PacketReceivedArgs e)
        {
            Connection REQ = PacketBuilder.GetConnectionContentFormByte(e.Packet.Content, e.Packet.ContentEncoding);

            if (REQ.Method == "TAKE")
            {
                if (REQ.DataType == ConnectionDataType.IMAGE)
                {
                    pictureBox1.Image = Sender.byteArrayToImage(Security.BFromBase64(REQ.Content, e.Packet.ContentEncoding));
                    Sender.SetSID(e.Packet.SessionID, SessionState.OK);
                }
                else
                {
                }
            }
            else if (REQ.Method == "ANSWER")
            {
                MessageBox.Show(REQ.Content, this.Text);
                Sender.SetSID(e.Packet.SessionID, SessionState.OK);
            }
            else if (REQ.Method == "RPROCESS")
            {
                MessageBox.Show("DATA PROCESSED : " + REQ.Content, this.Text);
                Sender.SetSID(e.Packet.SessionID, SessionState.OK);
            }
            else
            {
            }
        }
Exemple #3
0
        private void onPacketReceived(object sender, PacketReceivedArgs packetReceivedArgs)
        {
            IPacket packet = packetReceivedArgs.Packet;

            if (packet is LCAuthenticationResponse)
            {
                LCAuthenticationResponse response = (LCAuthenticationResponse)packet;
                switch (response.Result)
                {
                case AuthenticationResult.BAD_USERNAME:
                    loginStatusBox.Text = "Username not found!";
                    authenticating      = false;
                    break;

                case AuthenticationResult.BAD_PASSWORD:
                    loginStatusBox.Text = "Password not correct!";
                    authenticating      = false;
                    break;

                case AuthenticationResult.SUCCESS:
                    loginStatusBox.Text = "Success!";
                    break;
                }
            }
        }
Exemple #4
0
        static void AppClient_PacketReceived(PacketReceivedArgs e)
        {
            Connection REQ = PacketBuilder.GetConnectionContentFormByte(e.Packet.Content, e.Packet.ContentEncoding);

            if (REQ.Method == IPDTPRules.AnswerMethod)
            {
                Console.WriteLine("Received from " + e.Packet.SourceAdress + " data: " + REQ.Content + " Session Id " + e.Packet.SessionID);
                Sender.SendResponse("ECHO " + REQ.Content, e.Packet.SourceAdress, ".", e.Packet.SessionID);
            }
            else if (REQ.Method == "RESPONSE")
            {
                Console.WriteLine("Received from " + e.Packet.SourceAdress + " data: " + REQ.Content);
            }
        }
 private void OnPacketReceived(Packet packet, int size)
 {
     if ((this.ConnectionFlags & CryptoConnectionFlags.ManualRead) == CryptoConnectionFlags.ManualRead)
     {
         PacketWithSize pws = new PacketWithSize {
             Packet = packet, Size = size
         };
         while (packetQueue.Count >= maxQueueSize) // Choking
         {
             Thread.Sleep(10);
         }
         this.packetQueue.Enqueue(pws);
     }
     else
     {
         PacketReceivedArgs args = new PacketReceivedArgs {
             P = packet, S = size, D = this.PacketReceived
         };
         if (this.PacketReceived != null)
         {
             this.context.Post(new SendOrPostCallback((o) =>
             {
                 PacketReceivedArgs a = (PacketReceivedArgs)o;
                 a.D.Invoke(a.P, a.S);
             }), args);
         }
         else
         {
             while (this.queuedEvents.Count >= maxQueueSize) // Choking
             {
                 Thread.Sleep(10);
             }
             this.queuedEvents.Enqueue(args);
         }
     }
 }
Exemple #6
0
        private void Socket_PacketReceived(object sender, PacketReceivedArgs e)
        {
            SACNPacket packet = SACNPacket.Parse(e.Packet);

            OnReceive?.Invoke(this, new PacketReceivedEventArgs(packet));
        }