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(); } }
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); }
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); }
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()); } } }
private void Send(string msg) { using (var cpc = new ClientPipeConnection("JanusPipe")) { cpc.Connect(); cpc.Write(msg); } }
private static void WriteToPipe(string str) { using (var cpc = new ClientPipeConnection(_pipeName)) try { cpc.Connect(); cpc.Write(str); } //{{{-EmptyGeneralCatchClause catch //{{{+EmptyGeneralCatchClause {} }
public void SendRequest <T>(pipeMessageData <T> request) { try { using (IInterProcessConnection clientConnection = new ClientPipeConnection(pipeName, ".")) { clientConnection.Connect(); clientConnection.Write(JsonConvert.SerializeObject(request)); } } catch (Exception ex) { } }
public Resource GetData(string uri) { using (var cpc = new ClientPipeConnection(_pipeName)) try { cpc.Connect(); cpc.Write("<protocol-request><path>" + uri + "</path></protocol-request>"); return(Resource.Unpack(cpc.ReadBytes())); } catch (Exception e) { return(new Resource(MediaTypeNames.Text.Html, "<html><h3>Ошибка. Источник данных не обнаружен. Возможно RSDN@Home не запущен." + "</h3><pre style='background-color: #EEEEEE'>" + e + "</pre></html>")); } }
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); }
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); }
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); }