Exemple #1
0
 internal void __addInternalRequestHandler(InternalRequestType requestType, ClientEventHandler<RequestReceivedEventArgs> handler)
 {
     InternalRequestHandlers.Add((short)requestType, handler);
 }
Exemple #2
0
 /// <summary>
 /// Инициализировать обработчик меню работы
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.CHOOSE_PILOT_CONTRACT, ChooseContract);
     ClientEventHandler.Add(ClientEvent.PILOT_SALARY, PilotSalary);
 }
Exemple #3
0
 /// <summary>
 /// Инициализировать обработчик меню работы
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.WORK_AS_FARMER, StartFarmerWork);
     ClientEventHandler.Add(ClientEvent.WORK_AS_TRACTOR_DRIVER, StartTractorWork);
     ClientEventHandler.Add(ClientEvent.FARMER_SALARY, GetSalary);
 }
Exemple #4
0
 /// <summary>
 /// Инициализировать меню работы строителем
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.WORK_AS_BUILDER, StartWork);
     ClientEventHandler.Add(ClientEvent.BUILDER_SALARY, GetSalary);
 }
 /// <summary>
 /// Проинициализировать работу строителе
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.PROCESS_BUILDER_POINT, ProcessPoint);
     ClientEventHandler.Add(ClientEvent.FINISH_BUILDER_POINT, FinishPoint);
     CreatePoints();
 }
 /// <summary>
 /// Инициализировать интерфейсные обработчики
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.PLAYER_LOGIN, PlayerLogin);
 }
 /// <summary>
 /// Инициализация
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.GIVE_ONLINE_GIFT, OnGiveOnlineGift);
 }
 /// <summary>
 /// Инициализировать обработчик меню
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.DRESS_OR_BUY_GOOD, DressOrBuyGood);
     ClientEventHandler.Add(ClientEvent.DRESS_PLAYER_CLOTHES, DressPlayerClothes);
 }
Exemple #9
0
        private async Task Login()
        {
            _logger.Information("Initializing the client setup...");
            var activity = new DiscordActivity("ur mom is pretty gae", ActivityType.Custom);

            _client = new DiscordShardedClient(new DiscordConfiguration
            {
                Token                   = _token,
                TokenType               = TokenType.Bot,
                DateTimeFormat          = "dd-MM-yyyy HH:mm",
                AutoReconnect           = true,
                MessageCacheSize        = 4096,
                ReconnectIndefinitely   = true,
                HttpTimeout             = Timeout.InfiniteTimeSpan,
                GatewayCompressionLevel = GatewayCompressionLevel.Payload
            });

            _logger.Information("Successfully setup the client.");
            _logger.Information("Setting up all configurations...");

            var ccfg = new CommandsNextConfiguration
            {
                Services            = _serviceProvider,
                PrefixResolver      = PrefixResolverAsync,
                EnableMentionPrefix = false,
                EnableDms           = true,
                DmHelp            = true,
                EnableDefaultHelp = true
            };

            _logger.Information("Commands configuration setup done.");

            var icfg = new InteractivityConfiguration
            {
                PollBehaviour = PollBehaviour.KeepEmojis,
                Timeout       = TimeSpan.FromMinutes(2)
            };

            _logger.Information("Interactivity configuration setup done.");
            _logger.Information("Connecting all shards...");
            await _client.StartAsync().ConfigureAwait(true);

            await _client.UpdateStatusAsync(activity, UserStatus.Online).ConfigureAwait(true);

            _logger.Information("Setting up client event handler...");
            _clientEventHandler = new ClientEventHandler(_client, _logger, _redis, _reactionListener);

            foreach (var shard in _client.ShardClients.Values)
            {
                _logger.Information($"Applying configs to shard {shard.ShardId}...");
                _cnext = shard.UseCommandsNext(ccfg);
                _cnext.RegisterCommands(Assembly.GetEntryAssembly());
                _cnext.SetHelpFormatter <HelpFormatter>();
                shard.UseInteractivity(icfg);
                _logger.Information($"Settings up command event handler for the shard {shard.ShardId}...");
                _commandEventHandler = new CommandEventHandler(_cnext, _logger);
                _logger.Information($"Setup for shard {shard.ShardId} done.");
                await shard.InitializeAsync();
            }

            foreach (var cNextRegisteredCommand in _cnext.RegisteredCommands)
            {
                _logger.Information($"{cNextRegisteredCommand.Value} is registered!");
            }
        }
