public void ClosePod() { try { //call unjoin method if (channelNetTcp != null) { channelNetTcp.svcSignOutChat(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, lstName); } else if (channelHttp != null) { channelHttp.svcSignOutChat(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, lstName); } if (channelNetTcp != null) { channelNetTcp.Close(); channelNetTcp.Dispose(); channelNetTcp = null; } if (channelHttp != null) { channelHttp = null; } if (dispTimer != null) { dispTimer.Stop(); } Dispose(); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "ClosePod()", "ctlChat.xaml.cs"); } }
public void hostchatservice(object lstParams) { List<object> lstTempObj = (List<object>)lstParams; strUri = lstTempObj[1].ToString(); try { if ((VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.NodeWithNetP2P || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.BootStrap || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.SuperNode) { NetPeerClient npcChat = new NetPeerClient(); ((clsNetTcpChat)objNetTcpChat).EntsvcJoin += new clsNetTcpChat.delsvcJoin(wndChat_EntsvcJoin); ((clsNetTcpChat)objNetTcpChat).EntsvcSendMessage += new clsNetTcpChat.delsvcSendMessage(wndChat_EntsvcSendMessage); ((clsNetTcpChat)objNetTcpChat).EntsvcGetUserList += new clsNetTcpChat.delsvcGetUserList(ctlChat_EntsvcGetUserList); ((clsNetTcpChat)objNetTcpChat).EntsvcSetUserList += new clsNetTcpChat.delsvcSetUserList(ctlChat_EntsvcSetUserList); ((clsNetTcpChat)objNetTcpChat).EntsvcSignOutChat += new clsNetTcpChat.delsvcSignOutChat(ctlChat_EntsvcSignOutChat); ((clsNetTcpChat)objNetTcpChat).EntsvcUnJoin += new clsNetTcpChat.delsvcUnJoin(wndChat_EntsvcUnJoin); ((clsNetTcpChat)objNetTcpChat).EntsvcShowStatus += new clsNetTcpChat.delsvcShowStatus(ctlChat_EntsvcShowStatus); channelNetTcp = (INetTcpChatChannel)npcChat.OpenClient<INetTcpChatChannel>(strUri, strUri.ToString().Split(':')[2].Split('/')[2], ref objNetTcpChat); while (temp < 20) { try { channelNetTcp.svcJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); temp = 20; channelNetTcp.svcGetUserList(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); } catch { temp++; System.Threading.Thread.Sleep(1000); } } //ClsException.WriteToLogFile("Chat Module:Opened Chat P2P Client"); //ClsException.WriteToLogFile("Uri for opening the client is : " + strUri); //ClsException.WriteToLogFile("MeshId for opening the client is : " + strUri.ToString().Split(':')[2].Split('/')[1]); } else { BasicHttpClient bhcChat = new BasicHttpClient(); channelHttp = (IHttpChat)bhcChat.OpenClient<IHttpChat>(strUri); while (tempcounter < 20) { try { channelHttp.svcJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); tempcounter = 20; channelHttp.svcGetUserList(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); txtChat.IsEnabled = true; } catch { tempcounter++; System.Threading.Thread.Sleep(1000); } } dispTimer.Interval = TimeSpan.FromSeconds(2); dispTimer.Tick += new EventHandler(dispTimer_Tick); dispTimer.Start(); //ClsException.WriteToLogFile("chat module: Opened Http Chat Client with Timers"); //ClsException.WriteToLogFile("Uri for opening the client is : " + strUri); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "hostchatservice()", "ctlChat.xaml.cs"); } }
void bgHostService_DoWork(object sender, DoWorkEventArgs e) { List<object> lstTempObj = (List<object>)e.Argument; strUri = lstTempObj[1].ToString(); try { if ((VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.NodeWithNetP2P || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.BootStrap || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.SuperNode) { NetPeerClient npcChat = new NetPeerClient(); ((clsNetTcpChat)objNetTcpChat).EntsvcJoin += new clsNetTcpChat.delsvcJoin(wndChat_EntsvcJoin); ((clsNetTcpChat)objNetTcpChat).EntsvcSendMessage += new clsNetTcpChat.delsvcSendMessage(wndChat_EntsvcSendMessage); ((clsNetTcpChat)objNetTcpChat).EntsvcGetUserList += new clsNetTcpChat.delsvcGetUserList(ctlChat_EntsvcGetUserList); ((clsNetTcpChat)objNetTcpChat).EntsvcSetUserList += new clsNetTcpChat.delsvcSetUserList(ctlChat_EntsvcSetUserList); ((clsNetTcpChat)objNetTcpChat).EntsvcSignOutChat += new clsNetTcpChat.delsvcSignOutChat(ctlChat_EntsvcSignOutChat); ((clsNetTcpChat)objNetTcpChat).EntsvcUnJoin += new clsNetTcpChat.delsvcUnJoin(wndChat_EntsvcUnJoin); ((clsNetTcpChat)objNetTcpChat).EntsvcShowStatus += new clsNetTcpChat.delsvcShowStatus(ctlChat_EntsvcShowStatus); channelNetTcp = (INetTcpChatChannel)npcChat.OpenClient<INetTcpChatChannel>(strUri, strUri.ToString().Split(':')[2].Split('/')[2], ref objNetTcpChat); while (temp < 20) { try { channelNetTcp.svcJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); temp = 20; channelNetTcp.svcGetUserList(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); } catch { temp++; System.Threading.Thread.Sleep(1000); } } } else { BasicHttpClient bhcChat = new BasicHttpClient(); channelHttp = (IHttpChat)bhcChat.OpenClient<IHttpChat>(strUri); while (tempcounter < 20) { try { channelHttp.svcJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); tempcounter = 20; channelHttp.svcGetUserList(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); txtChat.IsEnabled = true; } 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, "hostchatservice()", "ctlChat.xaml.cs"); } }
void Current_Exit(object sender, ExitEventArgs e) { try { if (dispTimer != null) { dispTimer.Stop(); } if (channelHttp != null) { channelHttp = null; } if (channelNetTcp != null && channelNetTcp.State == CommunicationState.Opened) { channelNetTcp = null; } VMuktiAPI.VMuktiHelper.UnRegisterEvent("SignOut"); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "Current_Exit", "ctlChat.xaml.cs"); } }
public void Dispose() { try { //ClsException.WriteToLogFile("Dispose of chat called"); if (channelHttp != null) { channelHttp = null; } if (channelNetTcp != null) { channelNetTcp.Close(); channelNetTcp.Dispose(); channelNetTcp = null; } GC.Collect(); GC.WaitForPendingFinalizers(); //ClsException.WriteToLogFile("Uri is : " + strUri); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "Dispose()", "ctlChat.xaml.cs"); } }