예제 #1
0
        private IEnumerator <float> StatusUpdate()
        {
            supdateMessage message = new supdateMessage();

            if (_lastSupdateMessage == null || _lastSupdateMessage.CurrentPlayers != message.CurrentPlayers || (DateTime.Now - _lastSupdateMessage.LastUpdate).Seconds > 30)
            {
                SendMessage(JsonConvert.SerializeObject(message));
                _lastSupdateMessage = message;
            }

            yield return(Timing.WaitForSeconds(6f));

            Timing.RunCoroutine(StatusUpdate());
        }
예제 #2
0
        private IEnumerator <float> StatusUpdate()
        {
            supdateMessage message = new supdateMessage();

            if (_socket.Connected)
            {
                if (_lastSupdateMessage == null || _lastSupdateMessage.CurrentPlayers != message.CurrentPlayers)
                {
                    SendMessage(JsonConvert.SerializeObject(message));
                    _lastSupdateMessage = message;
                }
            }

            yield return(Timing.WaitForSeconds(6f));

            Timing.RunCoroutine(StatusUpdate());
        }
예제 #3
0
        public void NewMessage(string message, messageType type = messageType.MSG, JObject jObj = null)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            message.Replace("{", string.Empty).Replace("}", string.Empty);

            string json;

            if (type == messageType.MSG)
            {
                msgMessage msg = new msgMessage()
                {
                    Message = _rgx.Replace(message, string.Empty)
                };

                json = JsonConvert.SerializeObject(msg);
            }
            else if (type == messageType.KEEPALIVE)
            {
                keepaliveMessage msg = new keepaliveMessage();

                json = JsonConvert.SerializeObject(msg);
            }
            else if (type == messageType.PLIST)
            {
                plistMessage msg = new plistMessage
                {
                    ChannelID   = jObj["channel"].ToString(),
                    PlayerNames = message
                };

                json = JsonConvert.SerializeObject(msg);
            }
            else if (type == messageType.CMD)
            {
                cmdMessage msg = new cmdMessage
                {
                    ChannelID      = jObj["channel"].ToString(),
                    StaffID        = jObj["StaffID"].ToString(),
                    CommandMessage = message
                };

                json = JsonConvert.SerializeObject(msg);
            }
            else if (type == messageType.SUPDATE)
            {
                supdateMessage msg = new supdateMessage();

                json = JsonConvert.SerializeObject(msg);
            }
            else
            {
                Plugin.Warn("Invalid messageType given!");
                return;
            }

            SendMessage(json);
        }