コード例 #1
0
        public bool Stop()
        {
            if (!IsRunning)
            {
                throw new ArgumentException("Remoting Server could not be stopped as it not running.");
            }
            switch (Connection.Protocol)
            {
            case RemotingProtocol.Ipc:
                channelTcp.StopListening(null);
                ChannelServices.UnregisterChannel(channelTcp);
                break;

            case RemotingProtocol.Tcp:
                channelTcp.StopListening(null);
                ChannelServices.UnregisterChannel(channelTcp);
                break;

            case RemotingProtocol.Http:
                channelHttp.StopListening(null);
                ChannelServices.UnregisterChannel(channelHttp);
                break;
            }
            return(true);
        }
コード例 #2
0
        public static void UnRegisterChannels()
        {
            IChannel[] channels = ChannelServices.RegisteredChannels;

            foreach (IChannel channel in channels)
            {
                if (channel.ChannelName.ToLower().IndexOf("http") >= 0) // http
                {
                    HttpChannel httpChannel = (HttpChannel)channel;

                    //Close listening

                    httpChannel.StopListening(null);

                    //Unregister channel

                    ChannelServices.UnregisterChannel(httpChannel);
                }

                if (channel.ChannelName.ToLower().IndexOf("tcp") >= 0) // tcp
                {
                    TcpChannel tcpChannel = (TcpChannel)channel;

                    //Close listening

                    tcpChannel.StopListening(null);

                    //Unregister channel

                    ChannelServices.UnregisterChannel(tcpChannel);
                }
            }
        }
コード例 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (button1.Text == "Connect")
     {
         _nick   = nick.Text;
         _port   = Int32.Parse(port.Text);
         channel = new TcpChannel(_port);
         RemotingServices.Marshal(_clientService, _nick, typeof(ClientService));
         ChannelServices.RegisterChannel(channel, false);
         service = (IServerServices)Activator.GetObject(typeof(IServerServices), "tcp://localhost:7777/MyService");
         service.registerClient(_nick, "tcp://localhost:" + _port + "/" + _nick);
         button1.Text = "Disconnect";
         appendMessage("-> Connected <-");
         nick.Enabled    = false;
         port.Enabled    = false;
         button2.Enabled = true;
         message.Enabled = true;
     }
     else
     {
         service.close(_nick);
         service      = null;
         button1.Text = "Connect";
         nick.Enabled = true;
         port.Enabled = true;
         conversation.Clear();
         message.Clear();
         message.Enabled = false;
         button2.Enabled = false;
         channel.StopListening(null);
         RemotingServices.Disconnect(this);
         ChannelServices.UnregisterChannel(channel);
         channel = null;
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: schoerg/TrafficSimulation
        public static void Main(string[] args)
        {
            // Create the server channel.
            TcpChannel serverChannel = new TcpChannel(RemoteObject.RemoteObject.GetIpcPort());

            // Register the server channel.
#pragma warning disable 618
            ChannelServices.RegisterChannel(serverChannel);
#pragma warning restore 618

            // Expose an object for remote calls.
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(RemoteObject.RemoteObject), RemoteObject.RemoteObject.GetRemoteObjectIdentifier(),
                WellKnownObjectMode.Singleton);

            // Wait for the user prompt.
            Console.WriteLine("Press ENTER to exit the server.");
            Console.ReadLine();

            try
            {
                serverChannel.StopListening(null);
                ChannelServices.UnregisterChannel(serverChannel);
                serverChannel = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception)
            {
                Debug.Print("Termination error, no handling required.");
            }
        }
コード例 #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();
                canal.StopListening(4001);
                ChannelServices.UnregisterChannel(canal);

                if (CONNECTION_PARAM.cnx.State == ConnectionState.Open)
                {
                    CONNECTION_PARAM.cnx.Close();
                }
                btn_demarrer.Enabled = true;
                btn_demarrer.Visible = true;
                button3.Visible      = false;
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }

            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #6
0
        private void Stop()
        {
            //获得当前已注册的通道;
            IChannel[] channels = ChannelServices.RegisteredChannels;

            //关闭通道;
            foreach (IChannel eachChannel in channels)
            {
                if (eachChannel.ChannelName.ToLower() == "tcp")
                {
                    TcpChannel tcpChannel = (TcpChannel)eachChannel;

                    //关闭监听;
                    tcpChannel.StopListening(null);

                    //注销通道;
                    ChannelServices.UnregisterChannel(tcpChannel);
                }
                else if (eachChannel.ChannelName.ToLower() == "http")
                {
                    HttpChannel httpChannel = (HttpChannel)eachChannel;
                    //关闭监听;
                    httpChannel.StopListening(null);
                    //注销通道;
                    ChannelServices.UnregisterChannel(httpChannel);
                }
            }
        }
