Exemple #1
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 #2
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();
        }