Inheritance: IChannelReceiver, IChannelSender, ISecurableChannel
Exemple #1
0
 public void Start()
 {
     channel = new TcpChannel(8080);
     ChannelServices.RegisterChannel(channel, false);
     RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedObject), "Work", WellKnownObjectMode.Singleton);
     ServerConsole.Print("Сервер запущен!");
 }
Exemple #2
0
        static void Main() {
#if EASYTEST
			DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register();
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            EditModelPermission.AlwaysGranted = Debugger.IsAttached;
            var winApplication =
                new SecuritySystemExampleWindowsFormsApplication();
            const string connectionString = "tcp://localhost:1426/DataServer";
            winApplication.ConnectionString = connectionString;
            try {
                var t = new Hashtable{{"secure", true}, {"tokenImpersonationLevel", "impersonation"}};
                var channel = new TcpChannel(t, null, null);
                ChannelServices.RegisterChannel(channel, true);
                var clientDataServer = (IDataServer) Activator.GetObject(
                    typeof (RemoteSecuredDataServer), connectionString);
                var securityClient =
                    new ServerSecurityClient(clientDataServer, new ClientInfoFactory()){IsSupportChangePassword = true};
                winApplication.ApplicationName = "SecuritySystemExample";
                winApplication.Security = securityClient;
                winApplication.CreateCustomObjectSpaceProvider +=
                    delegate(object sender, CreateCustomObjectSpaceProviderEventArgs e) {
                        e.ObjectSpaceProvider =
                            new DataServerObjectSpaceProvider(clientDataServer, securityClient);
                    };
                winApplication.Setup();
                winApplication.Start();
            }
            catch (Exception e) {
                winApplication.HandleException(e);
            }
        }
Exemple #3
0
 public void Start()
 {
     channel = new TcpChannel(8081);
     ChannelServices.RegisterChannel(channel, false);
     RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedObject), "Пул данных", WellKnownObjectMode.Singleton);
     Log.Print("Сервер запущен");
 }
Exemple #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Thread m_oPrintThread;

            ConfigManager.Init();

            ConfigManager.ReloadConfig();

            CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>();

            CPrintThread myThread = new CPrintThread();
            m_oPrintThread = new Thread(new ThreadStart(myThread.run));
            m_oPrintThread.Start();

            TcpChannel ch = new TcpChannel(8085);

            ChannelServices.RegisterChannel(ch);

            RemotingConfiguration.RegisterWellKnownServiceType(typeof

                           (RmsRemote.CLogin), "RMSSERVER", WellKnownObjectMode.Singleton);

            Console.Write("Sever is  Ready........");

            Console.Read();
        }
        private void CreateCommunicationChannel()
        {
            BinaryServerFormatterSinkProvider binaryServerProv = new BinaryServerFormatterSinkProvider();
            binaryServerProv.TypeFilterLevel = TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider binaryClientProv = new BinaryClientFormatterSinkProvider();

            IDictionary props = new Hashtable();
            props["port"] = settings.Port;
            props["authenticationMode"] = "IdentifyCallers";


            //HttpChannel chan = new HttpChannel(props, binaryClientProv, binaryServerProv); 
            try
            {
                TcpChannel chan = new TcpChannel(props, binaryClientProv, binaryServerProv);
                ChannelServices.RegisterChannel(chan, false);
                if (chan == null)
                {
                    new WindowsServiceLog().WriteEntry(
                            string.Format("Could not start server with port {0}", settings.Port));
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (SocketException e)
            {
                new WindowsServiceLog().WriteEntry(
                        string.Format("Could not start server. Application port {1} is using by another application. Error message: {0}",
                                                    e.Message, settings.Port));
                Process.GetCurrentProcess().Kill();
            }
        }
        public static void Main(string [] args)
        {
            TcpChannel chan = new TcpChannel();
            ChannelServices.RegisterChannel(chan);

                ObjetoRemoto obj = (ObjetoRemoto) Activator.GetObject(
                typeof(TestCode.Remoting.ObjetoRemoto),
                    "tcp://127.0.0.1:9191/ObjetoRemoto");
                if( obj.Equals(null) )
                {
                    System.Console.WriteLine("Error: no se puede localizar el servidor");
                }
                else
                {
                    SampleClient client = new SampleClient();
                    AsyncCallback fin_llamada_asincrona = new AsyncCallback(client.fin_contador);
                    RemoteAsyncDelegate RemoteDel = new RemoteAsyncDelegate(obj.contador);
                    while (true){
                        Console.WriteLine("Empezar a contar");
                        Console.ReadLine();
                        IAsyncResult RemAr = RemoteDel.BeginInvoke(ref client.cuenta, fin_llamada_asincrona, null);

                        // Esperar a que la llamada termine: Si se quita while ya no espera
                        int y = 0;
                        while(!RemAr.IsCompleted){
                      //Console.WriteLine("Enviando petición al servidor, espere por favor: ");
                            //Console.WriteLine((++y));
                      Thread.Sleep(10);
                        }
                    }
                }
        }
Exemple #7
0
		public void Run()
		{
			try
			{
				tcp =  new TcpChannel (0);
				
				Hashtable options = new Hashtable ();
				options ["timeout"] = 10000; // 10s
				http = new HttpClientChannel (options, null);
			
				ChannelServices.RegisterChannel (tcp);
				ChannelServices.RegisterChannel (http);
			
				AppDomain domain = BaseCallTest.CreateDomain ("testdomain_activation");
				server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
				
				RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:9433");
				RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:9434");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:9433/wkoSingleCall1");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:9433/wkoSingleton1");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:9434/wkoSingleCall2");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:9434/wkoSingleton2");
			}
			catch (Exception ex)
			{
				Console.WriteLine (ex);
			}
		}
