/// <summary> /// Creates server endpoint instance. /// </summary> /// <param name="listener">Server connection listener used to listen for incoming connections.</param> /// <param name="config">Server configuration.</param> protected ServerEndpoint(IServerConnectionListener listener, IServerConfig config) { _listener = listener; _config = config; _connectionConfig = new ConnectionConfig { RemoteExecutorFactory = _config.RemoteExecutorFactory, TaskScheduler = _config.TaskScheduler }; _listener.OnChannelOpen += OnChannelOpen; BroadcastRemoteExecutor = config.RemoteExecutorFactory.CreateBroadcastRemoteExecutor(listener.BroadcastChannel); }
public void SetUp() { Configurator.Configure(); _connectionListener = new LidgrenServerConnectionListener(_applicationId, _listenAddress, _port, new BinaryMessageSerializer(), new UnencryptedCryptoProviderResolver()); _dispatcher = new OperationDispatcher(); _dispatcher.RegisterHandler <ICalculator>(new Calculator()); _dispatcher.RegisterHandler <IGreeter>(new Greeter()); _server = new GenericServerEndpoint(_connectionListener, new ServerConfig(), () => _dispatcher); _server.Start(); }
private IServerEndpoint CreateServer(ILidgrenCryptoProviderResolver providerResolver) { DefaultConfig.MessageSerializer = new BinaryMessageSerializer(); DefaultConfig.MessageFactory = new DefaultMessageFactory(); DefaultConfig.RemoteExecutorFactory = new RemoteExecutorFactory(); DefaultConfig.TaskScheduler = new AsyncTaskScheduler(); TransportLayerResolver.Register(new LidgrenProvider(providerResolver)); _connectionListener = new LidgrenServerConnectionListener(_applicationId, _listenAddress, _port, new BinaryMessageSerializer(), providerResolver); _dispatcher = new OperationDispatcher(); _dispatcher.RegisterHandler <ICalculator>(new Calculator()); _dispatcher.RegisterHandler <IGreeter>(new Greeter()); IServerEndpoint server = new GenericServerEndpoint(_connectionListener, new ServerConfig(), () => _dispatcher); server.Start(); return(server); }
public void SetUp() { _connectionListener = MockRepository.GenerateMock <IServerConnectionListener>(); _remoteExecutorFactory = MockRepository.GenerateMock <IRemoteExecutorFactory>(); _taskScheduler = MockRepository.GenerateMock <ITaskScheduler>(); _config = MockRepository.GenerateMock <IServerConfig>(); _config.Stub(c => c.MaxConnections).Return(10); _config.Stub(c => c.RemoteExecutorFactory).Return(_remoteExecutorFactory); _config.Stub(c => c.TaskScheduler).Return(_taskScheduler); _operationDispatcher = MockRepository.GenerateMock <IOperationDispatcher>(); _operationDispatcher.Stub(d => d.MessageDispatcher).Return(MockRepository.GenerateMock <IMessageDispatcher>()); _broadcastChannel = MockRepository.GenerateMock <IBroadcastChannel>(); _connectionListener.Stub(l => l.BroadcastChannel).Return(_broadcastChannel); _broadcastExecutor = MockRepository.GenerateMock <IBroadcastRemoteExecutor>(); _remoteExecutorFactory.Stub(f => f.CreateBroadcastRemoteExecutor(_broadcastChannel)).Return(_broadcastExecutor); _subject = new GenericServerEndpoint(_connectionListener, _config, () => _operationDispatcher); }
public void ValidateIpEndPointProvision() { connectionListener = new LidgrenServerConnectionListener(applicationId, ListenAddress, Port, new BinaryMessageSerializer(), new UnencryptedCryptoProviderResolver()); dispatcher = new OperationDispatcher(); IPEndPoint senderEndPoint = null; IPEndPoint clientEndPoint = null; dispatcher.RegisterHandler <IEndPointProvisioner>(new EndPointProvisioner { OnStuff = e => senderEndPoint = e }); server = new GenericServerEndpoint(connectionListener, new ServerConfig(), () => dispatcher); server.Start(); using (ClientConnection client = CreateClientConnection()) { client.Open(); clientEndPoint = client.GetClientEndpoint(); client.RemoteExecutor.Create <IEndPointProvisioner>().DoStuff(null); } server.Dispose(); Assert.AreEqual(clientEndPoint, senderEndPoint); }
/// <summary> /// Creates generic server endpoint. /// </summary> /// <param name="listener">Server connection listener used to listen for incoming connections.</param> /// <param name="config">Server configuration.</param> /// <param name="operationDispatcherCreator">Method used to create operation dispatcher for new connection.</param> /// <param name="connectionInitializer">Method used to initialize new connection. If null, no action is taken.</param> public GenericServerEndpoint(IServerConnectionListener listener, IServerConfig config, Func <IOperationDispatcher> operationDispatcherCreator, Action <IServerEndpoint, IRemoteConnection> connectionInitializer = null) : base(listener, config) { Initialize(operationDispatcherCreator, connectionInitializer); }
/// <summary> /// Creates generic server endpoint with default server configuration (<see cref="DefaultConfig"/>). /// </summary> /// <param name="listener">Server connection listener used to listen for incoming connections.</param> /// <param name="operationDispatcherCreator">Method used to create operation dispatcher for new connection.</param> /// <param name="connectionInitializer">Method used to initialize new connection. If null, no action is taken.</param> public GenericServerEndpoint(IServerConnectionListener listener, Func <IOperationDispatcher> operationDispatcherCreator, Action <IServerEndpoint, IRemoteConnection> connectionInitializer = null) : this(listener, new ServerConfig(), operationDispatcherCreator, connectionInitializer) { }
private ITransportLayerProvider StubProvider(string scheme, IClientChannel clientChannel, IServerConnectionListener connectionListener) { var provider = MockRepository.GenerateMock <ITransportLayerProvider>(); provider.Stub(p => p.Scheme).Return(scheme); provider.Stub(p => p.CreateClientChannelFor(Arg <Uri> .Is.Anything)).Return(clientChannel); provider.Stub(p => p.CreateConnectionListenerFor(Arg <Uri> .Is.Anything)).Return(connectionListener); return(provider); }
/// <summary> /// Creates stateful server endpoint. /// </summary> /// <param name="listener">Server connection listener used to listen for incoming connections.</param> /// <param name="config">Server configuration.</param> protected StatefulServerEndpoint(IServerConnectionListener listener, IServerConfig config) : base(listener, config) { OnConnectionInitialize += InitializeConnection; }
/// <summary> /// Creates stateless server endpoint. /// </summary> /// <param name="listener">Server connection listener used to listen for incoming connections.</param> /// <param name="dispatcher">Operation dispatcher that would be used for all connections.</param> /// <param name="config">Server configuration.</param> public StatelessServerEndpoint(IServerConnectionListener listener, IOperationDispatcher dispatcher, IServerConfig config) : base(listener, config) { _dispatcher = dispatcher; }
/// <summary> /// Creates stateless server endpoint with default server configuration (<see cref="DefaultConfig"/>). /// </summary> /// <param name="listener">Server connection listener used to listen for incoming connections.</param> /// <param name="dispatcher">Operation dispatcher that would be used for all connections.</param> public StatelessServerEndpoint(IServerConnectionListener listener, IOperationDispatcher dispatcher) : this(listener, dispatcher, new ServerConfig()) { }
/// <summary>initalize the channel</summary> private void InitChannel() { if (m_port < 0) { throw new ArgumentException("illegal port to listen on: " + m_port); } Ch.Elca.Iiop.Marshalling.ArgumentsSerializerFactory argumentSerializerFactory = omg.org.CORBA.OrbServices.GetSingleton().ArgumentsSerializerFactory; CodecFactory codecFactory = omg.org.CORBA.OrbServices.GetSingleton().CodecFactory; m_codec = codecFactory.create_codec( new omg.org.IOP.Encoding(omg.org.IOP.ENCODING_CDR_ENCAPS.ConstVal, 1, 2)); m_transportFactory.Codec = m_codec; m_iiopUrlUtil = omg.org.CORBA.OrbServices.GetSingleton().IiopUrlUtil; m_hostNameToUse = DetermineMachineNameToUse(); SetupChannelData(m_hostNameToUse, m_port, m_codec, null); m_connectionListener = m_transportFactory.CreateConnectionListener(new ClientAccepted(this.ProcessClientMessages)); // create the default provider chain, if no chain specified if (m_providerChain == null) { m_providerChain = new IiopServerFormatterSinkProvider(); } GiopMessageHandler messageHandler = new GiopMessageHandler(argumentSerializerFactory, m_headerFlags, m_interceptionOptions); ConfigureSinkProviderChain(messageHandler); IServerChannelSink sinkChain = ChannelServices.CreateServerChannelSinkChain(m_providerChain, this); m_transportSink = new IiopServerTransportSink(sinkChain); if (m_bidirConnectionManager != null) { // bidirectional entry point into server channel sink chain. m_bidirConnectionManager.RegisterMessageReceptionHandler(m_transportSink, m_serverThreadsMaxPerConnection); } // ready to wait for messages StartListening(null); // publish init-service Services.CORBAInitServiceImpl.Publish(); // public the handler for generic corba operations StandardCorbaOps.SetUpHandler(); }