コード例 #7
0
 public void setCrash(bool c)
 {
     crash = c;
     RemotingServices.Disconnect(mo);
     channel.StopListening(mo);
     //Environment.Exit(1);
 }
コード例 #8
0
        public void Connect(string nick, string port)
        {
            this.d++;
            SetText($"Connecting...\r\n");
            this.nickn = nick;
            this.cport = port;
            TcpChannel c = new TcpChannel(Int32.Parse(port));

            ChannelServices.RegisterChannel(c, false);

            CChat cc = new CChat(nick);

            RemotingServices.Marshal(cc, "ClientChat" + this.d, typeof(CChat));

            this.s    = (IServer)Activator.GetObject(typeof(IServer), "tcp://[IP]:[PORT]/SuperChat");
            this.turl = "tcp://" + GetLocalIPAddress() + ":" + port + "/ClientChat" + this.d;

            if (s.AddUser(nick, turl) == false)  //Check for already taken nickname
            {
                SetText($"Nickname already taken. Try again.\r\n");
                c.StopListening(null);
                RemotingServices.Disconnect(this);
                ChannelServices.UnregisterChannel(c);
                c = null;
            }
            else
            {
                SetText($"Connected!\r\n");
                portButton.Enabled = false;
            }
        }
コード例 #9
0
        public static void UnregisterChannel()
        {
            //获得当前已注册的通道;
            IChannel[] channels = ChannelServices.RegisteredChannels;

            //关闭指定通道;
            foreach (IChannel eachChannel in channels)
            {
                if (eachChannel == ms_tcpchannel)
                {
                    TcpChannel tcpChannel = (TcpChannel)eachChannel;
                    //关闭监听;
                    tcpChannel.StopListening(null);
                    //注销通道;
                    ChannelServices.UnregisterChannel(tcpChannel);
                    ms_tcpchannel = null;
                    log.Info("Tcp Service Stop!");
                }

                else if (eachChannel == ms_httpchannel)
                {
                    HttpChannel httpChannel = (HttpChannel)eachChannel;
                    //关闭监听;
                    httpChannel.StopListening(null);
                    //注销通道;
                    ChannelServices.UnregisterChannel(httpChannel);
                    ms_httpchannel = null;
                    log.Info("Http Service Stop!");
                }
            }
        }
コード例 #10
0
        public static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine();
            Console.WriteLine("PCS");
            Console.WriteLine("listening on tcp://" + PCS.GetLocalIPAddress() + ":11000/pcs");

            TcpChannel channel = new TcpChannel(1100);

            ChannelServices.RegisterChannel(channel, false);

            PCS pcs = new PCS();

            RemotingServices.Marshal(pcs, "pcs");

            createReplica("", "", "", 10, 10, false);
            createReplica("", "", "", 10, 10, true);
            createReplica("", "", "", 10, 10, true);


            // Dont close console
            Console.ReadLine();

            // Close TcpChannel
            channel.StopListening(null);
            RemotingServices.Disconnect(pcs);
            ChannelServices.UnregisterChannel(channel);
            channel = null;
        }
コード例 #11
0
        public static void Main(string[] args)
        {
            string repl_url = args[0];
            string op_id    = args[1];
            string pm_url   = args[2];

            int    port = Int32.Parse(repl_url.Split(':')[2].Split('/')[0]);
            string uri  = repl_url.Split('/')[repl_url.Split('/').Length - 1];

            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();

            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();

            props["port"] = port;
            props["name"] = "tcp" + port;

            TcpChannel channel = new TcpChannel(props, null, provider);

            ChannelServices.RegisterChannel(channel, false);

            Replica replica = new Replica(op_id, repl_url, pm_url);

            replica.channels.Add(channel);
            RemotingServices.Marshal(replica, uri, typeof(Replica));

            // Dont close console
            Console.ReadLine();

            // Close TcpChannel
            channel.StopListening(null);
            RemotingServices.Disconnect(replica);
            ChannelServices.UnregisterChannel(channel);
            channel = null;
        }
コード例 #12
0
        public override void Stop()
        {
            log.Info("Stopping");
            // This causes an error in the client because the agent
            // database is not thread-safe.
            //if (agency != null)
            //    agency.ReportStatus(this.ProcessId, AgentStatus.Stopping);

            // Do this on a different thread since we need to wait until all messages are through,
            // including the message which is waiting for this method to return so it can report back.
            ThreadPool.QueueUserWorkItem(_ =>
            {
                log.Info("Waiting for messages to complete");

                // Wait till all messages are finished
                _currentMessageCounter.WaitForAllCurrentMessages();

                log.Info("Attempting shut down channel");

                // Shut down nicely
                _channel.StopListening(null);
                ChannelServices.UnregisterChannel(_channel);

                // Signal to other threads that it's okay to exit the process or start a new channel, etc.
                log.Info("Set stop signal");
                stopSignal.Set();
            });
        }
