Beispiel #1
0
        private void FrmServer_Load(object sender, EventArgs e)
        {
            try
            {
                LED_Operate.DeleteFile_Log("错误日志");
                LED_Operate.DeleteFile_Log("操作日志");
                FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Constant.ApplicationDirectory + "\\" + "LED_RemotingServer.exe");

                this.Text = "LED服务端  版本:" + myFileVersionInfo.FileMajorPart + "." + myFileVersionInfo.FileMinorPart + "." + myFileVersionInfo.FileBuildPart + "." + myFileVersionInfo.FilePrivatePart;


                TcpServerChannel server = new TcpServerChannel(8080);
                string           se     = server.GetChannelUri();
                ChannelServices.RegisterChannel(server, false);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(LedShow), "LED", WellKnownObjectMode.Singleton);
                //RemotingObj.UsersInfo.SendEventArgs += new RemotingObj.UsersInfo.SendEventHandler(ListBox_Add);
                //RemotingObj.UsersInfo.SendEventArgs += delegate(string s) { MessageBox.Show(s); };
                LedShow.LedShowedEvent += new ICommon.LedShowEventHandler(LedShowMothed);
                listBox1.Items.Add("服务器TCP地址:" + se);
                listBox1.Items.Add("服务器开启时间:" + DateTime.Now.ToString());
                strs = showwindowstring.Split('|');
                if (strs != null)
                {
                    for (int i = 0; i < strs.Length; i++)
                    {
                        WindowsInfo window = new WindowsInfo(i.ToString());
                        window.WinName  = strs[i];
                        window.CallTime = DateTime.Now;
                        windows.Add(window);
                        listBox1.Items.Add("窗口" + i.ToString() + ":" + window.WinName);
                    }
                }
                this.toolStripStatusLabel1.Text = "服务启动成功!";
                if (sentens == "")
                {
                    //sentens = "谢谢惠顾";
                }
                //清屏时间
                if (TrasenClasses.GeneralClasses.Convertor.IsInteger(LED_Operate.qingpingshijian))
                {
                    int qingpingshijian = int.Parse(LED_Operate.qingpingshijian);
                    if (qingpingshijian >= 1)
                    {
                        _qingpingshijian = qingpingshijian;
                    }
                }

                this.WindowState = FormWindowState.Normal;
                myTimer          = new System.Timers.Timer(1000 * 30);//(30000);
                myTimer.Elapsed += Timer_Tick;
                myTimer.Enabled  = true;
                myTimer.Start();
            }
            catch (Exception ex)
            {
                this.toolStripStatusLabel1.Text = ex.Message;
            }
        }
Beispiel #2
0
        public void TestTcpRemoting()
        {
            TcpServerChannel serverChannel = GetServerChannel("TcpRemotingTest", 9090);
            string           uri           = serverChannel.GetChannelUri();

            Assert.IsNotNull(uri, "Server channel URI is null");

            TcpClientChannel clientChannel = GetClientChannel("TcpRemotingTest", uri);

            RemoteObject remoteObject = new RemoteObject();

            Assert.IsTrue(remoteObject.ReturnOne() == 1, "Invoking RemoteObject.ReturnOne() failed");
        }
Beispiel #3
0
        public static string StartServer(int port, string[] args)
        {
            TcpServerChannel channel = new TcpServerChannel(port);

            ChannelServices.RegisterChannel(channel);
            string uri = channel.GetChannelUri() + "/DebuggerService";

            DebuggerService debuggerService = new DebuggerService(args);

            RemotingServices.Marshal(debuggerService, "DebuggerService");

            Console.WriteLine("Listening at " + uri);

            return(uri);
        }
Beispiel #4
0
    public static void Main(string[] args)
    {
        //<snippet21>
        // Create the server channel.
        TcpServerChannel channel = new TcpServerChannel(
            "Server Channel", 9090, null);

        //</snippet21>

        // Register the server channel.
        ChannelServices.RegisterChannel(channel);

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

        //<snippet22>
        // Display the channel's URI.
        Console.WriteLine("The channel URI is {0}.",
                          channel.GetChannelUri());
        //</snippet22>

        //<snippet23>
        // Parse the channel's URI.
        string[] urls = channel.GetUrlsForUri("RemoteObject.rem");
        if (urls.Length > 0)
        {
            string objectUrl = urls[0];
            string objectUri;
            string channelUri = channel.Parse(objectUrl, out objectUri);
            Console.WriteLine("The object URI is {0}.", objectUri);
            Console.WriteLine("The channel URI is {0}.", channelUri);
            Console.WriteLine("The object URL is {0}.", objectUrl);
        }
        //</snippet23>

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