public static void StartServer(TestContext ctx) { var serverSetup = new IpcBinaryServerProtocolSetup("OneWayTest"); ZyanHost = new ZyanComponentHost("OneWayServer", serverSetup); ZyanHost.RegisterComponent<ISampleServer, SampleServer>(); ZyanConnection = new ZyanConnection("ipc://OneWayTest/OneWayServer"); }
public override void Run() { Trace.WriteLine("Zyan.Examples.MiniChat.AzureWorkerRole entry point called", "Information"); IPEndPoint endPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["MiniChat"].IPEndpoint; TcpDuplexServerProtocolSetup protocol = new TcpDuplexServerProtocolSetup(endPoint.Port, new NicknameAuthProvider(), true); ActiveNicknames = new List<string>(); ZyanComponentHost host = new ZyanComponentHost("MiniChat", protocol); host.RegisterComponent<IMiniChat, Zyan.Examples.MiniChat.Server.MiniChat>(ActivationType.Singleton); host.ClientLoggedOn += new EventHandler<LoginEventArgs>((sender, e) => { Trace.WriteLine(string.Format("{0}: User '{1}' with IP {2} logged on.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Add(e.Identity.Name); }); host.ClientLoggedOff += new EventHandler<LoginEventArgs>((sender, e) => { Trace.WriteLine(string.Format("{0}: User '{1}' with IP {2} logged off.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Remove(e.Identity.Name); }); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); } }
static void Main(string[] args) { var host = new ZyanComponentHost("ZyanDemo", 12800); host.RegisterComponent<IHellow, HellowServer>(); Console.ReadLine(); }
public static void StartServer(TestContext ctx) { ZyanComponentHost.LegacyBlockingEvents = true; var serverSetup = new NullServerProtocolSetup(2345); ZyanHost = new ZyanComponentHost("EventsServer", serverSetup); ZyanHost.RegisterComponent <ISampleServer, SampleServer>("Singleton", ActivationType.Singleton); ZyanHost.RegisterComponent <ISampleServer, SampleServer>("SingleCall", ActivationType.SingleCall); ZyanConnection = new ZyanConnection("null://NullChannel:2345/EventsServer"); }
private EventServer() { //TcpCustomServerProtocolSetup protocol = new TcpCustomServerProtocolSetup(8083, new NullAuthenticationProvider(), true); MsmqServerProtocolSetup protocol = new MsmqServerProtocolSetup(@"private$\reqchannel"); _host = new ZyanComponentHost("EventTest", protocol); _host.RegisterComponent <IEventComponentSingleton, EventComponentSingleton>(ActivationType.Singleton); _host.RegisterComponent <IEventComponentSingleCall, EventComponentSingleCall>(ActivationType.SingleCall); _host.RegisterComponent <ICallbackComponentSingleton, CallbackComponentSingleton>(ActivationType.Singleton); _host.RegisterComponent <ICallbackComponentSingleCall, CallbackComponentSingleCall>(ActivationType.SingleCall); _host.RegisterComponent <IRequestResponseCallbackSingleCall, RequestResponseCallbackSingleCall>(ActivationType.SingleCall); }
public static void StartServer(TestContext ctx) { var serverSetup = new IpcBinaryServerProtocolSetup("MefClientTest"); ZyanHost = new ZyanComponentHost("MefClientServer", serverSetup); ZyanHost.RegisterComponent <IMefClientSample, MefClientSample>(); ZyanHost.RegisterComponent <IMefClientSample, MefClientSample2>("AnotherComponent"); ZyanConnection = new ZyanConnection("ipc://MefClientTest/MefClientServer"); MefCatalog = new ZyanCatalog(ZyanConnection); MefContainer = new CompositionContainer(MefCatalog); }
public static void StartServer(TestContext ctx) { var serverSetup = new NullServerProtocolSetup(1234); ZyanHost = new ZyanComponentHost("DuckTypingServer", serverSetup); // registration-time check ZyanHost.RegisterComponent<IDuck, Platypus>("Platypus"); // invocation-time check (object factory can't be verified during registration) ZyanHost.RegisterComponent<IDuck>("Chicken", () => new Chicken()); ZyanConnection = new ZyanConnection("null://NullChannel:1234/DuckTypingServer"); }
static void Main(string[] args) { using (var host = new ZyanComponentHost(Settings.Default.ServiceUri, Settings.Default.TcpPort)) { // queryable service host.RegisterComponent <ISampleSource, SampleSource>(); // buggy service (to demonstrate error handling) host.RegisterComponent <INamedService, BuggyService>("BuggyService"); Console.WriteLine("Linq server started. Press ENTER to quit."); Console.ReadLine(); } }
public static void StartServer(TestContext ctx) { var serverSetup = new NullServerProtocolSetup(1234); ZyanHost = new ZyanComponentHost("DuckTypingServer", serverSetup); // registration-time check ZyanHost.RegisterComponent <IDuck, Platypus>("Platypus"); // invocation-time check (object factory can't be verified during registration) ZyanHost.RegisterComponent <IDuck>("Chicken", () => new Chicken()); ZyanConnection = new ZyanConnection("null://NullChannel:1234/DuckTypingServer"); }
private TcpDuplexServerHostEnvironment() { var protocol = new TcpDuplexServerProtocolSetup(8088, new CustomAuthenticationProvider(), true); _host = new ZyanComponentHost("CustomAuthenticationTestHost_TcpDuplex", protocol); _host.RegisterComponent <ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); }
public void CallInterceptionBug() { using (var host = new ZyanComponentHost("FirstTestServer", 18888)) { host.RegisterComponent <ITestService, TestService>(ActivationType.Singleton); using (var connection = new ZyanConnection("tcp://127.0.0.1:18888/FirstTestServer") { CallInterceptionEnabled = true }) { // add a call interceptor for the TestService.TestMethod connection.CallInterceptors.Add(CallInterceptor.For <ITestService>().Action(service => service.TestMethod(), data => { data.Intercepted = true; data.MakeRemoteCall(); data.ReturnValue = nameof(TestService); })); var testService = connection.CreateProxy <ITestService>(null); var result = testService.TestMethod(); Assert.AreEqual(nameof(TestService), result); } } }
public override void Run() { Trace.WriteLine("Zyan.Examples.MiniChat.AzureWorkerRole entry point called", "Information"); IPEndPoint endPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["MiniChat"].IPEndpoint; TcpDuplexServerProtocolSetup protocol = new TcpDuplexServerProtocolSetup(endPoint.Port, new NicknameAuthProvider(), true); ActiveNicknames = new List <string>(); ZyanComponentHost host = new ZyanComponentHost("MiniChat", protocol); host.RegisterComponent <IMiniChat, Zyan.Examples.MiniChat.Server.MiniChat>(ActivationType.Singleton); host.ClientLoggedOn += new EventHandler <LoginEventArgs>((sender, e) => { Trace.WriteLine(string.Format("{0}: User '{1}' with IP {2} logged on.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Add(e.Identity.Name); }); host.ClientLoggedOff += new EventHandler <LoginEventArgs>((sender, e) => { Trace.WriteLine(string.Format("{0}: User '{1}' with IP {2} logged off.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Remove(e.Identity.Name); }); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); } }
private static ZyanComponentHost CreateZyanHost(int port, string name) { ZyanSettings.LegacyBlockingEvents = true; ZyanSettings.LegacyBlockingSubscriptions = true; ZyanSettings.LegacyUnprotectedEventHandlers = true; var serverSetup = new NullServerProtocolSetup(port); var zyanHost = new ZyanComponentHost(name, serverSetup); //, DummySessionManager); zyanHost.RegisterComponent <ISampleServer, SampleServer <int> >("Singleton", ActivationType.Singleton); zyanHost.RegisterComponent <ISampleServer, SampleServer <short> >("Singleton2", ActivationType.Singleton); zyanHost.RegisterComponent <ISampleServer, SampleServer <long> >("Singleton3", ActivationType.Singleton); zyanHost.RegisterComponent <ISampleServer, SampleServer <byte> >("SingleCall", ActivationType.SingleCall); zyanHost.RegisterComponent <ISampleServer, SampleServer <char> >("SingletonExternal", new SampleServer <char>()); return(zyanHost); }
private TcpDuplexServerHostEnvironment() { var protocol = new TcpDuplexServerProtocolSetup(8092, new NullAuthenticationProvider(), true); _host = new ZyanComponentHost("TcpExConnectionLockRegressionTestHost_TcpDuplex", protocol); _host.RegisterComponent <ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); }
public static void StartServer(TestContext ctx) { var serverSetup = new IpcBinaryServerProtocolSetup("StreamsTest"); ZyanHost = new ZyanComponentHost("SampleStreamServer", serverSetup); ZyanHost.RegisterComponent<IStreamService, StreamService>(); ZyanConnection = new ZyanConnection("ipc://StreamsTest/SampleStreamServer"); }
private void TestVulnerability(string hostName, string serverUrl, IServerProtocolSetup serverSetup, IClientProtocolSetup clientSetup, object payload) { ZyanSettings.DisableUrlRandomization = true; using (var zyanHost = new ZyanComponentHost(hostName, serverSetup)) { zyanHost.RegisterComponent <ISampleServer, SampleServer>(ActivationType.Singleton); var credentials = new Hashtable { { "Login", "hacker" }, { "Password", "secret" }, { string.Empty, payload } }; using (var zyanConnection = new ZyanConnection(serverUrl, clientSetup)) { var proxy = zyanConnection.CreateProxy <ISampleServer>(); AssertEx.Throws <SecurityException>(() => proxy.TestMethod(payload)); } // should throw AssertEx.Throws <SecurityException>(() => { using (new ZyanConnection(serverUrl, clientSetup, credentials, true, true)) { } }); } }
private TcpSimplexServerHostEnvironment() { var protocol = new TcpCustomServerProtocolSetup(8085, new NullAuthenticationProvider(), true); _host = new ZyanComponentHost("RecreateClientConnectionTestHost_TcpSimplex", protocol); _host.RegisterComponent <ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); }
public void RefreshRegisteredComponentsTest() { using (var host = new ZyanComponentHost("RefreshTest", new NullServerProtocolSetup(123))) using (var conn = new ZyanConnection("null://NullChannel:123/RefreshTest")) { // this component is registered after connection is established var componentName = Guid.NewGuid().ToString(); host.RegisterComponent <ISampleServer, SampleServer>(componentName); try { // proxy cannot be created because connection doesn't know about the component var proxy1 = conn.CreateProxy <ISampleServer>(componentName); Assert.Fail("Component is not yet known for ZyanConnection."); } catch (ApplicationException) { } // refresh the list of registered components and create a proxy conn.RefreshRegisteredComponents(); var proxy2 = conn.CreateProxy <ISampleServer>(componentName); var echoString = "Hello there"; var result = proxy2.Echo(echoString); Assert.AreEqual(echoString, result); } }
public static void StartServer(TestContext ctx) { var serverSetup = new IpcBinaryServerProtocolSetup("OneWayTest"); ZyanHost = new ZyanComponentHost("OneWayServer", serverSetup); ZyanHost.RegisterComponent <ISampleServer, SampleServer>(); ZyanConnection = new ZyanConnection("ipc://OneWayTest/OneWayServer"); }
public static void StartServer(TestContext ctx) { var serverSetup = new IpcBinaryServerProtocolSetup("StreamsTest"); ZyanHost = new ZyanComponentHost("SampleStreamServer", serverSetup); ZyanHost.RegisterComponent <IStreamService, StreamService>(); ZyanConnection = new ZyanConnection("ipc://StreamsTest/SampleStreamServer"); }
public static void StartServer(TestContext ctx) { ZyanSettings.LegacyBlockingEvents = true; ZyanSettings.LegacyBlockingSubscriptions = true; ZyanSettings.LegacyUnprotectedEventHandlers = true; var serverSetup = new NullServerProtocolSetup(2345); ZyanHost = new ZyanComponentHost("EventsServer", serverSetup); ZyanHost.RegisterComponent <ISampleServer, SampleServer <int> >("Singleton", ActivationType.Singleton); ZyanHost.RegisterComponent <ISampleServer, SampleServer <short> >("Singleton2", ActivationType.Singleton); ZyanHost.RegisterComponent <ISampleServer, SampleServer <long> >("Singleton3", ActivationType.Singleton); ZyanHost.RegisterComponent <ISampleServer, SampleServer <byte> >("SingleCall", ActivationType.SingleCall); ZyanHost.RegisterComponent <ISampleServer, SampleServer <char> >("SingletonExternal", new SampleServer <char>()); ZyanConnection = new ZyanConnection("null://NullChannel:2345/EventsServer"); }
public static void StartServer(TestContext ctx) { var serverSetup = new NullServerProtocolSetup(4321); ZyanHost = new ZyanComponentHost("GenericServer", serverSetup); ZyanHost.RegisterComponent <ISampleServer, SampleServer>(); ZyanConnection = new ZyanConnection("null://NullChannel:4321/GenericServer"); }
public static void Main(string[] args) { var protocol = new TcpDuplexServerProtocolSetup(12345, new NullAuthenticationProvider(), true); using (var host = new ZyanComponentHost("Sample", protocol)) { host.RegisterComponent<ISampleService, SampleService>(); Console.WriteLine("Server started. Press Enter to exit."); Console.ReadLine(); } }
private TcpSimplexServerHostEnvironment() { // use custom SRP parameters var accounts = new SampleAccountRepository(CustomSrpParameters); var provider = new SrpAuthenticationProvider(accounts, CustomSrpParameters); var protocol = new TcpCustomServerProtocolSetup(8091, provider, true); _host = new ZyanComponentHost("CustomAuthenticationTestHost_TcpSimplex", protocol); _host.RegisterComponent <ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); }
public static void Main(string[] args) { var protocol = new TcpDuplexServerProtocolSetup(12345, new NullAuthenticationProvider(), true); using (var host = new ZyanComponentHost("Sample", protocol)) { host.RegisterComponent <ISampleService, SampleService>(); Console.WriteLine("Server started. Press Enter to exit."); Console.ReadLine(); } }
public static void StartServer(TestContext ctx) { ZyanConnection.AllowUrlRandomization = false; var serverSetup = new IpcBinaryServerProtocolSetup("ZyanProxyTest"); ZyanHost = new ZyanComponentHost("ZyanProxyServer", serverSetup); ZyanHost.RegisterComponent<ISampleServer, SampleServer>(ActivationType.Singleton); var clientSetup = new IpcBinaryClientProtocolSetup(); ZyanConnection = new ZyanConnection("ipc://ZyanProxyTest/ZyanProxyServer", clientSetup); }
static void Main(string[] args) { var protocol = new TcpDuplexServerProtocolSetup(8081, null, true); using (var host = new ZyanComponentHost("WhisperChat", protocol)) { host.RegisterComponent <IWhisperChatService, WhisperChatService>(ActivationType.SingleCall); Console.WriteLine("Server running."); Console.ReadLine(); } }
public static void StartServer(TestContext ctx) { ZyanComponentHost.LegacyBlockingEvents = true; var serverSetup = new NullServerProtocolSetup(3456); ZyanHost = new ZyanComponentHost("CallInterceptorServer", serverSetup); ZyanHost.RegisterComponent <IInterceptableComponent, InterceptableComponent>(ActivationType.Singleton); ZyanConnection = new ZyanConnection("null://NullChannel:3456/CallInterceptorServer"); ZyanConnection.CallInterceptionEnabled = true; }
static void Main(string[] args) { var protocol = new TcpDuplexServerProtocolSetup(8081,null,true); using (var host = new ZyanComponentHost("WhisperChat", protocol)) { host.RegisterComponent<IWhisperChatService, WhisperChatService>(ActivationType.SingleCall); Console.WriteLine("Server running."); Console.ReadLine(); } }
public static void StartServer(TestContext ctx) { ZyanSettings.LegacyBlockingEvents = true; ZyanSettings.LegacyBlockingSubscriptions = true; var serverSetup = new NullServerProtocolSetup(4567); ZyanHost = new ZyanComponentHost("EventFilterServer", serverSetup); ZyanHost.RegisterComponent <ISampleServer, SampleServer>(); ZyanConnection = new ZyanConnection("null://NullChannel:4567/EventFilterServer"); }
static void Main(string[] args) { HttpCustomServerProtocolSetup protocol = new HttpCustomServerProtocolSetup(8081, new BasicWindowsAuthProvider(), true); using (ZyanComponentHost host = new ZyanComponentHost("EbcCalc", protocol)) { host.SessionManager.SessionAgeLimit = 2; host.RegisterComponent<ICalculator, Calculator>(); Console.ReadLine(); } }
public static void StartServer(TestContext ctx) { ZyanConnection.AllowUrlRandomization = false; var serverSetup = new IpcBinaryServerProtocolSetup("ZyanProxyTest"); ZyanHost = new ZyanComponentHost("ZyanProxyServer", serverSetup); ZyanHost.RegisterComponent <ISampleServer, SampleServer>(ActivationType.Singleton); var clientSetup = new IpcBinaryClientProtocolSetup(); ZyanConnection = new ZyanConnection("ipc://ZyanProxyTest/ZyanProxyServer", clientSetup); }
static void Main(string[] args) { HttpCustomServerProtocolSetup protocol = new HttpCustomServerProtocolSetup(8081, new BasicWindowsAuthProvider(), true); using (ZyanComponentHost host = new ZyanComponentHost("EbcCalc", protocol)) { host.SessionManager.SessionAgeLimit = 2; host.RegisterComponent <ICalculator, Calculator>(); Console.ReadLine(); } }
public void CreateDisposeAndRecreateComponentHostForTcpSimplexChannel() { var protocol = new TcpCustomServerProtocolSetup(8087, new NullAuthenticationProvider(), true); using (var host = new ZyanComponentHost("RecreateClientConnectionTestHost_TcpSimplex", protocol)) { host.RegisterComponent <ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); } using (var host = new ZyanComponentHost("RecreateClientConnectionTestHost_TcpSimplex", protocol)) { host.RegisterComponent <ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); } }
static void Main(string[] args) { using (var transport = new WcfServerTransportAdapter() { BaseAddress = "net.tcp://localhost:9091" }) { var protocol = ServerProtocolSetup.WithChannel(x => transport); using (var host = new ZyanComponentHost("HelloWcf", protocol)) { host.RegisterComponent<IEchoService, EchoService>(); Console.WriteLine("Server läuft!"); Console.ReadLine(); } } }
public void CreateDisposeAndRecreateComponentHostForTcpDuplexChannel() { var protocol = new TcpDuplexServerProtocolSetup(8086, new NullAuthenticationProvider(), true); using (var host = new ZyanComponentHost("RecreateClientConnectionTestHost_TcpDuplex", protocol)) { host.RegisterComponent<ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); } using (var host = new ZyanComponentHost("RecreateClientConnectionTestHost_TcpDuplex", protocol)) { host.RegisterComponent<ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); } }
private void RegisterComponent(int port, string name, RemoteMonitor instance) { TcpDuplexServerProtocolSetup protocol = new TcpDuplexServerProtocolSetup(port); _znHost = new ZyanComponentHost(name, protocol); //_znHost.EnableDiscovery(); //_znHost.RegisterComponent<IMonitor, RemoteMonitor>(ActivationType.Singleton); _znHost.RegisterComponent <IMonitor, RemoteMonitor>(instance); _znHost.ClientLoggedOn += ClientLoggedOn; _znHost.ClientLoggedOff += ClientLoggedOff; Builder.Output(string.Format(ClassName + ": registrado componente {0} en puerto {1}.", name, port), TraceEventType.Verbose); }
static void Main(string[] args) { // create a new Zyan ComponentHost using (var host = new ZyanComponentHost("DynamicEbcResponses", 4567)) { // register the service implementation by its interface host.RegisterComponent<IService>( () => new Service(), ActivationType.SingleCall ); // print information and keep server process running Console.WriteLine("Stated Zyan Server on localhost:4567, press any key to stop."); Console.ReadKey(); } }
static void Main(string[] args) { // create a new Zyan ComponentHost using (var host = new ZyanComponentHost("DynamicEbcResponses", 4567)) { // register the service implementation by its interface host.RegisterComponent <IService>( () => new Service(), ActivationType.SingleCall ); // print information and keep server process running Console.WriteLine("Stated Zyan Server on localhost:4567, press any key to stop."); Console.ReadKey(); } }
static void Main(string[] args) { using (var transport = new WcfServerTransportAdapter() { BaseAddress = "net.tcp://localhost:9091" }) { var protocol = ServerProtocolSetup.WithChannel(x => transport); using (var host = new ZyanComponentHost("HelloWcf", protocol)) { host.RegisterComponent <IEchoService, EchoService>(); Console.WriteLine("Server läuft!"); Console.ReadLine(); } } }
public static void StartServer(TestContext ctx) { var serverSetup = new NullServerProtocolSetup(5432); ZyanHost = new ZyanComponentHost("SampleQueryableServer", serverSetup); ZyanHost.RegisterComponent <ISampleService, SampleService>(); ZyanHost.RegisterComponent <IObjectSource, SampleObjectSource>(new SampleObjectSource(new[] { "Hello", "World!" })); ZyanHost.RegisterComponent <IObjectSource, SampleObjectSource>("Sample1", new SampleObjectSource(new[] { "this", "is", "an", "example" })); ZyanHost.RegisterComponent <IObjectSource, SampleObjectSource>("Sample6"); ZyanHost.RegisterComponent <IObjectSource, SampleObjectSource>("Sample7", ActivationType.SingleCall); ZyanHost.RegisterComponent <IEntitySource, DataWrapper>("DbSample", DataWrapper = new DataWrapper()); ZyanHost.RegisterComponent <ISampleMethodSource, SampleMethodSource>("Disposable", ActivationType.SingleCall); ZyanConnection = new ZyanConnection("null://NullChannel:5432/SampleQueryableServer"); }
public void ExternalComponentCatalog_IsNotDisposed() { var disposed = false; var server = new ReleasableComponent { Handler = () => disposed = true }; Assert.IsFalse(disposed); var serverSetup = new IpcBinaryServerProtocolSetup("CleanupTest2"); using (var catalog = new ComponentCatalog()) using (var host = new ZyanComponentHost("SampleServer2", serverSetup, new InProcSessionManager(), catalog)) { host.RegisterComponent<ISampleComponent, ReleasableComponent>( server, s => ((ReleasableComponent)s).Release()); Assert.IsFalse(disposed); server.Release(); Assert.IsTrue(disposed); } }
public void OwnedComponentCatalog_IsDisposed() { var disposed = false; var server = new ReleasableComponent { Handler = () => disposed = true }; Assert.IsFalse(disposed); var serverSetup = new IpcBinaryServerProtocolSetup("CleanupTest1"); using (var host = new ZyanComponentHost("SampleServer1", serverSetup)) { host.RegisterComponent <ISampleComponent, ReleasableComponent>( server, s => ((ReleasableComponent)s).Release()); } Assert.IsTrue(disposed); }
static void Main(string[] args) { ActiveNicknames = new List<string>(); TcpDuplexServerProtocolSetup protocol = new TcpDuplexServerProtocolSetup(Properties.Settings.Default.TcpPort, new NicknameAuthProvider(), true); using (ZyanComponentHost host = new ZyanComponentHost("MiniChat", protocol)) { host.PollingEventTracingEnabled = true; host.ClientHeartbeatReceived += new EventHandler<ClientHeartbeatEventArgs>(host_ClientHeartbeatReceived); host.RegisterComponent<IMiniChat, MiniChat>(ActivationType.Singleton); host.ClientLoggedOn += new EventHandler<LoginEventArgs>((sender, e) => { Console.WriteLine(string.Format("{0}: User '{1}' with IP {2} logged on.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Add(e.Identity.Name); }); host.ClientLoggedOff += new EventHandler<LoginEventArgs>((sender, e) => { Console.WriteLine(string.Format("{0}: User '{1}' with IP {2} logged off.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Remove(e.Identity.Name); }); host.ClientSessionTerminated += new EventHandler<LoginEventArgs>((sender, e) => { Console.WriteLine(string.Format("{0}: User '{1}' with IP {2} was kicked due to inactivity.", e.Timestamp.ToString(), e.Identity.Name, e.ClientAddress)); ActiveNicknames.Remove(e.Identity.Name); }); host.EnableDiscovery(); Console.WriteLine("Chat server started. Press Enter to exit."); Console.ReadLine(); } }
private EventServer() { //TcpCustomServerProtocolSetup protocol = new TcpCustomServerProtocolSetup(8083, new NullAuthenticationProvider(), true); MsmqServerProtocolSetup protocol = new MsmqServerProtocolSetup(@"private$\reqchannel"); _host = new ZyanComponentHost("EventTest", protocol); _host.RegisterComponent<IEventComponentSingleton, EventComponentSingleton>(ActivationType.Singleton); _host.RegisterComponent<IEventComponentSingleCall, EventComponentSingleCall>(ActivationType.SingleCall); _host.RegisterComponent<ICallbackComponentSingleton, CallbackComponentSingleton>(ActivationType.Singleton); _host.RegisterComponent<ICallbackComponentSingleCall, CallbackComponentSingleCall>(ActivationType.SingleCall); _host.RegisterComponent<IRequestResponseCallbackSingleCall, RequestResponseCallbackSingleCall>(ActivationType.SingleCall); }
public void OwnedComponentCatalog_IsDisposed() { var disposed = false; var server = new ReleasableComponent { Handler = () => disposed = true }; Assert.IsFalse(disposed); var serverSetup = new IpcBinaryServerProtocolSetup("CleanupTest1"); using (var host = new ZyanComponentHost("SampleServer1", serverSetup)) { host.RegisterComponent<ISampleComponent, ReleasableComponent>( server, s => ((ReleasableComponent)s).Release()); } Assert.IsTrue(disposed); }
public void RefreshRegisteredComponentsTest() { using (var host = new ZyanComponentHost("RefreshTest", new NullServerProtocolSetup(123))) using (var conn = new ZyanConnection("null://NullChannel:123/RefreshTest")) { // this component is registered after connection is established var componentName = Guid.NewGuid().ToString(); host.RegisterComponent<ISampleServer, SampleServer>(componentName); try { // proxy cannot be created because connection doesn't know about the component var proxy1 = conn.CreateProxy<ISampleServer>(componentName); Assert.Fail("Component is not yet known for ZyanConnection."); } catch (ApplicationException) { } // refresh the list of registered components and create a proxy conn.RefreshRegisteredComponents(); var proxy2 = conn.CreateProxy<ISampleServer>(componentName); var echoString = "Hello there"; var result = proxy2.Echo(echoString); Assert.AreEqual(echoString, result); } }
public static void StartServer(TestContext ctx) { ZyanComponentHost.LegacyBlockingEvents = true; var serverSetup = new NullServerProtocolSetup(2345); ZyanHost = new ZyanComponentHost("EventsServer", serverSetup); ZyanHost.RegisterComponent<ISampleServer, SampleServer>("Singleton", ActivationType.Singleton); ZyanHost.RegisterComponent<ISampleServer, SampleServer>("SingleCall", ActivationType.SingleCall); ZyanConnection = new ZyanConnection("null://NullChannel:2345/EventsServer"); }
private TcpSimplexServerHostEnvironment() { var protocol = new TcpCustomServerProtocolSetup(8085, new NullAuthenticationProvider(), true); _host = new ZyanComponentHost("RecreateClientConnectionTestHost_TcpSimplex", protocol); _host.RegisterComponent<ISampleServer, SampleServer>("SampleServer", ActivationType.SingleCall); }
public void TestGenericWrapperOverZyan() { var serverProto = new IpcBinaryServerProtocolSetup("Test"); var clientProto = new IpcBinaryClientProtocolSetup(); var host = new ZyanComponentHost("TestServer", serverProto); host.RegisterComponent<INonGenericInterface>(() => new NonGenericWrapper(new GenericClass()), ActivationType.Singleton); var conn = new ZyanConnection("ipc://Test/TestServer"); var proxy = conn.CreateProxy<INonGenericInterface>(); // same as usual var test = new GenericWrapper(proxy); var prioritySet = false; // GetDefault Assert.AreEqual(default(int), test.GetDefault<int>()); Assert.AreEqual(default(string), test.GetDefault<string>()); Assert.AreEqual(default(Guid), test.GetDefault<Guid>()); // Equals Assert.IsTrue(test.Equals(123, 123)); Assert.IsFalse(test.Equals("Some", null)); // GetVersion Assert.AreEqual("DoSomething wasn't called yet", test.GetVersion()); // DoSomething test.DoSomething(123, 'x', "y"); Assert.AreEqual("DoSomething: A = 123, B = x, C = y", test.GetVersion()); // Compute var dt = test.Compute<Guid, DateTime>(Guid.Empty, 123, "123"); Assert.AreEqual(default(DateTime), dt); // CreateGuid var guid = test.CreateGuid(dt, 12345); Assert.AreEqual("00003039-0001-0001-0000-000000000000", guid.ToString()); // LastDate Assert.AreEqual(dt, test.LastDate); test.LastDate = dt = DateTime.Now; Assert.AreEqual(dt, test.LastDate); // Name Assert.AreEqual("GenericClass, priority = 123", test.Name); // add OnPrioritySet EventHandler<EventArgs> handler = (s, a) => prioritySet = true; test.OnPrioritySet += handler; Assert.IsFalse(prioritySet); // Priority test.Priority = 321; Assert.IsTrue(prioritySet); Assert.AreEqual("GenericClass, priority = 321", test.Name); // remove OnPrioritySet prioritySet = false; test.OnPrioritySet -= handler; test.Priority = 111; Assert.IsFalse(prioritySet); }