コード例 #13
0
        static void StartServer(FamicomDumperConnection dumper, uint tcpPort)
        {
            BinaryServerFormatterSinkProvider binaryServerFormatterSinkProvider
                = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider binaryClientFormatterSinkProvider
                = new BinaryClientFormatterSinkProvider();

            binaryServerFormatterSinkProvider.TypeFilterLevel
                = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            var dict = new System.Collections.Hashtable();

            dict["name"]   = "FamicomDumperServer";
            dict["port"]   = tcpPort;
            dict["secure"] = false;
            var channel = new TcpChannel(dict, binaryClientFormatterSinkProvider, binaryServerFormatterSinkProvider);

            ChannelServices.RegisterChannel(channel, false);
            dumper.Verbose = true;
            RemotingServices.Marshal(dumper, "dumper");
            Console.WriteLine($"Listening port {tcpPort}, press any key to stop");
            Console.ReadKey();
            Console.WriteLine();
            ChannelServices.UnregisterChannel(channel);
            channel.StopListening(null);
        }
コード例 #14
0
 private void stopWorkerServer()
 {
     Console.WriteLine("Worker is stopping !");
     ch.StopListening(null);
     ChannelServices.UnregisterChannel(ch);
     Console.WriteLine("Worker Service Finished ");
 }
コード例 #15
0
 /// <summary>
 /// Frees any used resources.
 /// </summary>
 public static void Cleanup()
 {
     if (tcpChannel != null)
     {
         tcpChannel.StopListening(null);
     }
     tcpChannel = null;
 }
コード例 #16
0
        private void btnreset_Click(object sender, EventArgs e)
        {
            channel.StopListening(null);
            RemotingServices.Disconnect(this);
            ChannelServices.UnregisterChannel(channel);
            channel = null;

            AddRooms Check = new AddRooms();

            Check.Show();
            this.Hide();
        }
コード例 #17
0
        public void getNewPort()
        {
            Random random  = new Random();
            int    port    = 5000 + random.Next(0, 100);
            string address = "tcp://localhost:" + (port) + "/PadIntServer";

            padIntServer.Address = address;
            channel.StopListening(null);
            ChannelServices.UnregisterChannel(channel);
            channel = new TcpChannel(port);
            ChannelServices.RegisterChannel(channel, false);
        }
コード例 #18
0
        private void btnUserForm_Click(object sender, EventArgs e)
        {
            channel.StopListening(null);
            RemotingServices.Disconnect(this);
            ChannelServices.UnregisterChannel(channel);
            channel = null;

            UserForm Check = new UserForm();

            Check.Show();
            this.Hide();
        }
コード例 #19
0
        private static void CloseChannel()
        {
            IChannel[] channels = ChannelServices.RegisteredChannels;

            foreach (var item in channels)
            {
                if (item.ChannelName == "ServiceMessage")
                {
                    TcpChannel tcpChannel = (TcpChannel)item;
                    tcpChannel.StopListening(null);
                    ChannelServices.UnregisterChannel(tcpChannel);
                }
            }
        }
コード例 #20
0
        public static void Cleanup()
        {
            if (m_Mutex != null)
            {
                m_Mutex.Close();
            }

            if (m_TCPChannel != null)
            {
                m_TCPChannel.StopListening(null);
            }

            m_Mutex      = null;
            m_TCPChannel = null;
        }
コード例 #21
0
        public void DisposeChannel()
        {
            HeartbeatCheckerThread?.Abort();
            BeatThread?.Abort();

            if (TcpChannel == null)
            {
                return;
            }

            TcpChannel.StopListening(null);
            RemotingServices.Disconnect(this);
            ChannelServices.UnregisterChannel(TcpChannel);
            TcpChannel = null;
        }
コード例 #22
0
        /// <summary>
        /// Cleanup after call
        /// </summary>
        public static void Cleanup()
        {
            if (mutex != null)
            {
                mutex.Close();
            }

            if (tcpChannel != null)
            {
                tcpChannel.StopListening(null);
            }

            mutex      = null;
            tcpChannel = null;
        }
コード例 #23
0
ファイル: Service1.cs プロジェクト: cupid0426/MyProject
        protected override void OnStop()
        {
            //获得当前已注册的通道;
            IChannel[] channels = ChannelServices.RegisteredChannels;

            //关闭指定名为MyTcp的通道;
            foreach (IChannel eachChannel in channels)
            {
                if (eachChannel.ChannelName == "MyTcp")
                {
                    TcpChannel tcpChannel = (TcpChannel)eachChannel;

                    //关闭监听;
                    tcpChannel.StopListening(null);

                    //注销通道;
                    ChannelServices.UnregisterChannel(tcpChannel);
                }
            }
        }