Exemple #10
0
 //needed to be call after create new ClientEventHandler and a new client logic
 public void Init(ClientEventHandler eventHandler, communicationHandler handler)
 {
     _eventHandler = eventHandler;
     _handler      = handler;
 }
Exemple #11
0
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.GPS_POINT, ProcessTarget);
 }
Exemple #12
0
        private async Task Login()
        {
            this.logger.Information("Initializing the client setup...");

            client = new DiscordShardedClient(new DiscordConfiguration
            {
                Token                   = config.Token,
                TokenType               = TokenType.Bot,
                LogTimestampFormat      = "dd-MM-yyyy HH:mm",
                AutoReconnect           = true,
                MessageCacheSize        = 4096,
                HttpTimeout             = Timeout.InfiniteTimeSpan,
                GatewayCompressionLevel = GatewayCompressionLevel.Stream
            });

            this.logger.Information("Successfully setup the client.");
            this.logger.Information("Setting up all configurations...");

            var ccfg = new CommandsNextConfiguration
            {
                Services            = serviceProvider,
                PrefixResolver      = PrefixResolverAsync,
                EnableMentionPrefix = true,
                EnableDms           = true,
                DmHelp                   = false,
                EnableDefaultHelp        = true,
                UseDefaultCommandHandler = true
            };

            this.logger.Information("Commands configuration setup done.");

            var icfg = new InteractivityConfiguration {
                PollBehaviour = PollBehaviour.KeepEmojis, Timeout = TimeSpan.FromMinutes(2)
            };

            this.logger.Information("Interactivity configuration setup done.");
            this.logger.Information("Connecting all shards...");
            await client.StartAsync()
            .ConfigureAwait(true);

            this.logger.Information("Setting up client event handler...");
            clientEventHandler = new ClientEventHandler(client, logger, redis, reactionService, logService);

            foreach (var shard in client.ShardClients.Values)
            {
                logger.Information($"Applying configs to shard {shard.ShardId}...");
                commandsNext = shard.UseCommandsNext(ccfg);
                commandsNext.RegisterCommands(typeof(Modules.Dummy).Assembly);
                commandsNext.SetHelpFormatter <HelpFormatter>();
                shard.UseInteractivity(icfg);
                this.logger.Information($"Settings up command event handler for the shard {shard.ShardId}...");
                commandEventHandler = new CommandEventHandler(commandsNext, logger);
                this.logger.Information($"Setup for shard {shard.ShardId} done.");
                await shard.InitializeAsync().ConfigureAwait(true);
            }

            foreach (var cNextRegisteredCommand in commandsNext.RegisteredCommands)
            {
                this.logger.Information($"{cNextRegisteredCommand.Value} is registered!");
            }
        }
Exemple #13
0
 /// <summary>
 /// Инициализировать обработчик меню
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.JOIN_CLAN, JoinClan);
     ClientEventHandler.Add(ClientEvent.LEFT_CLAN, LeftClan);
     ClientEventHandler.Add(ClientEvent.ACCEPT_CLAN_QUEST, AcceptClanQuest);
 }
 public BistroManager() : this(ServerKernel.Kernel)
 {
     ClientEventHandler.Add(ClientEvent.SET_DELIVERY_FAIL, SetDeliveryFail);
     ClientEventHandler.Add(ClientEvent.COMPLETE_DELIVERY, CompleteDelivery);
 }
 /// <summary>
 /// Инициализировать меню
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.WORK_ON_BUS, WorkAsBusDriver);
     ClientEventHandler.Add(ClientEvent.BUS_DRIVER_SALARY, GetSalary);
 }