Exemple #8
0
        static void Main(string[] config)
        {
            string cg;

            if(config.Length==0)
            {
              cg = "DefaultCavity";
            }
            else
            {
                cg = config[0];
            };

            Controller controller = new Controller(cg);

            // publish the controller to the remoting system
            TcpChannel channel = new TcpChannel(controller.config.TCPChannel);
            ChannelServices.RegisterChannel(channel, false);
            RemotingServices.Marshal(controller, "controller.rem");

            // hand over to the controller
            controller.Start();

            // the application is finishing - close down the remoting channel
            //RemotingServices.Disconnect(controller);
            //ChannelServices.UnregisterChannel(channel);
        }
Exemple #9
0
        private void JoinToChatRoom()
        {
            if (chan == null && txtName.Text.Trim().Length != 0)
            {
                chan = new TcpChannel();
                ChannelServices.RegisterChannel(chan, false);

                // Create an instance of the remote object
                objChatWin = new frmChatWin();
                objChatWin.remoteObj = (SampleObject)Activator.GetObject(typeof(RemoteBase.SampleObject), txtServerAdd.Text);

                if (!objChatWin.remoteObj.JoinToChatRoom(txtName.Text))
                {
                    MessageBox.Show(txtName.Text+ " already joined, please try with different name");
                    ChannelServices.UnregisterChannel(chan);
                    chan = null;
                    objChatWin.Dispose();
                    return;
                }
                objChatWin.key = objChatWin.remoteObj.CurrentKeyNo();
                
                objChatWin.yourName= txtName.Text;

                this.Hide();
                objChatWin.Show();
                
            }
        }
        public virtual void FixtureSetUp()
        {
            lock (lockObject)
            {
                if (channel == null)
                {
                    try
                    {
                        foreach (IChannel registeredChannel in ChannelServices.RegisteredChannels)
                        {
                            if (registeredChannel is TcpChannel)
                            {
                                ((TcpChannel) registeredChannel).StopListening(null);
                            }
                            ChannelServices.UnregisterChannel(registeredChannel);
                        }

                        channel = new TcpChannel(8005);
#if !NET_2_0 
                        ChannelServices.RegisterChannel(channel);
#else
                        ChannelServices.RegisterChannel(channel, false);
#endif
                    }
                    catch
                    {
                        // ignore duplicate registration exception if it occurs...
                    }
                }
            }
        }
