c# 实现多个客户端桌面截取共享到服务端软件制作

该博客介绍了如何使用C#来创建一个允许多个客户端进行桌面截图并共享到服务端的软件。客户端利用MCapture进行桌面图片采集,通过SuperSocket进行通信。服务端采用Supersocket处理客户端连接,防止粘包和消息丢失。目前面临的问题是由于截图和发送操作导致CPU占用率过高,作者希望得到改进方案。
摘要由CSDN通过智能技术生成

涉及到的内容有: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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值