コード例 #24
0
        public static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine();
            Console.WriteLine("PCS");
            Console.WriteLine(args[0]);

            channel = new TcpChannel(11000);
            ChannelServices.RegisterChannel(channel, false);

            pcs = new PCS();
            RemotingServices.Marshal(pcs, "pcs", typeof(IPCS));

            // Dont close console
            Console.ReadLine();

            // Close TcpChannel
            channel.StopListening(null);
            RemotingServices.Disconnect(pcs);
            ChannelServices.UnregisterChannel(channel);
            channel = null;
        }
コード例 #25
0
ファイル: RemotingServer.cs プロジェクト: mesh42/awmanaged
        public bool Stop()
        {
            base.Stop();
            switch (Connection.Protocol)
            {
            case RemotingProtocol.Ipc:
                channelIpc.StopListening(null);
                ChannelServices.UnregisterChannel(channelTcp);
                break;

            case RemotingProtocol.Tcp:
                channelTcp.StopListening(null);
                ChannelServices.UnregisterChannel(channelTcp);
                break;

            case RemotingProtocol.Http:
                channelHttp.StopListening(null);
                ChannelServices.UnregisterChannel(channelHttp);
                break;
            }
            return(true);
        }
コード例 #26
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(120, 20);
            Console.WriteLine("---Chat room server---");

            // Console.WriteLine("Input a port number to be listened");
            // int portNumber = int.Parse(Console.ReadLine());

            TcpChannel channel = new TcpChannel(8080);

            ChannelServices.RegisterChannel(channel, false);
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(Program), "Serveur", WellKnownObjectMode.Singleton);
            Console.WriteLine("The server is started");
            Console.WriteLine("---------------------------------");
            Console.WriteLine("Input anything to stop the server");
            if (Console.ReadLine() != null)
            {
                channel.StopListening(8080);
                ChannelServices.UnregisterChannel(channel);
            }
        }
コード例 #27
0
        private void stopServices()
        {
            running = false;
            try
            {
                // stop remoting
                try
                {
                    ChannelServices.UnregisterChannel(channel);
                    channel.StopListening(null);
                    channel = null;
                }
                catch (Exception) {}

                //DateTime StopTime = DateTime.Now;
                try
                {
                    serviceThreadManager.StopManager();
                }
                catch (Exception exc)
                {
                    EPSEventLog.WriteEntry("Error stopping threads" + Environment.NewLine + exc.ToString(), EventLogEntryType.Error);
                }

                // Wait until all processes have stopped to proceed
                do
                {
                    Thread.Sleep(100);
                } while (serviceThreadManager.sRunningProcesses + serviceThreadManager.lRunningProcesses > 0);


                EPSEventLog.WriteEntry("Services stopped.", EventLogEntryType.Information);
            }
            catch (Exception exc)
            {
                EPSEventLog.WriteEntry("Error stopping services" + Environment.NewLine + exc.ToString(), EventLogEntryType.Error);
            }
        }
コード例 #28
0
 private void CloseIncomingInteractionChannel()
 {
     if (_hostChannel == null)
     {
         return;
     }
     try
     {
         _hostChannel.StopListening(null);
     }
     catch
     {
     }
     try
     {
         ChannelServices.UnregisterChannel(_hostChannel);
     }
     catch
     {
     }
     _hostChannel = null;
     Logger.LogInfo(Message.SyncChannelClosed);
 }
コード例 #29
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int i = client.loginAdmin(txtEmailLogin.Text, txtPasswordLogin.Text);

            if (i == 200)
            {
                channel.StopListening(null);
                RemotingServices.Disconnect(this);
                ChannelServices.UnregisterChannel(channel);
                channel = null;

                UserForm Check = new UserForm();
                Check.Show();
                this.Hide();
            }
            else if (i == 400)
            {
                MessageBox.Show("Invalid Password!!!");
            }
            else if (i == 404)
            {
                MessageBox.Show("User Does Not Exsist in the System");
            }
        }
コード例 #30
0
        private void UnregisterPCUService()
        {
            try
            {
                IChannel[] channels = ChannelServices.RegisteredChannels;


                foreach (IChannel eachChannel in channels)
                {
                    if (eachChannel.ChannelName == "PCUChannel")
                    {
                        TcpChannel tcpChannel = (TcpChannel)eachChannel;


                        tcpChannel.StopListening(null);

                        ChannelServices.UnregisterChannel(tcpChannel);
                    }
                }
            }
            catch (Exception)
            {
            }
        }