Пример #1
0
 public StreamController(
     IGameWebSocketConnectionProvider wsConnectionProvider,
     IExtensionWebSocketConnectionProvider ewsConnectionProvider)
 {
     this.gameWsConnectionProvider      = wsConnectionProvider;
     this.extensionWsConnectionProvider = ewsConnectionProvider;
 }
Пример #2
0
            public WebSocketConnection(
                ILogger logger,
                IRavenBotApiClient ravenBotApi,
                IIntegrityChecker integrityChecker,
                IPlayerInventoryProvider inventoryProvider,
                IGameData gameData,
                IGameManager gameManager,
                IGamePacketManager packetManager,
                IGamePacketSerializer packetSerializer,
                ISessionManager sessionManager,
                IExtensionWebSocketConnectionProvider extWsProvider,
                GameWebSocketConnectionProvider sessionProvider,
                WebSocket ws,
                SessionToken sessionToken)
            {
                this.receiveLoop      = new Thread(ReceiveLoop);
                this.sendLoop         = new Thread(SendLoop);
                this.gameLoop         = new Thread(GameUpdateLoop);
                this.logger           = logger;
                this.sessionToken     = sessionToken;
                this.packetManager    = packetManager;
                this.packetSerializer = packetSerializer;
                this.sessionManager   = sessionManager;
                this.sessionProvider  = sessionProvider;
                this.ws = ws;

                this.killTask      = new TaskCompletionSource <object>();
                this.gameProcessor = new GameProcessor(
                    ravenBotApi, integrityChecker, this, extWsProvider, sessionManager, inventoryProvider, gameData, gameManager, sessionToken);
            }
Пример #3
0
        public GameProcessor(
            IRavenBotApiClient ravenbotApi,
            IIntegrityChecker integrityChecker,
            IGameWebSocketConnection websocket,
            IExtensionWebSocketConnectionProvider extWsProvider,
            ISessionManager sessionManager,
            IPlayerInventoryProvider inventoryProvider,
            IGameData gameData,
            IGameManager gameManager,
            SessionToken sessionToken)
        {
            this.gameData                    = gameData;
            this.gameManager                 = gameManager;
            this.ravenbotApi                 = ravenbotApi;
            this.integrityChecker            = integrityChecker;
            this.gameConnection              = websocket;
            this.extensionConnectionProvider = extWsProvider;
            this.sessionManager              = sessionManager;
            this.inventoryProvider           = inventoryProvider;
            this.sessionToken                = sessionToken;

            RegisterPlayerTask <ClanProcessor>(ClanProcessorName);
            RegisterPlayerTask <VillageProcessor>(VillageProcessorName);
            RegisterPlayerTask <LoyaltyProcessor>(LoyaltyProcessorName);
            RegisterPlayerTask <RestedProcessor>(RestedProcessorName);
            RegisterPlayerTask <FightingTaskProcessor>("Fighting");
            RegisterPlayerTask <MiningTaskProcessor>("Mining");
            RegisterPlayerTask <FishingTaskProcessor>("Fishing");
            RegisterPlayerTask <FarmingTaskProcessor>("Farming");
            RegisterPlayerTask <WoodcuttingTaskProcessor>("Woodcutting");
            RegisterPlayerTask <CraftingTaskProcessor>("Crafting");
            RegisterPlayerTask <CookingTaskProcessor>("Cooking");

            SendSessionData();
        }
        private static async Task <bool> ForAllConnectionsAsync(
            this IExtensionWebSocketConnectionProvider connectionProvider,
            Func <IExtensionConnection, Task> action)
        {
            var connection = connectionProvider.GetAll();

            if (connection == null)
            {
                return(false);
            }
            await connection.ForEachAsync(action);

            return(true);
        }
Пример #5
0
 public SessionManager(
     ILogger <SessionManager> logger,
     ITwitchClient twitchClient,
     IGameData gameData,
     IPlayerManager playerManager,
     IVillageManager villageManager,
     IExtensionWebSocketConnectionProvider extWsConnectionProvider)
 {
     this.logger                  = logger;
     this.twitchClient            = twitchClient;
     this.gameData                = gameData;
     this.playerManager           = playerManager;
     this.villageManager          = villageManager;
     this.extWsConnectionProvider = extWsConnectionProvider;
 }
Пример #6
0
 public GameWebSocketConnectionProvider(
     ILogger <GameWebSocketConnectionProvider> logger,
     IRavenBotApiClient ravenBotApi,
     IIntegrityChecker integrityChecker,
     IPlayerInventoryProvider inventoryProvider,
     IExtensionWebSocketConnectionProvider extWsProvider,
     IGameData gameData,
     IGameManager gameManager,
     IGamePacketManager packetManager,
     IGamePacketSerializer packetSerializer,
     ISessionManager sessionManager)
 {
     this.logger            = logger;
     this.ravenBotApi       = ravenBotApi;
     this.integrityChecker  = integrityChecker;
     this.inventoryProvider = inventoryProvider;
     this.extWsProvider     = extWsProvider;
     this.gameData          = gameData;
     this.gameManager       = gameManager;
     this.packetManager     = packetManager;
     this.packetSerializer  = packetSerializer;
     this.sessionManager    = sessionManager;
 }
 public static Task <bool> BroadcastAsync <T>(this IExtensionWebSocketConnectionProvider connectionProvider, T update)
 {
     return(connectionProvider.ForAllConnectionsAsync(x => x.SendAsync(update)));
 }
Пример #8
0
 public void SetExtensionConnectionProvider(IExtensionWebSocketConnectionProvider provider)
 {
     this.ExtensionConnectionProvider = provider;
 }