涉及到的内容有:MCapture桌面图片采集,supersocket等。server端使用到了winfrom的flowLayoutPanel的布局控件,因为要将多个客户端显示在服务端,每个客户端的布局控件由panel,picturebox和textbox组成。
客户端:
桌面采集:
//桌面图片采集
private void getcapturer()
{
this.capturer = CapturerFactory.CreateDesktopCapturer(40, false);
((IDesktopCapturer)this.capturer).ZoomSize = new Size(1067, 600);
((IDesktopCapturer)this.capturer).ImageCaptured += new ESBasic.CbGeneric<Bitmap>(Form1_ImageCaptured);
this.capturer.Start();
if (serverIP != null || serverIP != "")
{
getSocekt();
}
}
void Form1_ImageCaptured(Bitmap img)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new ESBasic.CbGeneric<Bitmap>(this.Form1_ImageCaptured), img);
}
else
{
sendByte(img);
Thread.Sleep(10);
}
}
客户端socket:普通的socket也可以,当前使用的是supersocket中的客户端连接。
AsyncTcpSession tcpClient = null;
private void getSocekt()
{
try
{
Thread.Sleep(1000);
tcpClient = new AsyncTcpSession(new IPEndPoint(IPAddress.Parse(serverIP), int.Parse(PORT)));
tcpClient.Connect();
getTcpClient(tcpClient);
}
catch
{
getSocekt();
}
}
private void getTcpClient(AsyncTcpSession tcpClient)
{
if (tcpClient != null)
{
tcpClient.DataReceived += TcpClient_DataReceived;
tcpClient.Error += TcpClient_Error;
tcpClient.Closed += TcpClient_Closed;
}
}
/// <summary>
/// 客户端断开连接
/// </su