protected static bool RegisterChannnel(int IP) { // リモート用として、クライアントチャンネルを登録。登録系は同じプロセス内で複数回やるとエラーが出るので、 try { System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ch[IP], false); // リモート呼び出しのため、(サーバーにある)オブジェクト取得。 // Register as client for remote object. System.Runtime.Remoting.WellKnownClientTypeEntry remoteType = new System.Runtime.Remoting.WellKnownClientTypeEntry(typeof(HmNodeRemoteObject), "ipc://localhost:" + IP + "/" + HmNodeRemoteObject.Name + IP + ".rem"); // クライアントタイプとして登録 System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType); // 通知先(Message Sink)のインスタンス生成 string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = (ch[IP]).CreateMessageSink("ipc://localhost:" + IP + "/" + HmNodeRemoteObject.Name + IP + ".rem", null, out objectUri); Console.WriteLine("通知先のURIは {0}.", objectUri); if (messageSink != null) { Console.WriteLine("通知先のクラス型は {0}.", messageSink.GetType().ToString()); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.GetType().ToString()); System.Diagnostics.Debug.WriteLine(e.Message); return(false); } return(true); }
public void MainFunc() { // Создаём каналы IpcChannel channel1 = new IpcChannel(); IpcChannel channel2 = new IpcChannel(); IpcChannel channel3 = new IpcChannel(); // Регистрируем канал. System.Runtime.Remoting.Channels.ChannelServices. RegisterChannel(channel1, false); // Регистрируем клиентские удалённые обьекты. System.Runtime.Remoting.WellKnownClientTypeEntry remoteType1 = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(ClassLibrary1.Class1), "ipc://localhost:9090/RemoteObject1.rem"); System.Runtime.Remoting.WellKnownClientTypeEntry remoteType2 = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(ClassLibrary2.Class2), "ipc://localhost:9090/RemoteObject2.rem"); System.Runtime.Remoting.WellKnownClientTypeEntry remoteType3 = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(ClassLibrary3.Class3), "ipc://localhost:9090/RemoteObject3.rem"); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownClientType(remoteType1); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownClientType(remoteType2); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownClientType(remoteType3); // Создаём приемники сообщений string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink1 = channel1.CreateMessageSink( "ipc://localhost:9090/RemoteObject1.rem", null, out objectUri); System.Runtime.Remoting.Messaging.IMessageSink messageSink2 = channel2.CreateMessageSink( "ipc://localhost:9090/RemoteObject2.rem", null, out objectUri); System.Runtime.Remoting.Messaging.IMessageSink messageSink3 = channel3.CreateMessageSink( "ipc://localhost:9090/RemoteObject3.rem", null, out objectUri); // Создание экземпляра удаленного объекта service1 = new ClassLibrary1.Class1(); service2 = new ClassLibrary2.Class2(); service3 = new ClassLibrary3.Class3(); return; }
public static void Main(string[] args) { // Create the channel. HttpClientChannel clientChannel = new HttpClientChannel(); // Register the channel. ChannelServices.RegisterChannel(clientChannel); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(RemoteObject), "http://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "http://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine( "The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Display the channel's properties using Keys and Item. foreach (string key in clientChannel.Keys) { Console.WriteLine( "clientChannel[{0}] = <{1}>", key, clientChannel[key]); } // Parse the channel's URI. string objectUrl = "http://localhost:9090/RemoteObject.rem"; string channelUri = clientChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
public static void Main(string[] args) { //<snippet31> // Create the channel. TcpClientChannel clientChannel = new TcpClientChannel("Client", null); //</snippet31> // Register the channel. ChannelServices.RegisterChannel(clientChannel); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), "tcp://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); //<snippet32> // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "tcp://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } //</snippet32> //<snippet33> // Parse the channel's URI. string objectUrl = "tcp://localhost:9090/RemoteObject.rem"; string channelUri = clientChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); //</snippet33> // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
public void Run() { AllocConsole(); // Create the channel. TcpChannel clientChannel = new TcpChannel(); // Register the channel. ChannelServices.RegisterChannel(clientChannel, true); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( typeof(ConsoleLoggerProxy), "tcp://localhost:9090/LoggerProxy.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "tcp://localhost:" + TcpController.Port + "/LoggerProxy.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Create an instance of the remote object. ConsoleLoggerProxy service = new ConsoleLoggerProxy(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); while (true) { while (service.Count > 0) { Console.WriteLine(service.Dequeue()); } } }
[SecurityPermission(SecurityAction.Demand)] //wtf even is this public static void Main(string[] args) { // Krijo channel IpcChannel channel = new IpcChannel(); // Regjistro channel, percakto sigurine System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false); // Regjistro se qka do dergohet, dhe ku System.Runtime.Remoting.WellKnownClientTypeEntry remoteType = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(RemoteObject), "ipc://localhost:9090/RemoteObject.rem"); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownClientType(remoteType); // Krijo nje pool te mesazheve string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = channel.CreateMessageSink( "ipc://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine("URI e pool te mesazheve eshte {0}.", objectUri); if (messageSink != null) { Console.WriteLine("Lloji i pool te mesazheve eshte {0}.", messageSink.GetType().ToString()); } // Krijo instanc te RemoteObject RemoteObject service = new RemoteObject(); // Thirr metoden e RemoteObject again: Console.WriteLine("Klienti po therret remote object."); Console.WriteLine("Remote objecti eshte thirrur " + service.GetCount() + " here."); // Mundesi e thjeshte per te perseritur thirrjen Console.Write("Deshironi t'e perseritni? (1=po, 0=jo): "); int repeat = 1; try{ repeat = Int32.Parse(Console.ReadLine()); } catch { repeat = 1; } if (repeat == 1) { goto again; } }
public static void Main(string[] args) { //<snippet21> // Create the channel. IpcChannel channel = new IpcChannel(); //</snippet21> // Register the channel. System.Runtime.Remoting.Channels.ChannelServices. RegisterChannel(channel); // Register as client for remote object. System.Runtime.Remoting.WellKnownClientTypeEntry remoteType = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(RemoteObject), "ipc://localhost:9090/RemoteObject.rem"); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownClientType(remoteType); //<snippet22> // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = channel.CreateMessageSink( "ipc://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } //</snippet22> // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
public int Connect() { try { TcpChannel channel = new TcpChannel(); ChannelServices.RegisterChannel(channel, false); WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(PuppetServices), puppetMasterUrl); RemotingConfiguration.RegisterWellKnownClientType(remoteType); string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = channel.CreateMessageSink(puppetMasterUrl, null, out objectUri); services = new PuppetServices(); return(0); } catch (RemotingException e) { Console.WriteLine(e.StackTrace); return(-1); } }
public System.Runtime.Remoting.Messaging.IMessageSink GetObjectSink(MarshalByRefObject obj, System.Runtime.Remoting.Messaging.IMessageSink nextSink) { return(new InterceptSink(nextSink)); }
public System.Runtime.Remoting.Messaging.IMessageCtrl AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink) { throw null; }
public virtual new System.Runtime.Remoting.Messaging.IMessageSink GetClientContextSink(System.Runtime.Remoting.Messaging.IMessageSink nextSink) { return(default(System.Runtime.Remoting.Messaging.IMessageSink)); }
// Methods System.Runtime.Remoting.Messaging.IMessageCtrl System.Runtime.Remoting.Messaging.IMessageSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink) { (System.Threading.Thread.CurrentContext.GetProperty("ok ok") as MyContextProperty).doLog(msg); return(next.AsyncProcessMessage(msg, replySink)); }
public MyMessageSink(System.Runtime.Remoting.Messaging.IMessageSink next) { this.next = next; }
System.Runtime.Remoting.Messaging.IMessageSink System.Runtime.Remoting.Contexts.IContributeObjectSink.GetObjectSink(System.MarshalByRefObject obj, System.Runtime.Remoting.Messaging.IMessageSink nextSink) { return(new MyMessageSink(nextSink)); }
public virtual System.Runtime.Remoting.Messaging.IMessageSink GetClientContextSink(System.Runtime.Remoting.Messaging.IMessageSink nextSink) { }
public ClientChannelSinkStack(System.Runtime.Remoting.Messaging.IMessageSink replySink) { }
public static System.Runtime.Remoting.Messaging.IMessageCtrl AsyncDispatchMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink) { return(default(System.Runtime.Remoting.Messaging.IMessageCtrl)); }
public System.Runtime.Remoting.Messaging.IMessageSink GetServerContextSink(System.Runtime.Remoting.Messaging.IMessageSink nextSink) { return(default(System.Runtime.Remoting.Messaging.IMessageSink)); }
public virtual System.Runtime.Remoting.Messaging.IMessageCtrl AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink) { }