Exemple #16
0
 /// <summary>
 /// Проинициализировать инвентарь
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.SHOW_INVENTORY, ShowInventory);
     ClientEventHandler.Add(ClientEvent.USE_INVENTORY_ITEM, UseInventoryItem);
 }
Exemple #17
0
 /// <summary>
 /// Инициализировать меню
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.WORK_ON_FORKLIFT, StartWork);
     ClientEventHandler.Add(ClientEvent.FORKLIFT_SALARY, GetSalary);
 }
 /// <summary>
 /// Инициализировать обработчик меню
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.JOIN_CLAN_MISSION, JoinClanMission);
     ClientEventHandler.Add(ClientEvent.LEFT_CLAN_MISSION, LeftClanMission);
 }
 public TaxiDriverManager() : this(ServerKernel.Kernel)
 {
     API.onPlayerEnterVehicle += OnEnterTaxi;
     API.onPlayerExitVehicle  += OnExitTaxi;
     ClientEventHandler.Add("CallTaxi", OnTaxiCall);
 }
        /// <summary>
        /// Gets the handler associated with the specified request type.
        /// </summary>
        /// <param name="key">The request type.</param>
        /// <param name="value">The handler of the specified request type, if found.</param>
        /// <returns></returns>
        public bool TryGetValue(short key, out ClientEventHandler<RequestReceivedEventArgs> value)
        {
            lock (syncRoot)
                if (inner.TryGetValue(key, out value))
                    return true;

            if (parent != null)
                return parent.TryGetValue(key, out value);

            return false;
        }
 /// <summary>
 /// Инициализировать меню работы
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.WORK_IN_TAXI, WorkInTaxi);
     ClientEventHandler.Add(ClientEvent.TAXI_DRIVER_SALARY, GetSalary);
 }
 /// <summary>
 /// Assigns the handler to a request type.
 /// </summary>
 /// <param name="key">The request type.</param>
 /// <param name="value">Handler.</param>
 public void Add(short key, ClientEventHandler<RequestReceivedEventArgs> value)
 {
     lock (syncRoot)
         inner.Add(key, value); 
 }
 /// <summary>
 /// Инициализировать обработчик меню
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.GO_TO_DRESSING_ROOM, GoToDressingRoom);
     ClientEventHandler.Add(ClientEvent.EXIT_FROM_DRESSING_ROOM, ExitFromDressingRoom);
 }
Exemple #24
0
 /// <summary>
 /// Adds a handler delegate for a specific request type.
 /// </summary>
 /// <param name="requestType">The type of request to handle.</param>
 /// <param name="handler">The delegate which will handle the request.</param>
 public void AddRequestHandler(short requestType, ClientEventHandler<RequestReceivedEventArgs> handler)
 {
     RequestHandlers.Add(requestType, handler);
 }
Exemple #25
0
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.PLAYER_REGISTER, PlayerRegister);
 }
Exemple #26
0
        //  Allow overriding classes to register their own internal requests.

        /// <summary>
        /// Adds a handler delegate for a specific request type.
        /// </summary>
        /// <param name="requestType">The type of request to handle.</param>
        /// <param name="handler">The delegate which will handle the request.</param>
        protected void AddInternalRequestHandler(short requestType, ClientEventHandler<RequestReceivedEventArgs> handler)
        {
            RequestHandlers.Add(requestType, handler);
        }
 /// <summary>
 /// Инициализировать обработчик меню работы
 /// </summary>
 public override void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.GET_VEHICLE_FROM_PARKING_FINE, GetVehicleFromParkingFine);
     ClientEventHandler.Add(ClientEvent.WRECKER, WorkAsWrecker);
     ClientEventHandler.Add(ClientEvent.WRECKER_SALARY, GetSalary);
 }
 /// <summary>
 /// Инициализация работы
 /// </summary>
 public void Initialize()
 {
     ClientEventHandler.Add(ClientEvent.PROCESS_FARMER_POINT, ProcessPoint);
     CreateFarmPoints();
     CreateFarmEndPoint();
 }