Esempio n. 1
0
        void OnPlayerDisconnected(BasePlayer player, string reason)
        {
            var payload = new BotPayload
            {
                numeroDePLayersAgora = $"{BasePlayer.activePlayerList.Count}",
                numeroDePlayersTotal = $"{maximoDePlayers}"
            };

            NotificarBot(payload);
        }
Esempio n. 2
0
        void OnPlayerConnected(Network.Message packet)
        {
            //int agora = global.BasePlayer.activePlayerList.Count;
            var payload = new BotPayload
            {
                numeroDePLayersAgora = $"{BasePlayer.activePlayerList.Count}",
                numeroDePlayersTotal = $"{maximoDePlayers}"
            };

            NotificarBot(payload);
        }
Esempio n. 3
0
        void NotificarBot(BotPayload payload)
        {
            string webhook = $"http://{enderecoServidor}:{porta}/atualizarContador";
            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("Content-Type", "application/json");
            Puts(JsonConvert.SerializeObject(payload));
            if (payload == null || string.IsNullOrEmpty(webhook))
            {
                return;
            }
            webrequest.Enqueue(webhook, JsonConvert.SerializeObject(payload), (code, response) => ServerDetailsCallback(code, response), this, RequestMethod.POST, header);
        }
Esempio n. 4
0
        public static void CallBotApi(string user, List <CalendarItem> recommendations, string subject)
        {
            BotPayload payload = new BotPayload();

            payload.UserId      = user;
            payload.Suggestions = new List <Suggestion>();
            payload.Suggestions = recommendations.Select(a => new Suggestion
            {
                End = new OfficeDate {
                    DateTime = a.EndDate.ToString("o"), Timezone = "Pacific Standard Time"
                },
                Start = new OfficeDate {
                    DateTime = a.StartDate.ToString("o"), Timezone = "Pacific Standard Time"
                },
                Subject = subject
            }).ToList();

            HttpClient         client         = new HttpClient();
            HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, AppState.BotEndPoint);
            string             jsonPayload    = JsonConvert.SerializeObject(payload);

            requestMessage.Content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
            HttpResponseMessage response = client.SendAsync(requestMessage).Result;
        }