void clientOut_OnReveive(ServerSocket sender, string key) { if (key.Length >= 2) { if (key.Substring(0, 1).Equals("x")) { string[] coordinates = key.Split('y'); coordinates[0] = coordinates[0].Remove(0,1); int coordX = Int16.Parse(coordinates[0]); int coordY = Int16.Parse(coordinates[1]); mouse.Move(coordX, coordY); } else if ((key.Substring(0, 3).Equals("ml0")) || (key.Substring(0, 3).Equals("mr0"))) { mouse.MouseClickControl(key); } else { keyboard.KeyboardExtraControl(key); } } else { keyboard.KeyboardControl(key); } receiveDoneOut.Set(); }
void clientIn_OnReveive(ServerSocket sender, string msg1) { msg = msg1; if (msg == "Next") { receiveDoneIn.Set(); } else if (msg == "Close") { serverIn.Close(); serverOut.Close(); serverIn = null; serverOut = null; Invoke((MethodInvoker)delegate { listBox1.Items.Add("Client disconnected !!!"); }); } }
void clientIn_OnSend(ServerSocket sender, int sent) { Invoke((MethodInvoker)delegate { label6.Text = string.Format("Data sent: {0} B = {1} kB", sent, (sent/1024)); }); }
void listenerOut_Accepted(Socket e) { if (serverOut != null) { e.Close(); return; } serverOut = new ServerSocket(e); serverOut.onReceive += new ServerSocket.ReceiveEventHandler(clientOut_OnReveive); Invoke((MethodInvoker)delegate { listBox1.Items.Add("Connected: " + serverOut.endPoint.ToString() + " (SocketOut)"); }); while(serverOut.connected) { serverOut.ReceiveKeyboardAndMouseMessage(); receiveDoneOut.WaitOne(); } }
void listenerIn_Accepted(Socket e) { if (serverIn != null) { e.Close(); return; } serverIn = new ServerSocket(e); serverIn.onSend += new ServerSocket.SendEventHandler(clientIn_OnSend); serverIn.onReceive += new ServerSocket.ReceiveEventHandler(clientIn_OnReveive); Invoke((MethodInvoker)delegate { listBox1.Items.Add("Connected: " + serverIn.endPoint.ToString() + " (SocketIn)"); }); do { msg = ""; obraz = makeScreenShot(true); SendImage(obraz); serverIn.ReceiveMessage(); receiveDoneIn.WaitOne(); } while(serverIn.connected); }
private void button2_Click(object sender, EventArgs e) { if (serverIn != null) { serverIn.Close(); serverIn = null; } if (serverOut != null) { serverOut.Close(); serverOut = null; } listBox1.Items.Add("Stop listening or client disconnected !!!"); button1.Enabled = true; button2.Enabled = false; listenerIn.Stop(); listenerOut.Stop(); }