public void HostDesktopService(object lstParams) { try { List<object> lstTempObj = (List<object>)lstParams; strUri = lstTempObj[1].ToString(); if ((VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.NodeWithNetP2P || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.BootStrap || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.SuperNode) { NetPeerClient npcDesktop = new NetPeerClient(); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcJoin += new clsNetTcpDesktop.delsvcJoin(ctlDesktop_Sharing_EntsvcJoin); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcSendMessage += new clsNetTcpDesktop.delsvcSendMessage(ctlDesktop_Sharing_EntsvcSendMessage); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcGetUserList += new clsNetTcpDesktop.delsvcGetUserList(ctlDesktop_Sharing_EntsvcGetUserList); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcSetUserList += new clsNetTcpDesktop.delsvcSetUserList(ctlDesktop_Sharing_EntsvcSetUserList); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcSelectedDesktop += new clsNetTcpDesktop.delsvcSelectedDesktop(ctlDesktop_Sharing_EntsvcSelectedDesktop); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcStopControl += new clsNetTcpDesktop.delsvcStopControl(ctlDesktop_Sharing_EntsvcStopControl); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcSendXY += new clsNetTcpDesktop.delsvcSendXY(ctlDesktop_Sharing_EntsvcSendXY); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcBtnDown += new clsNetTcpDesktop.delsvcBtnDown(ctlDesktop_Sharing_EntsvcBtnDown); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcBtnUp += new clsNetTcpDesktop.delsvcBtnUp(ctlDesktop_Sharing_EntsvcBtnUp); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcSendKey += new clsNetTcpDesktop.delsvcSendKey(ctlDesktop_Sharing_EntsvcSendKey); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcAllowView += new clsNetTcpDesktop.delsvcAllowView(ctlDesktop_Sharing_EntsvcAllowView); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcAllowControl += new clsNetTcpDesktop.delsvcAllowControl(ctlDesktop_Sharing_EntsvcAllowControl); ((clsNetTcpDesktop)objNetTcpDesktop).EntsvcUnJoin += new clsNetTcpDesktop.delsvcUnJoin(ctlDesktop_Sharing_EntsvcUnJoin); channelNetTcp = (INetTcpDesktopChannel)npcDesktop.OpenClient<INetTcpDesktopChannel>(strUri, strUri.ToString().Split(':')[2].Split('/')[2], ref objNetTcpDesktop); while (temp < 20) { try { #region MsgContract clsMessageContract objMsgContract = new clsMessageContract(); objMsgContract.strFrom = VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName; objMsgContract.stremImage = new MemoryStream(); #endregion MsgContract channelNetTcp.svcJoin(objMsgContract); temp = 20; #region MsgContract clsMessageContract objContractGetUserList = new clsMessageContract(); objContractGetUserList.stremImage = new MemoryStream(); objContractGetUserList.strFrom = VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName; objContractGetUserList.strType = "Get"; channelNetTcp.svcGetUserList(objContractGetUserList); #endregion MsgContract fncStartSendingImage(); } catch { temp++; System.Threading.Thread.Sleep(1000); } } } else { BasicHttpClient bhcDesktop = new BasicHttpClient(); bhcDesktop.NewBasicHttpBinding().TransferMode = TransferMode.Streamed; channelHttp = (IHttpDesktop)bhcDesktop.OpenClient<IHttpDesktop>(strUri); while (tempcounter < 20) { try { #region MsgContract clsMessageContract objMsgContract = new clsMessageContract(); objMsgContract.strFrom = VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName; objMsgContract.stremImage = new MemoryStream(); #endregion MsgContract channelHttp.svcJoin(objMsgContract); tempcounter = 20; #region MsgContract clsMessageContract objContractGetUserList = new clsMessageContract(); objContractGetUserList.stremImage = new MemoryStream(); objContractGetUserList.strFrom = VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName; objContractGetUserList.strType = "Get"; #endregion MsgContract channelHttp.svcGetUserList(objContractGetUserList); fncStartSendingImage(); } catch { tempcounter++; System.Threading.Thread.Sleep(1000); } } dispTimer.Interval = TimeSpan.FromSeconds(2); dispTimer.Tick += new EventHandler(dispTimer_Tick); dispTimer.Start(); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "HostDesktopService", "ctlDesktop_Sharing.xaml.cs"); } }
public void ClosePod() { try { if (dispTimer != null) { dispTimer.Stop(); } if (channelNetTcp != null && channelNetTcp.State == CommunicationState.Opened) { #region MsgContract clsMessageContract objContract = new clsMessageContract(); objContract.stremImage = new MemoryStream(); objContract.strFrom = VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName; #endregion MsgContract channelNetTcp.svcUnJoin(objContract); } else { #region MsgContract clsMessageContract objContract = new clsMessageContract(); objContract.stremImage = new MemoryStream(); objContract.strFrom = VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName; #endregion MsgContract channelHttp.svcUnJoin(objContract); channelHttp = null; } if (channelNetTcp != null) { channelNetTcp.Close(); channelNetTcp.Dispose(); channelNetTcp = null; } cnvDesktops.Children.Clear(); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "ClosePod", "ctlDesktop_Sharing.xaml.cs"); } }