Esempio n. 1
0
        void RegChatp2pClient(string P2PUri)
        {
            try
            {
                NetPeerClient npcDummyChat = new NetPeerClient();
                objNetTcpChat = new clsNetTcpChat();
                ((clsNetTcpChat)objNetTcpChat).EntsvcJoin += new clsNetTcpChat.delsvcJoin(DummyClient_EntsvcJoin);
                //((clsNetTcpChat)objNetTcpChat).EntsvcSendMessage += new clsNetTcpChat.delsvcSendMessage(DummyClient_EntsvcSendMessage);
                //((clsNetTcpChat)objNetTcpChat).EntsvcGetUserList += new clsNetTcpChat.delsvcGetUserList(DummyClient_EntsvcGetUserList);
                //((clsNetTcpChat)objNetTcpChat).EntsvcSetUserList += new clsNetTcpChat.delsvcSetUserList(DummyClient_EntsvcSetUserList);
                //((clsNetTcpChat)objNetTcpChat).EntsvcSignOutChat += new clsNetTcpChat.delsvcSignOutChat(DummyClient_EntsvcSignOutChat);
                ((clsNetTcpChat)objNetTcpChat).EntsvcUnJoin += new clsNetTcpChat.delsvcUnJoin(DummyClient_EntsvcUnJoin);
                channelNettcpChat = (INetTcpChatChannel)npcDummyChat.OpenClient <INetTcpChatChannel>(P2PUri, P2PUri.ToString().Split(':')[2].Split('/')[2], ref objNetTcpChat);

                while (tempcounter < 20)
                {
                    try
                    {
                        channelNettcpChat.svcJoin(UserName);
                        tempcounter = 20;
                    }
                    catch
                    {
                        tempcounter++;
                        System.Threading.Thread.Sleep(1000);
                    }
                }
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "P2PChatp2pClient", "P2PChatClient.cs");
            }
        }
Esempio n. 2
0
        void RegChatp2pClient(string P2PUri)
        {
            try
            {
                NetPeerClient npcDummyChat = new NetPeerClient();
                objNetTcpChat = new clsNetTcpChat();
                ((clsNetTcpChat)objNetTcpChat).EntsvcJoin += new clsNetTcpChat.delsvcJoin(DummyClient_EntsvcJoin);
                //((clsNetTcpChat)objNetTcpChat).EntsvcSendMessage += new clsNetTcpChat.delsvcSendMessage(DummyClient_EntsvcSendMessage);
                //((clsNetTcpChat)objNetTcpChat).EntsvcGetUserList += new clsNetTcpChat.delsvcGetUserList(DummyClient_EntsvcGetUserList);
                //((clsNetTcpChat)objNetTcpChat).EntsvcSetUserList += new clsNetTcpChat.delsvcSetUserList(DummyClient_EntsvcSetUserList);
                //((clsNetTcpChat)objNetTcpChat).EntsvcSignOutChat += new clsNetTcpChat.delsvcSignOutChat(DummyClient_EntsvcSignOutChat);
                ((clsNetTcpChat)objNetTcpChat).EntsvcUnJoin += new clsNetTcpChat.delsvcUnJoin(DummyClient_EntsvcUnJoin);
                channelNettcpChat = (INetTcpChatChannel)npcDummyChat.OpenClient<INetTcpChatChannel>(P2PUri, P2PUri.ToString().Split(':')[2].Split('/')[2], ref objNetTcpChat);

                while (tempcounter < 20)
                {
                    try
                    {
                        channelNettcpChat.svcJoin(UserName);
                        tempcounter = 20;
                    }
                    catch
                    {
                        tempcounter++;
                        System.Threading.Thread.Sleep(1000);
                    }
                }
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "P2PChatp2pClient", "P2PChatClient.cs");
            }
        }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
        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");
            }
        }