private static IConnection ConfigureFootlooseConnection(ServiceLocatorDummy serviceLocator, string endpointIdentifier) { var footloose = Fluently.Configure() .UseSerializerOfType<Footloose.Serialization.TextSerializer>() .UseServiceLocator(serviceLocator) .WithServiceContracts(contracts => { //single registration contracts.WithServiceContract.RegisterOfType<ISimpleService>(); //other example; automatically register all public interfaces that are in the "*.Contracts" namespace contracts.WithAutoServiceContract.RegisterFromAssemblyOf<ISimpleService>(). Where( type => type.IsInterface && type.IsPublic && type.Namespace.EndsWith("Contracts")); }) .UseTransportChannel(Footloose.Configuration.Fluent.IpcTransportChannelConfiguration.Standard .WithTimeOut(5000) ) .WithEndpointIdentifier(endpointIdentifier) // Uri will be "ipc://user@host/<endpointIdentifier>" .CreateConnection(licenseFile); return footloose; }
private static void Main(string[] args) { var serviceLocator = new ServiceLocatorDummy(); using (var footlooseConnection = Footloose.Fluently.Configure() .UseSerializerOfType<Footloose.Serialization.TextSerializer>() .UseServiceLocator(serviceLocator) .WithServiceContracts(contracts => contracts.WithServiceContract.RegisterOfType<IServiceContract>()) .UseTransportChannel( Footloose.Configuration.Fluent.IpcTransportChannelConfiguration.Standard ) .WithEndpointIdentifier("footloose-asyncawaitservice") .CreateConnection(licenseFile)) { footlooseConnection.ExceptionOccurred += (sender, eventArgs) => Console.WriteLine("Exception occurred: {0}", eventArgs.Exception); footlooseConnection.Open(); Console.WriteLine("Footloose Connection is now listening on: {0}", footlooseConnection.EndpointIdentityManager.SelfEndpointIdentity.LocalEndpoint.Uri); Console.WriteLine("Press ENTER to exit..."); Console.ReadLine(); footlooseConnection.Close(); } }
static void Main(string[] args) { var serviceLocator = new ServiceLocatorDummy(); var endpointIdentifier = "footloose-quickstart-client"; var footlooseConnection = ConfigureFootlooseConnection(serviceLocator, endpointIdentifier); //register events footlooseConnection.ExceptionOccurred += new EventHandler<ExceptionEventArgs>(Footloose_ExceptionOccurred); footlooseConnection.MethodResponseReceived += new EventHandler<MethodResponseEventArgs>(Footloose_MethodResponseReceived); // wait for incoming method calls footlooseConnection.Open(); Console.WriteLine("Footloose started..."); Console.WriteLine("Uri of this endpoint is: " + footlooseConnection.EndpointIdentityManager.SelfEndpointIdentity.LocalEndpoint.Uri); // let try to call a method of ISimpleService on the service with event Console.WriteLine("Press Enter to start..."); Console.ReadLine(); var userName = Environment.UserName; var mashineName = Environment.MachineName; var serviceEndpointIdentifier = "footloose-quickstart-service"; var serviceUri = footlooseConnection.UriBuilder.BuildEndpointUri(userName, mashineName, serviceEndpointIdentifier); var methodCallId = footlooseConnection.Invoke<ISimpleService, string>(service => service.DoIt(), serviceUri); Console.WriteLine("Called method 'DoIt' of 'ISimpleService' on '" + serviceUri + "'. CorrelationId is '" + methodCallId + "'."); Console.ReadLine(); // let try to call a method of ISimpleService on the service with callback Console.WriteLine("Press Enter to start second run..."); Console.ReadLine(); methodCallId = footlooseConnection.Invoke<ISimpleService, string>( serice => serice.DoIt("Argument 1", "Argument 2"), response => Console.WriteLine("=======" + Environment.NewLine + "Incoming method respose: " + response.ReturnValue + Environment.NewLine + "======="), serviceUri ); Console.WriteLine("Called method 'DoIt' of 'ISimpleService' on '" + serviceUri + "'. CorrelationId is '" + methodCallId + "'."); Console.ReadLine(); footlooseConnection.Close(); footlooseConnection.Dispose(); }
private static IConnection ConfigureFootlooseConnection(ServiceLocatorDummy serviceLocator, string endpointIdentifier) { var footloose = Fluently.Configure() .UseSerializerOfType<Footloose.Serialization.TextSerializer>() .UseServiceLocator(serviceLocator) .UseTransportChannel(Footloose.Configuration.Fluent.IpcTransportChannelConfiguration.Standard .WithTimeOut(5000) ) .WithEndpointIdentifier(endpointIdentifier) // Uri will be "ipc://user@host/<endpointIdentifier>" .CreateConnection(licenseFile); return footloose; }
static void Main(string[] args) { var serviceLocator = new ServiceLocatorDummy(); var endpointIdentifier = "footloose-quickstart-service"; var footlooseConnection = ConfigureFootlooseConnection(serviceLocator, endpointIdentifier); //register events footlooseConnection.ExceptionOccurred += new EventHandler<ExceptionEventArgs>(Footloose_ExceptionOccurred); // wait for incoming method calls footlooseConnection.Open(); Console.WriteLine("Footloose started... [Press Enter to exit]"); Console.WriteLine("Uri of this endpoint is: " + footlooseConnection.EndpointIdentityManager.SelfEndpointIdentity.LocalEndpoint.Uri); Console.ReadLine(); footlooseConnection.Close(); footlooseConnection.Dispose(); }