public static ILifecycle Create(RpcEndPoint endPoint, IGameServerRegistrar gameServerRegistrar) { var port = new ServerPort(endPoint.Host, endPoint.Port, ServerCredentials.Insecure); var controller = new RpcServiceController(port); controller.RegisterService(token => GameServerRegistrar.BindService(new GameServerRegistrarService(gameServerRegistrar, token))); return(controller); }
private static GameServer.GameServer CreateGameServer( IPersistenceContextProvider persistenceContextProvider, IGameServerRegistrar gameServerRegistrar, IAccountLoginService accountLoginService) { var config = new GameServer.Configuration(); return(GameServer.GameServerFactory.Create(config, persistenceContextProvider, gameServerRegistrar, accountLoginService)); }
/// <summary>Initializes a new instance of the <see cref="GameServerTcpListener" /> class.</summary> // TODO: The determined end point should be injected public GameServerTcpListener( Configuration config, IClientController clientController, IClientProtocolResolver clientProtocolResolver, IGameServerRegistrar gameServerRegistrar) : base(config.ClientListenerEndPoint, config.MaxPacketSize) { this.config = config; this.gameServerRegistrar = gameServerRegistrar; this.clientProtocolResolver = clientProtocolResolver; this.clientController = clientController; this.clientController.ClientSessionStarted += this.OnServerClientsChanged; this.clientController.ClientSessionEnded += this.OnServerClientsChanged; this.ConfigureEncryption(); }
/// <summary>Initializes a new instance of the <see cref="GameServer" /> class with default implementations.</summary> public static GameServer Create( Configuration config, IPersistenceContextProvider persistenceContextProvider, IGameServerRegistrar gameServerRegistrar, IAccountLoginService accountLoginService) { var gameContext = new GameContext(persistenceContextProvider, new LoginServiceAdapter(accountLoginService)); var clientController = new ClientController(); var clientProtocolResolver = new ClientProtocolResolver(config, gameContext); var clientListener = new GameServerTcpListener(config, clientController, clientProtocolResolver, gameServerRegistrar); clientListener.AddFilter(new MaxConnectionsFilter(config.MaxConnections)); clientListener.AddFilter(new MaxConnectionsPerIpFilter(config.MaxConnectionsPerIp)); var gameServer = new GameServer(config, clientController, gameContext); gameServer.AddListener(clientListener); return(gameServer); }
/// <summary>Initializes a new instance of the <see cref="GameServerRegistrarService"/> class.</summary> public GameServerRegistrarService(IGameServerRegistrar gameServerRegistrar, CancellationToken cancellationToken) { this.gameServerRegistrar = gameServerRegistrar; this.cancellationToken = cancellationToken; }