Exemple #11
0
        public Form1()
        {
            InitializeComponent();
            PuppetMaster.ctx = this;
            TcpChannel channel = new TcpChannel(8090);
            ChannelServices.RegisterChannel(channel, true);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(PuppetMaster), "PseudoNodeReg", WellKnownObjectMode.Singleton);
            Clients = new List<Node>();
            Servers = new List<Node>();
            WriteHostDelegate = new WriteHost(WriteHostMethod);

            string currentDirectory = Environment.CurrentDirectory;
            string[] newDirectory = Regex.Split(currentDirectory, "PuppetMaster");
            string strpath = newDirectory[0] + "Scripts";    //Replace("PuppetMaster", "Scripts");

            string[] filePaths = Directory.GetFiles(strpath, "*.txt",
                                                     SearchOption.AllDirectories);

            foreach (string path in filePaths)
                listBox1.Items.Add(path);

            this.listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick);

            //System.DirectoryServices.DirectoryEntry myDE = new
            //   System.DirectoryServices.DirectoryEntry(strpath);
            //tabPage3.Controls.Add(myDE);
               // string nameGuid = myDE.Name + myDE.Guid.ToString();

               // WriteUserScriptsDelegate = new WriteUserScripts(WriteUserScriptsMethod);
        }
Exemple #12
0
        //HANDLER DO FORM
        public bool Register(string nick, string port)
        {
            this.nick = nick;

            TcpChannel channel = new TcpChannel(Int32.Parse(port));
            ChannelServices.RegisterChannel(channel, true);

            ObjClient objClient = new ObjClient(formClient);
            RemotingServices.Marshal(objClient,
                "IChatClient",
                typeof(ObjClient));

            string serverUrl = "tcp://localhost:8086/IChatServer";

            serverObj = (ObjServer)Activator.GetObject(
                typeof(ObjServer), serverUrl);

            if (serverObj == null) {
                System.Console.WriteLine("Could not locate server");
                return false;
            }

            string clientUrl = "tcp://localhost:" + port + "/IChatClient";
            serverObj.Register(nick, clientUrl);

            return true;
        }
Exemple #13
0
        static void Main(string[] args)
        {
            RemotingConfiguration.ApplicationName = "CallbackRemoting";

            // 设置formatter
            BinaryServerFormatterSinkProvider formatter = new BinaryServerFormatterSinkProvider();
            formatter.TypeFilterLevel = TypeFilterLevel.Full;

            // 设置通道名称和端口
            IDictionary propertyDic = new Hashtable();
            propertyDic["name"] = "CustomTcpChannel";
            propertyDic["port"] = 8502;

            // 注册通道
            IChannel tcpChnl = new TcpChannel(propertyDic, null, formatter);
            ChannelServices.RegisterChannel(tcpChnl, false);

            // 注册类型
            Type t = typeof(Server);
            RemotingConfiguration.RegisterWellKnownServiceType(
                t, "ServerActivated", WellKnownObjectMode.Singleton);

            Console.WriteLine("Server running, model: Singleton\n");
            Console.ReadKey();
        }
Exemple #14
0
        public static void Main(string[] args)
        {
            short port=23456;

            Console.WriteLine("USAGE: subserver <portnumber>");

            if(args.Length>1 && Int16.TryParse(args[1],out port) && port>1024){
                //OK, got good port
            } else {
                port = 23456; //default port
            }

            try {
                BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
                serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
                IDictionary props = new Hashtable();
                props["port"] = port;

                TcpChannel chan = new TcpChannel(props, clientProv, serverProv);	//create the tcp channel
                ChannelServices.RegisterChannel(chan,false);	//register the tcp channel
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(subsharelib.subshareRemoteObject),"SUBSERVER",WellKnownObjectMode.Singleton);	//publish the remote object

                Console.WriteLine("SERVER STARTED AT PORT "+port);
            } catch (Exception ex) {
                Console.WriteLine("SERVER CAN NOT START! "+ex);
            }
            Console.Write("Press any key to exit . . . ");
            Console.ReadKey(true);
        }
Exemple #15
0
        public void Connect()
        {
            cmbCompression.SelectedIndex = 4;
            chan1 = new TcpChannel(8082);
            try
            {
                //Set the Host IP
                if(txtServer.Text != "")
                    hostIP = txtServer.Text;

                //Register the TCP Channel
                ChannelServices.RegisterChannel(chan1, false);
                chan1.StartListening(null);

                castTimer.Enabled = true;
                connected = true;
                btnConnect.ImageIndex = 2;
                btnConnect.Text = "Disconnect";
                updatePanel(pnlBottom, true);
                updateText(lblMessage, "Connected to " + hostIP + " - " + DateTime.Now);
            }
            catch (Exception exc)
            {
                updateText(lblMessage, exc.Message);
            }
        }
