/// <summary> /// Initializes communications with the outside world by means of remoting /// </summary> private void InitializeRemotingCommunications() { // Read the configuration file. RemotingConfiguration.Configure("..\\..\\App.config", false); WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Bind the operational test faceade objectDirectory.Rebind(this, "OperationalTestFacade"); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to listen to rndfChannel = channelFactory.GetChannel("RndfNetworkChannel", ChannelMode.Bytestream); mdfChannel = channelFactory.GetChannel("MdfChannel", ChannelMode.Bytestream); positionChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.Bytestream); testStringChannel = channelFactory.GetChannel("TestStringChannel", ChannelMode.Vanilla); // Create a channel listeners and listen on wanted channels channelListener = new MessagingListener(); rndfToken = rndfChannel.Subscribe(channelListener); mdfToken = mdfChannel.Subscribe(channelListener); //positionToken = positionChannel.Subscribe(channelListener); testStringToken = testStringChannel.Subscribe(new StringListener()); // Show that the navigation system is ready and waiting for input Console.WriteLine(" > Remoting Communication Initialized"); }
/// <summary> /// Registers with the correct services /// </summary> public void Register() { try { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to push to simulationMessageChannel = channelFactory.GetChannel("SimulationMessageChannel", ChannelMode.UdpMulticast); // Rebind the Simulator as the simulator remote facade server objectDirectory.Rebind(this, "SimulationServer"); // Notify user of success SimulatorOutput.WriteLine("Connection to Name Service and Registration of Simulation Server as Simulator Facade Successful"); // let clients know the sim is alive simulationMessageChannel.PublishUnreliably(SimulationMessage.Alive); } catch (Exception e) { SimulatorOutput.WriteLine("Error Registering With Remoting Services: " + e.ToString()); } }
/// <summary> /// Registers with the correct services /// </summary> public void Register() { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // register the core as implementing the arbiter advanced remote facade objectDirectory.Rebind(this.arbiterCore, "ArbiterAdvancedRemote" + this.RemotingSuffix); // shutdown old channels this.Shutdown(); // get vehicle state channel vehicleStateChannel = channelFactory.GetChannel("ArbiterSceneEstimatorPositionChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); vehicleStateChannelToken = vehicleStateChannel.Subscribe(messagingListener); // get observed obstacle channel observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); observedObstacleChannelToken = observedObstacleChannel.Subscribe(messagingListener); // get observed vehicle channel observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); observedVehicleChannelToken = observedVehicleChannel.Subscribe(messagingListener); // get vehicle speed channel vehicleSpeedChannel = channelFactory.GetChannel("VehicleSpeedChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); vehicleSpeedChannelToken = vehicleSpeedChannel.Subscribe(messagingListener); // get side obstacle channel sideObstacleChannel = channelFactory.GetChannel("SideObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); sideObstacleChannelToken = sideObstacleChannel.Subscribe(messagingListener); // get output channel if (arbiterOutputChannel != null) { arbiterOutputChannel.Dispose(); } arbiterOutputChannel = channelFactory.GetChannel("ArbiterOutputChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); // get information channel if (arbiterInformationChannel != null) { arbiterInformationChannel.Dispose(); } arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); // get the operational layer this.operationalFacade = (OperationalFacade)objectDirectory.Resolve("OperationalService" + this.RemotingSuffix); this.operationalFacade.RegisterListener(this); this.SendProjection(); // try connecting to the test facade this.TryOperationalTestFacadeConnect(); }
private void Connect(ObjectDirectory od) { // get the channel for the sim state IChannelFactory channelFactory = (IChannelFactory)od.Resolve("ChannelFactory"); operationalStateChannel = channelFactory.GetChannel("OperationalSimState_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // publish ourself to the object directory od.Rebind(this, "DynamicsSim_" + SimulatorClient.MachineName); }
static void Main(string[] args) { // Read the configuration file. RemotingConfiguration.Configure("..\\..\\ProxyService.exe.config", false); WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. ObjectDirectory od = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Bind the facades of components we implement. od.Rebind(Arbiter.FacadeImpl.Instance, "Arbiter"); Console.WriteLine("Waiting"); // Enter the main event loop... Console.ReadLine(); }
public void TryConnect() { try { // configure RemotingConfiguration.Configure("FakeOperational.exe.config", false); WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. ObjectDirectory objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // register the core as implementing the arbiter advanced remote facade objectDirectory.Rebind(this, "OperationalService_" + Environment.MachineName); Console.WriteLine("Connection and Registration Success"); } catch (Exception e) { Console.WriteLine("Connection error: \n" + e.ToString()); } }
/// <summary> /// Registers with the correct services /// </summary> public void Register() { try { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to interact with if (simulationMessageChannel != null) { simulationMessageChannel.Dispose(); } simulationMessageChannel = channelFactory.GetChannel("SimulationMessageChannel", ChannelMode.UdpMulticast); // Listen to channels we wish to listen to simulationMessageChannelToken = simulationMessageChannel.Subscribe(this.messagingListener); // Rebind the Simulator as the simulator remote facade server objectDirectory.Rebind(this.client, this.client.Name()); // get vehicle state channel if (vehicleStateChannel != null) { vehicleStateChannel.Dispose(); } vehicleStateChannel = channelFactory.GetChannel("ArbiterSceneEstimatorPositionChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get observed obstacle channel if (observedObstacleChannel != null) { observedObstacleChannel.Dispose(); } observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get observed vehicle channel if (observedVehicleChannel != null) { observedVehicleChannel.Dispose(); } observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get vehicle speed channel if (vehicleSpeedChannel != null) { vehicleSpeedChannel.Dispose(); } vehicleSpeedChannel = channelFactory.GetChannel("VehicleSpeedChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get the local road estimate channel if (localRoadChannel != null) { localRoadChannel.Dispose(); } localRoadChannel = channelFactory.GetChannel(LocalRoadEstimate.ChannelName + "_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // Notify user of success Console.WriteLine(DateTime.Now.ToString() + ": Connection to Name Service and Registration of Simulation Client Successful"); } catch (Exception e) { // notify Console.WriteLine(DateTime.Now.ToString() + ": Error Registering With Remoting Services: " + e.ToString()); } }
public static void BindObject(string baseName, MarshalByRefObject obj) { // bind the object to the object directory objectDirectory.Rebind(obj, BuildServiceName(baseName)); }