Exemplo n.º 1
0
        public RavenNestClient(
            ILogger logger,
            IGameManager gameManager,
            IAppSettings settings,
            IGameCache cache)
        {
            ServicePointManager.DefaultConnectionLimit = 100;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);
            //ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy();

            this.logger      = logger ?? new ConsoleLogger();      //new UnityLogger();
            this.gameManager = gameManager;
            var binarySerializer = new CompressedJsonSerializer(); //new BinarySerializer();

            appSettings = settings ?? new ProductionRavenNestStreamSettings();

            tokenProvider = new TokenProvider();
            var request = new WebApiRequestBuilderProvider(logger, appSettings, tokenProvider);

            Stream      = new WebSocketEndpoint(this, gameManager, logger, settings, tokenProvider, new GamePacketSerializer(binarySerializer), cache);
            Auth        = new WebBasedAuthEndpoint(this, logger, request);
            Game        = new WebBasedGameEndpoint(this, logger, request);
            Items       = new WebBasedItemsEndpoint(this, logger, request);
            Players     = new WebBasedPlayersEndpoint(this, logger, request);
            Marketplace = new WebBasedMarketplaceEndpoint(this, logger, request);
            Village     = new WebBasedVillageEndpoint(this, logger, request);
            Admin       = new WebBasedAdminEndpoint(this, logger, request);
        }
Exemplo n.º 2
0
        public void InitGameContext(UserContext first, UserContext second, BaseHero firstHero, BaseHero secondHero)
        {
            gameContext = new GameContext()
            {
                GameCode        = "GameCode",
                CurrentTurnCode = "CurrentTurnCode",
                NextTurnCode    = "NextTurnCode",
                Players         = new List <UserContext> {
                    first, second
                },
                GameStatus = GameStatus.进行中,
                TurnIndex  = 10,
            };
            gameContext.DeskCards = new DeskBoard()
            {
                firstHero, null, null, null, null, null, null, null, secondHero, null, null, null, null, null, null, null
            };

            IGameCache gameCache = Substitute.For <IGameCache>();

            gameCache.GetAllCard().Returns(CardsUtil.AllCard);
            gameCache.GetContext(Arg.Any <string>()).Returns(gameContext);

            gameContext.GameCache = gameCache;
            proxy = new Controller_Base_Proxy(gameCache);
        }
        public NinthPlanetGameRepository(
            IGameServerFactory gameServerFactory,
            IGameCache <Games.NinthPlanet> gameCache,
            ApplicationDbContext dbContext)
        {
            semaphore = new SemaphoreSlim(1);

            this.gameServerFactory = gameServerFactory ?? throw new System.ArgumentNullException(nameof(gameServerFactory));
            this.gameCache         = gameCache ?? throw new System.ArgumentNullException(nameof(gameCache));
            this.dbContext         = dbContext ?? throw new System.ArgumentNullException(nameof(dbContext));
        }
Exemplo n.º 4
0
 public WSGameServerConnection(
     ILogger logger,
     IAppSettings settings,
     ITokenProvider tokenProvider,
     IGamePacketSerializer packetSerializer,
     IGameCache gameCache)
 {
     this.logger           = logger;
     this.settings         = settings;
     this.tokenProvider    = tokenProvider;
     this.packetSerializer = packetSerializer;
     this.gameCache        = gameCache;
 }
Exemplo n.º 5
0
        public GameService(ILogger logger,
                           IGameCache gameCache,
                           IUserRepository userRepository, IGameRepository gameRepository, IBoardRepository boardRepository,
                           ILexiconService lexiconService, IStatService statService, IGameQueueService gameQueueService)
        {
            this.userRepository  = userRepository;
            this.gameRepository  = gameRepository;
            this.boardRepository = boardRepository;

            this.gameCache = gameCache;

            this.lexiconService   = lexiconService;
            this.statService      = statService;
            this.gameQueueService = gameQueueService;
            this.logger           = logger;
        }
Exemplo n.º 6
0
        public WebSocketEndpoint(
            IRavenNestClient client,
            IGameManager gameManager,
            ILogger logger,
            IAppSettings settings,
            ITokenProvider tokenProvider,
            IGamePacketSerializer packetSerializer,
            IGameCache gameCache)
        {
            connection = new WSGameServerConnection(
                logger,
                settings,
                tokenProvider,
                packetSerializer,
                gameCache);

            connection.Register("game_event", new GameEventPacketHandler(gameManager));
            connection.OnReconnected += OnReconnected;
            this.client      = client;
            this.gameManager = gameManager;
        }
Exemplo n.º 7
0
 public GameService(IGameCache gameCache)
 {
     this.gameCache = gameCache;
 }
 public Controller_Base_Proxy(IGameCache gameCache)
 {
     _gameCache = gameCache;
 }
Exemplo n.º 9
0
 public Controler_Base(IGameCache gameCache)
 {
     _gameCache = gameCache;
 }
Exemplo n.º 10
0
 public GameDbRepository(IDbConnection dbConnection, IGameCache gameCache)
 {
     this.dbConnection = dbConnection;
     GameCache         = gameCache;
 }