Exemple #16
0
        private void mnuSlaveStart_Click(object sender, EventArgs e)
        {
            try
            {
                // 以指定連接埠的伺服器Channel建立TcpChannel物件
                tcpchannel = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(8080);

                // 註冊Channel服務的Channel通道
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcpchannel, false);

                // 設定Channel組態
                System.Runtime.Remoting.WellKnownServiceTypeEntry entry =
                    new WellKnownServiceTypeEntry(typeof(RemoteControl), "RemoteSlave", WellKnownObjectMode.Singleton);

                // 在服務端登錄提供服務之物件
                System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(entry);

                timer1.Enabled = false;
                this.notifyIcon1.ContextMenu = this.contextMenu1;
                this.notifyIcon1.Visible     = true;
                this.Visible = false;

                this.mnuSlaveStart.Enabled = false;
                this.mnuSlaveStop.Enabled  = true;
            }
            catch (Exception ex)
            {
                stop();
                this.mnuSlaveStart.Enabled = true;
                this.mnuSlaveStop.Enabled  = false;
                Console.WriteLine(ex.StackTrace.ToString());
            }
        }
Exemple #17
0
            public void OpenConnection()
            {
                Log.Info("DatabaseProxy.OpenConnection");
                // connecting to the remote database
                TcpChannel tcpChannel = new TcpChannel();
                ChannelServices.RegisterChannel(tcpChannel);
                this.db = (PSPEServer.PSPEDatabaseServer)Activator.GetObject(
                    typeof(PSPEServer.PSPEDatabaseServer), "tcp://localhost:8085/MyDatabase");
                if (null == db)
                {
                    Log.Info("Cannot connect to the server");
                }
                else
                {
                    Log.Info("Internal tx id:" + db.Connect());
                }

                // enlisting in the transaction
                if (null != this.internalRM)
                {
                    throw new Exception("we don't support multiple connections, this is just a sample");
                }
                internalRM = new InternalRM(db);
                internalRM.Enlist();
            }
Exemple #18
0
        static void Main(string[] args)
        {
            TcpChannel channel = new TcpChannel();
            ChannelServices.RegisterChannel(channel, false);

            ClientApp clientApp = new ClientApp();

            PadiDstm.Init();
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //Console.WriteLine("About to recover");
            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");

            //clientApp.PadiDstm.Status();

            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Freeze("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Freeze("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //Console.WriteLine("After fail");

            //Console.ReadLine();
            //clientApp.transaction1();
            //clientApp.transaction2();

            Console.ReadLine();
            PadiDstm.Status();
            Console.ReadLine();
        }
Exemple #19
0
        static void Main(string[] args)
        {
            RemotingConfiguration.Configure(@"../../App.config", true);

            KeyValuePair<int, int> idAndPort;
            System.Console.WriteLine("Bootstrapping...");
            TcpChannel channel = new TcpChannel();
            ChannelServices.RegisterChannel(channel, false);
            System.Console.WriteLine("Registered Channel @random");

            string address = System.IO.File.ReadAllText(@"../../../mServerLocation.dat");

            MasterInterface mServer = (MasterInterface)Activator.GetObject(typeof(MasterInterface), address);
            idAndPort = mServer.RegisterTransactionalServer(getIP());

            System.Console.WriteLine("Registered at Master");
            ChannelServices.UnregisterChannel(channel);
            System.Console.WriteLine("Unbinding old port");

            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();
            props["port"] = idAndPort.Value;

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

            ChannelServices.RegisterChannel(channel, false);
            System.Console.WriteLine("Registered Channel @" + idAndPort.Value);
            TransactionalServer ts = new TransactionalServer(idAndPort.Key, mServer, "tcp://"+getIP()+":"+idAndPort.Value+"/Server");
            RemotingServices.Marshal(ts, "Server", typeof(TransactionalServer));
            System.Console.WriteLine("SERVER ON");
            System.Console.WriteLine("Server: " + idAndPort.Key + " Port: " + idAndPort.Value + " IP: "+ getIP());
            System.Console.ReadLine();
        }
Exemple #20
0
        private static void loadRPCServices(string[] args)
        {
            TcpChannel channel;
            channel = new TcpChannel(Int32.Parse(args[0]));
            ChannelServices.RegisterChannel(channel, true);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            RemotingConfiguration.RegisterWellKnownServiceType(typeof(ClientToServerServicesObject),
                    ServicesNames.ClientToServerServicesName,
                    WellKnownObjectMode.Singleton);

            RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerToServerServicesObject),
                    ServicesNames.ServerToServerServicesName,
                    WellKnownObjectMode.Singleton);

            _myUri = (((ChannelDataStore)channel.ChannelData).ChannelUris)[0];
            _primaryURI = _myUri;
            _serverPort = args[0];

            _ServerToServerServiceObject = (ServerToServerServicesObject)Activator.GetObject(
                typeof(ServerToServerServicesObject),
                ServerApp._myUri + "/" + ServicesNames.ServerToServerServicesName);
        }
