Exemplo n.º 1
0
        private void OnNetworkObjectClientReceiveData(string guid, ArraySegment <byte> buffer, int size)
        {
            var data = new ArraySegment <byte>(buffer.Array, 0, size);
            var pack = new RawJson(data.Array);

            this.apiComponentObject.DispatchPack(pack, guid);
        }
Exemplo n.º 2
0
        private void UpdateTimeDisplay()
        {
            if (TimeDisplay != null)
            {
                TimeDisplay.gameObject.SetActive(false);
                Dictionary <string, object> json = RawJson.ContainsKey("date") ? RawJson : (Dictionary <string, object>)RawJson["data"];

                if (json.ContainsKey("date"))
                {
                    ulong timeDisplay = Convert.ToUInt64(json["date"]);
                    TimeDisplay.text = GetDisplayTime(timeDisplay);
                    TimeDisplay.gameObject.SetActive(true);
                }

                // update every second
                if (TimeDisplay.text.Contains("s"))
                {
                    Invoke("UpdateTimeDisplay", 0.5f);
                }
                // update in a min, if left idle
                else if (TimeDisplay.text.Contains("m"))
                {
                    Invoke("UpdateTimeDisplay", 1.0f * 60.0f);
                }
                // update in an hr, if left idle
                else if (TimeDisplay.text.Contains("h"))
                {
                    Invoke("UpdateTimeDisplay", 1.0f * 3600.0f);
                }
                // not going to update these!
            }
        }
Exemplo n.º 3
0
            private void DispatchRawJsonPack(RawJson jsonPack, string guid)
            {
                var command = "";

                if (jsonPack.JsonDictionary.ContainsKey("command"))
                {
                    command = (string)jsonPack.JsonDictionary["command"];
                }
                Type obj  = this.packMap[command];
                var  pack = (BasePack)Activator.CreateInstance(obj, jsonPack.RawData);

                pack.Deserialized();
                try
                {
                    this.OnDispatchPack?.Invoke(guid, pack);
                }
                catch
                {
                }
            }