Esempio n. 1
0
 private void button1_Click(object sender, System.EventArgs e)
 {
     if (textBox1.Text != "")
     {
         DateTime dt = DateTime.Now;
         // This cycle is used only when you want to run numerous name pipes requests
         // and measure the performance. In the general case it is not needed.
         for (int i = 0; i < 1; i++)
         {
             IInterProcessConnection clientConnection = null;
             try {
                 clientConnection = new ClientPipeConnection("MyPipe", ".");
                 clientConnection.Connect();
                 clientConnection.Write(textBox1.Text);
                 Activity.AppendText(clientConnection.Read() + Environment.NewLine);
                 clientConnection.Close();
             }
             catch (Exception ex) {
                 clientConnection.Dispose();
                 throw (ex);
             }
         }
         this.duration.Text = DateTime.Now.Subtract(dt).Milliseconds.ToString();
     }
 }
Esempio n. 2
0
        public static bool SendAccess(string file, string DestinationAdress, string destnetname)
        {
            string request = PacketBuilder.RequestBuilder(Process.GetCurrentProcess(), ConnectionDataType.STRING, "ACCESS", file);

            byte[] data   = ServerEncoding.GetBytes(request);
            int    sid    = sessions + 1;
            string packet = PacketBuilder.BuildPacket(AppClient.serverupl, DestinationAdress, "STRING", sid, Process.GetCurrentProcess().Id, Encryption, ServerEncoding, data, destnetname);

            if (packet != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    IInterProcessConnection clientConnection = null;
                    try
                    {
                        clientConnection = new ClientPipeConnection("upl://128.215.52", Networkname);
                        clientConnection.Connect();
                        clientConnection.Write(packet);

                        clientConnection.Close();
                        SetSID(sid, SessionState.WAITINGResponse);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        clientConnection.Dispose();
                        throw (ex);
                    }
                }
            }
            else
            {
            }
            return(false);
        }
Esempio n. 3
0
 public static bool SendMessage(string packet, string upl, string Networkname)
 {
     if (packet != "")
     {
         for (int i = 0; i < 1; i++)
         {
             IInterProcessConnection clientConnection = null;
             try
             {
                 clientConnection = new ClientPipeConnection(upl, Networkname);
                 clientConnection.Connect();
                 clientConnection.Write(packet);
                 IPDTPApplication.ChatHistory.Add(clientConnection.Read());
                 Log.LWrite("Packet Sent From Default Server (upl://128.215.52)" + " || To " + upl + " || In Machine (" + Networkname + ")");
                 clientConnection.Close();
                 return(true);
             }
             catch (Exception ex)
             {
                 clientConnection.Dispose();
                 throw (ex);
             }
         }
     }
     else
     {
     }
     return(false);
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            string key = "";

            while ((key = Console.ReadLine()) != "exit")
            {
                if (key != "")
                {
                    DateTime dt = DateTime.Now;
                    // This cycle is used only when you want to run numerous name pipes requests
                    // and measure the performance. In the general case it is not needed.
                    for (int i = 0; i < 1; i++)
                    {
                        IInterProcessConnection clientConnection = null;
                        try
                        {
                            clientConnection = new ClientPipeConnection("MyPipe", ".");
                            clientConnection.Connect();

                            clientConnection.Write(key);
                            Console.WriteLine(clientConnection.Read());
                            clientConnection.Close();
                        }
                        catch (Exception ex)
                        {
                            clientConnection.Dispose();
                            throw (ex);
                        }
                    }
                    Console.WriteLine(DateTime.Now.Subtract(dt).Milliseconds.ToString());
                }
            }
        }
Esempio n. 5
0
        public static bool SendTakeImage(Image img, string DestinationAdress, string destnetname, int sid)
        {
            // get the image base64 string

            byte[] imagebytes = imageToByteArray(img);

            string imageb64 = System.Convert.ToBase64String(imagebytes);

            // begin response
            string response = PacketBuilder.RequestBuilder(Process.GetCurrentProcess(), ConnectionDataType.IMAGE, "TAKE", imageb64);

            byte[] data = ServerEncoding.GetBytes(response);

            string packet = PacketBuilder.BuildPacket(AppClient.serverupl, DestinationAdress, "IMAGE", sid, Process.GetCurrentProcess().Id, Encryption, ServerEncoding, data, destnetname);

            if (packet != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    IInterProcessConnection clientConnection = null;
                    try
                    {
                        clientConnection = new ClientPipeConnection("upl://128.215.52", Networkname);
                        clientConnection.Connect();
                        clientConnection.Write(packet);

                        clientConnection.Close();
                        SetSID(sid, SessionState.OK);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        clientConnection.Dispose();
                        throw (ex);
                    }
                }
            }
            else
            {
            }
            return(false);
        }
Esempio n. 6
0
        static string connectSendMsg(string msg)
        {
            string retMsg = "";
            IInterProcessConnection clientConnection = null;

            try
            {
                clientConnection = new ClientPipeConnection(mXFSPipeName, ".");
                clientConnection.Connect();
                clientConnection.Write(msg);
                retMsg = clientConnection.Read() + "\n";
                clientConnection.Close();
            }
            catch (Exception ex)
            {
                clientConnection.Dispose();
                throw (ex);
            }
            return(retMsg);
        }
Esempio n. 7
0
        public static bool SendSET(Type type, string propertyname, object value, string DestinationAdress, string destnetname)
        {
            string content = type.ToString() + "|" + propertyname + "|" + value.ToString();
            string request = PacketBuilder.RequestBuilder(Process.GetCurrentProcess(), ConnectionDataType.VAR, "SET", content);

            byte[] data   = ServerEncoding.GetBytes(request);
            int    sid    = sessions + 1;
            string packet = PacketBuilder.BuildPacket(AppClient.serverupl, DestinationAdress, "VAR", sid, Process.GetCurrentProcess().Id, Encryption, ServerEncoding, data, destnetname);

            if (packet != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    IInterProcessConnection clientConnection = null;
                    try
                    {
                        clientConnection = new ClientPipeConnection("upl://128.215.52", Networkname);
                        clientConnection.Connect();
                        clientConnection.Write(packet);

                        clientConnection.Close();
                        SetSID(sid, SessionState.OK);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        clientConnection.Dispose();
                        throw (ex);
                    }
                }
            }
            else
            {
            }
            return(false);
        }