Exemple #21
0
 //Construtor
 public Cliente()
 {
     //Definindo que o canal da Conexão remota será TCP
     TcpChannel channel = new TcpChannel();
     ChannelServices.RegisterChannel(channel, false);
     this.LimparJogadorCliente();
 }
Exemple #22
0
 public void Start()
 {
     channel = new TcpChannel(8081);
     ChannelServices.RegisterChannel(channel, false);
     RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedObject), "DataPool", WellKnownObjectMode.Singleton);
     Log.Print("Server has started");
 }
        public Portability SolicitarBilhetePortabilidade(Custumer custumer, Acount acount)
        {
            //[chamando o webservice do módulo Anatel]
            Anatel.IAnatel client;
            TcpChannel channel = new TcpChannel();
            ChannelServices.RegisterChannel(channel);
            client = (Anatel.IAnatel)Activator.GetObject(typeof(Anatel.IAnatel), "tcp://localhost:8091/SolicitarPortabilidadeNumerica");

            //[obtendo resposta da Anatel para a portabilidade]
            RetornoPortabilidade retorno = client.SolicitarPortabilidadeNumerica(custumer);

            //[verificar as validacoes retornadas pela anatel]
            if (!retorno.CodigoErro.Equals("0"))
            {
                PortabilidadeFault falha = new PortabilidadeFault();
                falha.CodigoErro = retorno.CodigoErro;
                falha.DataErro = retorno.DataErro;
                falha.Motivo = retorno.Motivo;
                throw new FaultException<PortabilidadeFault>(falha);
            }

            //[obtendo o numero do bilhete da Anatel]
            Portability portabilidade = new Portability();
            portabilidade.Bilhete = retorno.Bilhete;

            return portabilidade;
        }
Exemple #24
0
        private void RegisterRemoting()
        {
            {
                try
                {
                    BinaryServerFormatterSinkProvider server_provider = new BinaryServerFormatterSinkProvider();
                    server_provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

                    BinaryClientFormatterSinkProvider client_provider = new BinaryClientFormatterSinkProvider();
                    IDictionary properties = new Hashtable();

                    properties["port"] = "0";

                    TcpChannel channel = new TcpChannel(properties, client_provider, server_provider);
                    ChannelServices.RegisterChannel(channel, false);

                    user = (IUser)Activator.GetObject(typeof(IUser), "tcp://localhost:9998/UserHandeling");
                    portal = (IPortal)Activator.GetObject(typeof(IPortal), "tcp://localhost:9998/PortalHandeling");
                    ftserver = (IFTserver)Activator.GetObject(typeof(IFTserver), "tcp://localhost:9998/TransferHandeling");
                }
                catch (RemotingException e)
                {
                    MessageBox.Show("Connection Error");
                }
            }
        }
