public override void recvFrameStep(BroadcastEvent eve) { base.recvFrameStep(eve); RecvFrameBst bst = ((RecvFrameBst)eve.Data); // if (bst.Frame.Items.Count != 0) // Debug.Log("----收到帧消息:" + bst.Frame.Id + "\r\n"); foreach (FrameItem fi in bst.Frame.Items) { XXFrameData xfd = XXFrameData.init(fi.Data); int kk = xfd.intData; // Debug.LogError("ssss:"+kk+":"+UserManager.instance.UType); if ((UserType)xfd.intData != UserManager.instance.UType) { // Debug.Log(xfd.strData); JsonData jsonData = JsonMapper.ToObject(xfd.strData); if (((IDictionary)jsonData).Contains("mark")) { string canvasId = jsonData["mark"].ToString(); //选择不同的画布 if (paintClients.ContainsKey(canvasId)) { if (((IDictionary)jsonData).Contains("ctrl-data")) { // Debug.LogError("Contain ID:" + canvasId + "DDD:" + jsonData["ctrl-data"].ToJson()); UserDefEventHandler handler = paintClients[canvasId]; if (handler == null || handler.painterClientController == null) { Debug.LogError("Some NUll"); } if (handler.painterClientController.painterCanvas.isInited) { paintClients[canvasId].painterClientController.UpdatePara(jsonData["ctrl-data"]); } } } } } // Debug.Log(fi.PlayerId + "|" + fi.Data + "\r\n"); } }
void InitBroadcast() { // 设置收帧广播回调函数 Global.Room.OnRecvFrame = eve => { RecvFrameBst bst = (RecvFrameBst)eve.Data; AddAction(() => this.OnFrame(bst.Frame)); }; // 设置消息接收广播回调函数 Global.Room.OnRecvFromClient = eve => { RecvFromClientBst bst = (RecvFromClientBst)eve.Data; }; // 设置服务器接收广播回调函数 Global.Room.OnRecvFromGameSvr = eve => { RecvFromGameSvrBst bst = (RecvFromGameSvrBst)eve.Data; }; // 设置房间改变广播回调函数 Global.Room.OnChangeRoom = eve => { this.OnChangeRoom(); }; /* //no match for now * Room.OnMatch = eve => * { * RefreshRoomList(); * Debugger.Log("on match!"); * }; * * Room.OnCancelMatch = eve => * { * RefreshRoomList(); * Debugger.Log("on cancel match! "); * }; */ }
private void FillSend(int beginFrameId) { while (true) { if (beginFrameId > this._frameIdSent + 1 || !this._fillCache.ContainsKey(beginFrameId)) { return; } var cache = this._fillCache[beginFrameId]; _fillCache.Remove(beginFrameId); foreach (var item in cache.Frames) { var bst = new RecvFrameBst { Frame = item, }; this.Send(new BroadcastEvent(bst, "")); } beginFrameId = cache.EndFrameId + 1; } }
///////////////////////////////// 广播 ////////////////////////////////// // 收到帧同步消息 private void OnRecvFrame(DecodeBstResult bstResult, string seq) { var bst = new RecvFrameBst(); bst.MergeFrom(bstResult.Body); bst.Frame.RoomId = this.GetFrameRoom().Id; var eve = new BroadcastEvent(bst, seq); // 用户数据上传 FrameBst.Trigger(); EventUpload.PushFrameRateEvent(Convert.ToInt64(FrameBst.deltaTime)); // 上报时间间隔 foreach (var frameItem in bst.Frame.Items) { if (frameItem.PlayerId == RequestHeader.PlayerId) { EventUpload.PushSendRecvEvent(SdkUtil.GetCurrentTimeMilliseconds() - Convert.ToInt64(frameItem.Timestamp)); } } this._responses.OnRecvFrame(eve); }
public override void recvFrameStep(BroadcastEvent eve) { base.recvFrameStep(eve); RecvFrameBst bst = ((RecvFrameBst)eve.Data); // if (bst.Frame.Items.Count != 0) // Debug.Log("----收到帧消息:" + bst.Frame.Id + "\r\n"); try { foreach (FrameItem fi in bst.Frame.Items) { XXFrameData xfd = XXFrameData.init(fi.Data); // Debug.LogError("strData:" +xfd.strData); if ((UserType)xfd.intData != UserManager.instance.UType) { JsonData jsonData = JsonMapper.ToObject(xfd.strData); if (((IDictionary)jsonData).Contains("expert")) { bool temp = false; temp = bool.Parse(jsonData["expert"].ToString()); videoController.SetStaffVideoType(temp); } if (((IDictionary)jsonData).Contains("mark")) { actPanelName = new List <string>(); for (int j = 0; j < jsonData["mark"].Count; j++) { string temp = jsonData["mark"][j].ToString(); actPanelName.Add(temp); // Debug.LogError("mark:" + temp + " paintCanvasDic:" + paintCanvasDic.Count); bool find = false; for (int i = 0; i < paintContainer.Length; i++) { if (paintContainer[i].tarName == temp) { find = true; break; } } if (!find) { for (int i = 0; i < paintContainer.Length; i++) { if (paintContainer[i].tarName == "") { paintContainer[i].tarName = temp; break; } } } } for (int i = 0; i < paintContainer.Length; i++) { bool find = false; for (int k = 0; k < actPanelName.Count; k++) { if (paintContainer[i].tarName == actPanelName[k]) { find = true; break; } } if (!find) { paintContainer[i].tarName = ""; } } } } // Debug.Log(fi.PlayerId + "|" + fi.Data + "\r\n"); } } catch (Exception e) { if (ToastManager.instance) { ToastManager.instance.AddToast(ToastType.Error, e.Message); } Debug.LogError(e.Message); } }