爲了開發應用程序遠程桌面WP7,我開始使用桌面簡單的查看器,它的工作原理,但沒有顯示我在服務器端做的所有操作的問題,這是YouTube中的視頻可以告訴我我的問題 http://www.youtube.com/watch?v=3q-FumfYsPQ&feature=youtu.be桌面簡單查看器
我使用套接字連接和解碼和編碼我的數據(圖像)。
這是我在WP7客戶端
void Conncet(string IP_Address)
{
client_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs()
{
RemoteEndPoint = new IPEndPoint(IPAddress.Parse(IP_Address), 4532)
};
socketEventArg.Completed += OnConncetCompleted;
client_socket.ConnectAsync(socketEventArg);
}
void StartReceiving()
{
byte[] response = new byte[131072];
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.Completed += OnReceiveCompleted;
socketEventArg.SetBuffer(response, 0, response.Length);
client_socket.ReceiveAsync(socketEventArg);
}
private void ViewReceivedImage(byte[] buffer)
{
try
{
MemoryStream ms = new MemoryStream(buffer);
BitmapImage bi = new BitmapImage();
bi.SetSource(ms);
MyImage.Source = bi;
ms.Close();
}
catch (Exception) { }
finally
{
StartReceiving();
}
}
這是我在服務器端代碼(PC)發送圖像的代碼。
void StartSending()
{
while (!stop)
try
{
Image oldimage = scr.Get_Resized_Image(wToCompare, hToCompare, scr.GetDesktopBitmapBytes());
//Thread.Sleep(1);
Image newimage = scr.Get_Resized_Image(wToCompare, hToCompare, scr.GetDesktopBitmapBytes());
byte[] buffer = scr.GetDesktop_ResizedBytes(wToSend, hToSend);
float difference = scr.difference(newimage, oldimage);
if (difference >= 1)
{
SenderSocket.Send(buffer);
}
}
catch (Exception) { }
}
我的問題是如何使發送和接收速度快,顯示在+/-實時WP7的電腦屏幕。
我會添加大量'日誌'代碼,以查看哪些步驟緩慢,哪些方面發生緩慢。這可能是目前情況下的瓶頸只是WP7設備不能足夠快地顯示圖像。 – CodingBarfield 2012-02-24 08:42:24
這個問題我怎麼能加快? 我在機器中使用它,其結果是相同的2機器, 我也在不同的網絡中使用它,並讓我看到相同的視圖 – juste3alfaza 2012-02-24 09:24:14