Exemple #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //使用TCP通道得到远程对象
                TcpChannel chan1 = new TcpChannel();
                ChannelServices.RegisterChannel(chan1);
                ISMUser obj1 = (ISMUser)Activator.GetObject(
                    typeof(ISMUser),
                    string.Format("tcp://{0}:8085/SMUserService", SMClientSetting.Default.RemotingServerIP));
                if (obj1 == null)
                {
                    XtraMessageBox.Show("连接Remoting服务器失败!");
                }

                //注册
                bool ret = obj1.Login("admin", "123456");
                if (ret)
                {
                    //获取"litaiyong"用户相关的摄像头的信息
                    smCameraInfos = obj1.GetCameraInfoByUserName("litaiyong");
                }
            }
            catch (Exception ex)
            {

                XtraMessageBox.Show(ex.ToString());
            }
        }
Exemple #26
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            setServiceXml();
            btnStart.Enabled = false;
            
            try
            {
                Setting.Load();
                BinaryServerFormatterSinkProvider binaryServerFormatterSinkProvider = new BinaryServerFormatterSinkProvider();
                BinaryClientFormatterSinkProvider clientSinkProvider = new BinaryClientFormatterSinkProvider();
                binaryServerFormatterSinkProvider.TypeFilterLevel = TypeFilterLevel.Full;

                IDictionary dic = new Dictionary<string, int>();
                dic.Add("port", Setting.Instance.Port);

                TcpChannel channel = new TcpChannel(dic, clientSinkProvider, binaryServerFormatterSinkProvider);
                ChannelServices.RegisterChannel(channel, false);
                List<IRemoteService> list = ServicesManager.GetTypeFromAssembly<IRemoteService>();
                foreach (IRemoteService service in list)
                {
                    service.RegisterService();
                }
                btnStop.Enabled = true;
            }
            catch (Exception ex)
            {
                btnStart.Enabled = true;
                throw ex;
            }
        }
Exemple #27
0
        private static void Main(string[] args)
        {
            var channelServ = new TcpChannel();
            ChannelServices.RegisterChannel(channelServ, false);

            var mainServer = (IMainServer) Activator.GetObject(typeof (IMainServer), Config.RemoteMainserverUrl);
            ServerInit serverInit = mainServer.AddServer();

            channelServ.StopListening(null);
            ChannelServices.UnregisterChannel(channelServ);

            var server = new Server(serverInit);
            IDictionary properties = new Hashtable();
            int serverPort = Config.GetServerPort(serverInit.Uuid);
            const int serverTimeout = Config.InvocationTimeout;
            properties["port"] = serverPort;
            properties["timeout"] = serverTimeout;
            channelServ = new TcpChannel(properties, null, null);
            ChannelServices.RegisterChannel(channelServ, false);
            RemotingServices.Marshal(server, Config.RemoteServerObjName);

            server.StartSplitLock();

            foreach (var faultDetection in serverInit.FaultDetection)
            {
                var fd = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(faultDetection.Key));
                fd.OnFaultDetectionReborn(serverInit.Uuid);
            }

            int backupId = -1;
            if ((serverInit.FaultDetection.Count == 1 && serverInit.FaultDetection.ContainsKey(serverInit.Parent) &&
                 serverInit.Parent != -1) || (serverInit.FaultDetection.Count == 0 && serverInit.Parent != -1))
            {
                backupId = serverInit.Parent;
            }
            else if (serverInit.FaultDetection.Count > 0)
            {
                backupId = serverInit.FaultDetection.Keys.Max();
            }

            if (backupId != -1)
            {
                /* Get data from backup */
                var backupServer = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(backupId));
                backupServer.StartSplitLock();
                ParticipantStatus status = backupServer.OnChild(serverInit.Uuid, serverInit.Version,
                    serverInit.ServerCount);
                server.SetStatus(status);
                backupServer.EndSplitLock();
            }
            else
            {
                Console.WriteLine("Server need to have a backup server! Is it the first one?");
            }

            server.EndSplitLock();

            Console.WriteLine("Press <enter> to exit");
            Console.ReadLine();
        }
