private static void StreamCreation() { using var environment = new TcpReactiveEnvironment(); using var platform = new TcpReactivePlatform(environment); Initialize(environment, platform); var ctx = platform.CreateClient().Context; var streamFactory = ctx.GetStreamFactory <Person, Person>(Platform.Constants.Identifiers.Observable.FireHose.Uri); var stream = streamFactory.CreateAsync(new Uri("reactor://stream/foo"), null).Result; var cout = ctx.GetObserver <Person>(Platform.Constants.Identifiers.Observer.ConsoleObserver.Uri); var subscription = ctx.GetObservable <Person>(new Uri("reactor://stream/foo")).SubscribeAsync(cout, new Uri("reactor://subscription"), null).Result; var observer = ctx.GetObserver <Person>(new Uri("reactor://stream/foo")); observer.OnNextAsync(new Person { FirstName = "John", LastName = "Smith", Location = "Home" }).Wait(); observer.OnNextAsync(new Person { FirstName = "Bob", LastName = "Smith", Location = "Home" }).Wait(); observer.OnNextAsync(new Person { FirstName = "Joe", LastName = "Smith", Location = "Home" }).Wait(); Task.Delay(10000).Wait(); }
private static void Run(Func <ReactiveClientContext, Task> action) { var platform = default(IReactivePlatform); try { platform = new TcpReactivePlatform(); try { var clientProvider = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider(); var serverProvider = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider { TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full }; var props = new System.Collections.Hashtable { { "port", 0 }, { "name", System.Guid.NewGuid().ToString() }, { "typeFilterLevel", System.Runtime.Serialization.Formatters.TypeFilterLevel.Full } }; System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, clientProvider, serverProvider), ensureSecurity: false); platform.StartAsync(CancellationToken.None).Wait(); Console.WriteLine("Running demo with the TCP platform."); } #pragma warning disable CA1031 // Do not catch general exception types. (Demo code.) catch { try { platform.StopAsync(CancellationToken.None).Wait(); } catch { } platform = new InMemoryReactivePlatform(); platform.StartAsync(CancellationToken.None).Wait(); Console.WriteLine("Running demo with the in-memory platform."); } #pragma warning restore CA1031 new ReactivePlatformDeployer(platform, new Deployable.CoreDeployable()).Deploy(); action(platform.CreateClient().Context).Wait(); } finally { platform?.Dispose(); } }