本文整理汇总了C#中IChannel.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# IChannel.Subscribe方法的具体用法?C# IChannel.Subscribe怎么用?C# IChannel.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IChannel
的用法示例。
在下文中一共展示了IChannel.Subscribe方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1
public Form1()
{
InitializeComponent();
log4net.Config.XmlConfigurator.Configure();
textBox1.Text = ConfigurationManager.AppSettings["Path"];
_application = new Application(ApplicationName);
_workerFiber = new PoolFiber();
_workerFiber.Start();
_importar = new Channel<string>();
_importar.Subscribe(_workerFiber, Work);
_notificationType = new NotificationType(SampleNotificationType, "Sample Notification");
_growl = new GrowlConnector { EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.AES };
_growl.NotificationCallback += GrowlNotificationCallback;
_growl.Register(_application, new[] { _notificationType });
folderWatch.Created += FolderWatchCreated;
folderWatch.Renamed += FolderWatchRenamed;
folderWatch.Deleted += FolderWatchDeleted;
InitDatabase();
if (!_autostart) return;
Operar(true,true);
}
示例2: Importar
protected Importar()
{
_cola = new PoolFiber();
_channel=new Channel<string>();
_cola.Start();
_channel.Subscribe(_cola, MoverArchivo);
}
示例3: FullSimTransport
public FullSimTransport()
{
// initialize the car mode to unknown so that we raised the changed event immediately
lastCarMode = CarMode.Unknown;
// get the DynamicsSimFacade
dynamicsSim = (DynamicsSimFacade)CommBuilder.GetObject(DynamicsSimFacade.ServiceName);
// set the sim state channel
simStateChannel = CommBuilder.GetChannel(OperationalSimVehicleState.ChannelName);
obstacleChannel = CommBuilder.GetChannel(SceneEstimatorObstacleChannelNames.UntrackedClusterChannelName);
vehicleChannel = CommBuilder.GetChannel(SceneEstimatorObstacleChannelNames.TrackedClusterChannelName);
// add ourself as a listern
simStateChannel.Subscribe(this);
obstacleChannel.Subscribe(this);
vehicleChannel.Subscribe(this);
}
示例4: ResgisterWithClient
public void ResgisterWithClient()
{
try
{
// 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 output channel
arbiterOutputChannel = channelFactory.GetChannel("ArbiterOutputChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast);
arbiterOutputChannelToken = arbiterOutputChannel.Subscribe(messagingListener);
// get information channel
arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast);
arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(messagingListener);
// get side obstacle channel
sideObstacleChannel = channelFactory.GetChannel("SideObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast);
sideObstacleChannelToken = sideObstacleChannel.Subscribe(messagingListener);
// get ai
this.arbiterRemote = (ArbiterAdvancedRemote)objectDirectory.Resolve("ArbiterAdvancedRemote" + this.RemotingSuffix);
// get the operational layer
this.operationalFacade = (OperationalFacade)objectDirectory.Resolve("OperationalService" + this.RemotingSuffix);
// register
RemoraOutput.WriteLine("Resgistered To Client with suffix: " + this.RemotingSuffix, OutputType.Remora);
}
catch (Exception e)
{
RemoraOutput.WriteLine("Error registering with client: " + e.ToString(), OutputType.Remora);
}
}
示例5: InitializeRemotingCommunications
/// <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");
}
示例6: Register
/// <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());
}
}
示例7: InitializeRemotingCommunications
/// <summary>
/// Initializes communications with the outside world by means of remoting
/// </summary>
public void InitializeRemotingCommunications()
{
// try to shut down in case we have already been active
this.ShutDown();
try
{
// Read the configuration file.
RemotingConfiguration.Configure("Remora.exe.config", false);
WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
// "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 listen to
vehicleStateChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.UdpMulticast);
observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel", ChannelMode.UdpMulticast);
observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel", ChannelMode.UdpMulticast);
arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel", ChannelMode.UdpMulticast);
carModeChannel = channelFactory.GetChannel("CarMode", ChannelMode.UdpMulticast);
fakeVehicleChannel = channelFactory.GetChannel("FakeVehicleChannel", ChannelMode.UdpMulticast);
// Create a channel listeners and listen on wanted channels
channelListener = new MessagingListener();
vehicleStateChannelToken = vehicleStateChannel.Subscribe(channelListener);
observedObstacleChannel.Subscribe(channelListener);
observedVehicleChannel.Subscribe(channelListener);
arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(channelListener);
carModeChannelToken = carModeChannel.Subscribe(channelListener);
fakeVehicleChannelToken = fakeVehicleChannel.Subscribe(channelListener);
// set that remoting has been successfully initialize
this.RemotingInitialized = true;
RemoraOutput.WriteLine("Successfully initialized communications");
}
catch (Exception e)
{
RemoraOutput.WriteLine(e.ToString() + "\n\n" + "Could not initialize communications, attempting to reconnect");
try
{
WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
// "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 listen to
vehicleStateChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.UdpMulticast);
observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel", ChannelMode.UdpMulticast);
observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel", ChannelMode.UdpMulticast);
arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel", ChannelMode.UdpMulticast);
carModeChannel = channelFactory.GetChannel("CarMode", ChannelMode.UdpMulticast);
fakeVehicleChannel = channelFactory.GetChannel("FakeVehicleChannel", ChannelMode.UdpMulticast);
// Create a channel listeners and listen on wanted channels
channelListener = new MessagingListener();
vehicleStateChannelToken = vehicleStateChannel.Subscribe(channelListener);
observedObstacleChannel.Subscribe(channelListener);
observedVehicleChannel.Subscribe(channelListener);
arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(channelListener);
carModeChannelToken = carModeChannel.Subscribe(channelListener);
fakeVehicleChannelToken = fakeVehicleChannel.Subscribe(channelListener);
// set that remoting has been successfully initialize
this.RemotingInitialized = true;
RemoraOutput.WriteLine("Successfully initialized communications");
}
catch (Exception e1)
{
RemoraOutput.WriteLine(e1.ToString() + "\n\n" + "Could not reinitialize nameservice communications");
try
{
// Retreive the directory of messaging channels
IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory");
// Retreive the Messaging Service channels we want to listen to
vehicleStateChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.UdpMulticast);
observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel", ChannelMode.UdpMulticast);
observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel", ChannelMode.UdpMulticast);
arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel", ChannelMode.UdpMulticast);
carModeChannel = channelFactory.GetChannel("CarMode", ChannelMode.UdpMulticast);
fakeVehicleChannel = channelFactory.GetChannel("FakeVehicleChannel", ChannelMode.UdpMulticast);
// Create a channel listeners and listen on wanted channels
channelListener = new MessagingListener();
vehicleStateChannelToken = vehicleStateChannel.Subscribe(channelListener);
observedObstacleChannel.Subscribe(channelListener);
observedVehicleChannel.Subscribe(channelListener);
arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(channelListener);
carModeChannelToken = carModeChannel.Subscribe(channelListener);
//.........这里部分代码省略.........
示例8: Configure
/// <summary>
/// Configures remoting
/// </summary>
public void Configure()
{
// configure
RemotingConfiguration.Configure("VehicleSeparationDisplay.exe.config", false);
wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
// "Activate" the NameService singleton.
objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri);
// Retreive the directory of messaging channels
channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory");
// Notify user of success
Console.WriteLine("Connection to Name Service Successful");
// get information channel
arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast);
arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(messagingListener);
}