Exemple #28
0
        public PuppetMasterForm()
        {
            InitializeComponent();

            //Inicializations
            puppet_master_history_TextBox.Text = "";
            dump_history_TextBox.Text = "";
            command_TextBox.Text = "";

            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();
            props["port"] = 8400;
            props["timeout"] = 200000;

            channel = new TcpChannel(props, null, provider);
            ChannelServices.RegisterChannel(channel, true);

            clients = new Dictionary<string, Tuple<string, ClientInterface>>();
            metadataServers = new Dictionary<string, Tuple<string, MetadataServerInterface>>();
            dataServers = new Dictionary<string, Tuple<string, DataServerInterface>>();

            clientStartPort = 8100;
            metadataServerStartPort = 8200;
            dataServerStartPort = 8300;

            script = null;
        }
 public TesteUnitarioServiceAnatel()
 {
     InitializeComponent();
     TcpChannel channel = new TcpChannel();
     ChannelServices.RegisterChannel(channel);
     client = (Anatel.IAnatel)Activator.GetObject(typeof(Anatel.IAnatel), "tcp://localhost:8091/SolicitarPortabilidadeNumerica");
 }
Exemple #30
0
        public RemotingHostServer(Machine machine, int port, string name)
            : base(machine)
        {
            this.port = port;
            this.name = name;

            // TODO review this name, get machine name
            this.hostname = "localhost";

            // According to http://www.thinktecture.com/resourcearchive/net-remoting-faq/changes2003
            // in order to have ObjRef accessible from client code
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();

            IDictionary props = new Hashtable();
            props["port"] = port;

            TcpChannel channel = new TcpChannel(props, clientProv, serverProv);

            if (!registered)
            {
                ChannelServices.RegisterChannel(channel, false);
                registered = true;
            }

            // end of "according"

            // TODO review other options to publish an object
            this.objref = RemotingServices.Marshal(this, name);
        }
Exemple #31
0
        public frmRCleint()
        {
            InitializeComponent();

            //************************************* TCP *************************************//
            // using TCP protocol
            // running both client and server on same machines
            //TcpChannel chan = new TcpChannel();
            //˫���ŵ�
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
            IDictionary props = new Hashtable();
            props["port"] = 0;//���ն˿�(���)
            TcpChannel chan = new TcpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(chan,false);
            // Create an instance of the remote object
            remoteObject = (MyRemotableObject) Activator.GetObject(typeof(MyRemotableObject),"tcp://localhost:8080/HelloWorld");
            // if remote object is on another machine the name of the machine should be used instead of localhost.
            //************************************* TCP *************************************//
            wrapper = new EventWrapper();//�¼���װ������
            wrapper.LocalEvent += new ServerEventHandler(OnServerEvent);
            remoteObject.ServerEvent += new ServerEventHandler(wrapper.Response);
        }
Exemple #32
0
        private void start()
        {
            frmHost form = new frmHost();

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                string remotehost = form.Host;

                if (remotehost.Length != 0)
                {
                    try
                    {
                        string url = "tcp://" + remotehost + ":8080/RemoteSlave";

                        // 建立TcpChannel物件
                        tcpchannel = new System.Runtime.Remoting.Channels.Tcp.TcpChannel();

                        // 註冊Channel服務的Channel通道
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcpchannel, false);

                        // 以指定物件和URL建立Proxy
                        remotecontrol = (RemoteControl)System.Activator.GetObject(typeof(RemoteControl), url);

                        this.connected = true;
                        timer1.Enabled = true;

                        this.FormBorderStyle = FormBorderStyle.None;
                        this.WindowState     = FormWindowState.Maximized;

                        this.mnuView.Visible = true;
                        this.mnuView.Enabled = true;

                        this.mnuMasterStart.Enabled = false;
                        this.mnuMasterStop.Enabled  = true;
                    }
                    catch (Exception ex)
                    {
                        stop();
                        this.mnuMasterStart.Enabled = true;
                        this.mnuMasterStop.Enabled  = false;
                        Console.WriteLine(ex.StackTrace.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("請輸入被控端之IP位址或DNS主機名稱.", "Remote Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public TcpClientTransportSink(string url)
        {
            string objectUri;
            string port;

            TcpChannel.ParseTcpURL(url, out _host, out port, out objectUri);

            try
            {
                if (port != null)
                {
                    _port = Convert.ToInt32(port);
                }
                else
                {
                    _port = 0;
                }
            }
            catch
            {
                _host = null;
                _port = -1;
            }
        }
Exemple #34
0
 public string Parse(string url, out string objectURI)
 {
     return(TcpChannel.ParseChannelUrl(url, out objectURI));
 }