private void OpenEvent() { if (this._session > 0) { return; } this._session = MidGenerator.Gen(); IDictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("sw", RUMPlatform.Instance.ScreenWidth()); dict.Add("sh", RUMPlatform.Instance.ScreenHeight()); dict.Add("manu", RUMPlatform.Instance.GetManu()); dict.Add("model", RUMPlatform.Instance.GetModel()); dict.Add("os", RUMPlatform.Instance.GetOS()); dict.Add("osv", RUMPlatform.Instance.GetOSV()); dict.Add("nw", RUMPlatform.Instance.GetNetwork()); dict.Add("carrier", RUMPlatform.Instance.GetCarrier()); dict.Add("lang", RUMPlatform.Instance.GetLang()); dict.Add("from", RUMPlatform.Instance.GetFrom()); dict.Add("appv", this._appv); dict.Add("v", RUMConfig.VERSION); dict.Add("first", this._rumEvent.IsFirst()); this.WriteEvent("open", dict); }
private void WriteEvent(string ev, IDictionary <string, object> dict) { dict.Add("ev", ev); if (!dict.ContainsKey("eid")) { dict.Add("eid", MidGenerator.Gen()); this._writeCount++; } if (!dict.ContainsKey("pid")) { dict.Add("pid", this._pid); } if (!dict.ContainsKey("sid")) { dict.Add("sid", this._session); } if (!dict.ContainsKey("uid")) { dict.Add("uid", this._uid); } if (!dict.ContainsKey("rid")) { dict.Add("rid", this._rumEvent.GetRumId()); } if (!dict.ContainsKey("ts")) { dict.Add("ts", this._rumEvent.GetTimestamp()); } IDictionary <string, object> cp_dict = new Dictionary <string, object>(dict); if (this._debug) { Debug.Log("[RUM] write event: " + Json.SerializeToString(cp_dict)); } this._rumEvent.WriteEvent(cp_dict); }
private void SendPing(long timestamp) { if (this._lastPingTime == 0) { return; } if (timestamp - this._lastPingTime < RUMConfig.PING_INTERVAL) { return; } this._lastPingTime += RUMConfig.PING_INTERVAL; if (this._debug) { Debug.Log("[RUM] ping..."); } long lastEid = this._pingEid; int lastCount = this._writeCount; this._writeCount = 0; this._pingEid = MidGenerator.Gen(); long salt = this.GenSalt(); IDictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("pid", this._pid); payload.Add("sign", this.GenSign(salt)); payload.Add("salt", salt); payload.Add("uid", this._uid); payload.Add("rid", this._rumEvent.GetRumId()); payload.Add("sid", this._session); payload.Add("cv", this._configVersion); payload.Add("pt", this._pingLatency); payload.Add("ss", this._rumEvent.GetStorageSize()); payload.Add("wc", lastCount); payload.Add("feid", lastEid); payload.Add("teid", this._pingEid); MemoryStream outputStream = new MemoryStream(); MsgPack.Serialize(payload, outputStream); outputStream.Position = 0; byte[] bytes = outputStream.ToArray(); FPData data = new FPData(); data.SetFlag(0x1); data.SetMtype(0x1); data.SetMethod("ping"); data.SetPayload(bytes); long pingTime = timestamp; RUMClient self = this; this.SendQuest(data, (cbd) => { self._pingLatency = Convert.ToInt32(ThreadPool.Instance.GetMilliTimestamp() - pingTime); Exception ex = cbd.GetException(); if (ex != null) { self.GetEvent().FireEvent(new EventData("error", ex)); return; } IDictionary <string, object> dict = (IDictionary <string, object>)cbd.GetPayload(); if (self._debug) { Debug.Log("[RUM] ping: " + Json.SerializeToString(dict)); } self._rumEvent.SetTimestamp(Convert.ToInt64(dict["ts"])); self._rumEvent.SetSizeLimit(Convert.ToInt32(dict["bw"])); int cv = Convert.ToInt32(dict["cv"]); if (self._configVersion != cv || (cv == 0 && !self._rumEvent.HasConfig())) { self._configVersion = cv; this.LoadConfig(); } }, RUMConfig.PING_INTERVAL); }