private object GetProtoObject(PvpCode code, object msgParam) { switch (code) { case PvpCode.C2P_ReadySkill: return(this.GetProbufMsg <ReadySkillInfo>(msgParam)); case PvpCode.C2P_StartSkill: return(this.GetProbufMsg <StartSkillInfo>(msgParam)); case PvpCode.C2P_DoSkill: case PvpCode.C2P_FlashTo: IL_2E: if (code != PvpCode.C2P_DoHighEffect) { return(null); } return(this.GetProbufMsg <HighEffInfo>(msgParam)); case PvpCode.C2P_HitSkill: return(this.GetProbufMsg <HitSkillInfo>(msgParam)); case PvpCode.C2P_StopSkill: return(this.GetProbufMsg <StopSkillInfo>(msgParam)); case PvpCode.C2P_EndSkill: return(this.GetProbufMsg <EndSkillInfo>(msgParam)); case PvpCode.C2P_UnitsSnap: return(this.GetProbufMsg <UnitSnapInfo>(msgParam)); } goto IL_2E; }
public bool Send(PvpCode code, Dictionary <byte, object> param, bool isResend = false) { bool result; if (!isResend) { param[1] = this.channelID; int nextSeqNo = this.sendPkgMgr.GetNextSeqNo(); param[2] = nextSeqNo; param[3] = 0; if (this.sendPkgMgr.GetNumberOfWaitingAck() > 10) { this.waitingSendPkg = param; this.waitingSendCode = code; result = true; return(result); } this.waitingSendPkg = null; this.sendPkgMgr.AddSendPkg(code, nextSeqNo, param); } bool flag = this.pvpPeer.OpCustom((byte)code, param, false, 1); result = flag; return(result); }
public bool HandlePvpMsg(PvpCode msgID, object msgParam) { if (this.IsReplaying) { return(true); } if (this.IsRecording && msgID != PvpCode.C2P_Ping && msgID != PvpCode.P2C_TipMessage) { OperationResponse operationResponse = msgParam as OperationResponse; ReplayMessage msg; if (operationResponse != null) { msg = new ReplayMessage { time = ReplayController.GetRecordTimeOffset(), code = msgID, param = operationResponse.Parameters[0] as byte[] }; } else { msg = new ReplayMessage { time = ReplayController.GetRecordTimeOffset(), code = msgID, param = msgParam as byte[] }; } this._replayMessageIO.Push(msg); } return(false); }
public void AddMsg(int msgID, object msgParam, MsgType msgType, long svrTime) { object protoObj = null; if (msgType == MsgType.PvpMsg) { PvpCode pvpCode = (PvpCode)msgID; if (pvpCode == PvpCode.P2C_Packages) { this.UnpackPackages(msgID, msgParam, msgType); return; } protoObj = this.GetProtoObject(pvpCode, msgParam); } lock (this) { this._msgList.Add(new MsgData { msgID = msgID, svrTime = svrTime, msgParam = msgParam, msgType = msgType, protoObj = protoObj }); } }
public static void On_ProcessPvpMsg(PvpCode code, long tick) { if (!GameStats._pvpCodeProcessInfo.ContainsKey((int)code)) { GameStats._pvpCodeProcessInfo[(int)code] = new GameStats.PvpCodeProccessInfo(); } GameStats._pvpCodeProcessInfo[(int)code].Add(Time.frameCount, tick); }
protected void OnAck(int seqNo) { if (seqNo == this.lastSentSeqno) { this.lastSentParam = null; this.lastSentCode = (PvpCode)0; this.lastSentSeqno = 0; } }
public bool Send(PvpCode code, Dictionary <byte, object> param) { this.lastSentCode = code; this.lastSentSeqno = this.curSeqno; this.lastSentParam = param; this.lastSentTime = DateTime.Now.Ticks; param[1] = this.lastSentSeqno; this.curSeqno++; return(this.pvpPeer.OpCustom((byte)code, param, false)); }
private void DelePhotonMsgPvpCode(PvpCode msgID, object msgParam) { if (PvpServer.IsMultithreadEnabled) { this._storage.AddMsg((int)msgID, msgParam, MsgType.PvpMsg, 0L); } else { this.ProcessPvpMsg(msgID, msgParam, null, 0L); } }
public bool Send(MobaPeer _pvpPeer, PvpCode code, Dictionary <byte, object> param, int channelID = 0) { bool result; lock (this.channelDict) { CustomClientReliableChannel channel = this.GetChannel(channelID); result = channel.Send(code, param, false); } return(result); }
public static void On_SendPvpMsg(PvpCode code) { if (GameStats._stats.ContainsKey((int)code)) { GameStats._stats[(int)code].OutCount++; } else { GameStats._stats[(int)code] = new GameStats.PackageStats { OutCount = 1 }; } }
public static void On_ReceivePvpMsg(PvpCode code, bool packed) { if (!GameStats._stats.ContainsKey((int)code)) { GameStats._stats[(int)code] = new GameStats.PackageStats(); } if (packed) { GameStats._stats[(int)code].InPackedCount++; } else { GameStats._stats[(int)code].InUnpackedCount++; } }
public void BroadClienMessage <TPeer>(IEnumerable <TPeer> peers, PvpCode code, params object[] args) where TPeer : PeerBase { Dictionary <byte, object> param = comm.BuildParams(args); if (param == null) { param = new Dictionary <byte, object>(); } var data = new EventData() { Code = (byte)code, Parameters = param }; BroadCastEvent(data, peers, new SendParameters());//TODO:姚茂新按协议广播? }
public void SendAllLobbyMessage(PvpCode code, params object[] args) { // if (PvpLobbyConnectionList == null || PvpLobbyConnectionList.Count == 0) // { // Log.ErrorFormat("PvpLobbyConnectionList 为空 code {0} args {1}", code, args); // return; // } // foreach (var tmpConnection in PvpLobbyConnectionList.Values) // { // var result = tmpConnection.GetPeer().SendOperationRequest((byte)code, args); // if (result != SendResult.Ok) // { // Log.ErrorFormat("[send][lobby]SendAllLobbyMessage failed, code:{0}, result:{1}", // code, result); // } // } }
private void appendToCache(PvpCode code, int seqNo, Dictionary <byte, object> param) { SendPkgData sendPkgData = this.AllocPkgData(); sendPkgData.code = code; sendPkgData.SaveRsp(param); sendPkgData.timeTick = DateTime.Now.Ticks; sendPkgData.firstTimeTick = sendPkgData.timeTick; this.sendArr[seqNo % 1000] = sendPkgData; if (this.nextSeqNo == seqNo) { this.nextSeqNo++; if (this.nextSeqNo < 0) { this.nextSeqNo = 0; } } }
protected void SayHelloToPs(PvpCode code) { PvpStateBase.LogState("SayHelloToPs: send " + code); PvpStartGameInfo loginInfo = Singleton <PvpManager> .Instance.LoginInfo; object probufObj = null; switch (code) { case PvpCode.C2P_Reconnect: probufObj = new C2PReconnect { roomId = loginInfo.roomId, newUid = loginInfo.newUid, newkey = loginInfo.newKey }; goto IL_F4; case PvpCode.P2C_Reconnect: IL_39: if (code != PvpCode.C2P_LoginAsViewer) { goto IL_F4; } probufObj = new C2PLoginAsViewer { roomId = loginInfo.roomId, newUid = int.Parse(ModelManager.Instance.Get_userData_X().UserId), newkey = loginInfo.newKey }; goto IL_F4; case PvpCode.C2P_BackGame: probufObj = new C2PBackGame { roomId = loginInfo.roomId, newUid = loginInfo.newUid, newkey = loginInfo.newKey }; goto IL_F4; } goto IL_39; IL_F4: SendMsgManager.Instance.SendPvpLoginMsgBase <object>(code, probufObj, loginInfo.roomId); }
private void ProcessPvpMsg(PvpCode msgID, object msgParam, object protoObj, long svrTime) { if (GameManager.Instance.ReplayController.HandlePvpMsg(msgID, msgParam)) { return; } MobaMessage message = MobaMessageManager.GetMessage(msgID, msgParam, 0f, protoObj); message.svrTime = svrTime; if (MobaMessageManager.IsHandlerExists(message)) { if (message.ID != 143) { FrameSyncManager.Instance.ReceiveMsg(message); } else { MobaMessageManager.ExecuteMsg(message); } } }
public SendResult SendLobbyMessage(string lobbykey, PvpCode code, params object[] args) { // if (string.IsNullOrEmpty(lobbykey) || lobbykey.Equals("")) // { // Log.ErrorFormat("lobbykey 为空 code {0}", code); // return SendResult.Failed; // } // // PvpLobbyConnection tmpConnection = null; // if (PvpLobbyConnectionList.TryGetValue(lobbykey, out tmpConnection)) // { // var result = tmpConnection.GetPeer().SendOperationRequest((byte)code, args); // if (result != SendResult.Ok) // { // Log.ErrorFormat("[send][lobby] failed, code:{0}, result:{1} serverkey {2}", // code, result, lobbykey); // } // Log.InfoFormat("[send][lobby] success, code:{0}, result:{1} serverkey {2}", // code, result, lobbykey); // return result; // } return(SendResult.Disconnected); }
private static void InitPVPCode() { if (MobaMessageManagerTools.dicPvpCode == null) { MobaMessageManagerTools.dicPvpCode = new Dictionary <int, List <string> >(); Dictionary <int, List <string> > dictionary = new Dictionary <int, List <string> >(); string[] names = Enum.GetNames(typeof(PvpCode)); for (int i = 0; i < names.Length; i++) { PvpCode pvpCode = (PvpCode)((byte)Enum.Parse(typeof(PvpCode), names[i])); int key = (int)pvpCode; if (dictionary.ContainsKey(key)) { dictionary[key].Add(names[i]); } else { dictionary.Add((int)pvpCode, new List <string>()); dictionary[key].Add(names[i]); } } Dictionary <int, List <string> > .Enumerator enumerator = dictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <int, List <string> > current = enumerator.Current; if (current.Value.Count > 1) { Dictionary <int, List <string> > arg_E4_0 = MobaMessageManagerTools.dicPvpCode; KeyValuePair <int, List <string> > current2 = enumerator.Current; int arg_E4_1 = current2.Key; KeyValuePair <int, List <string> > current3 = enumerator.Current; arg_E4_0.Add(arg_E4_1, current3.Value); } } } }
public void AddSendPkg(PvpCode code, int seqNo, Dictionary <byte, object> param) { this.appendToCache(code, seqNo, param); }
public static void UnRegistMessage(PvpCode msgID, MobaMessageFunc msgFunc) { MobaMessageManager.UnRegistMessage(MobaMessageType.PvpCode, (int)msgID, msgFunc); }
public static MobaMessage GetMessage(PvpCode msgID, object msgParam, float delayTime = 0f, object protoObj = null) { return(new MobaMessage(MobaMessageType.PvpCode, (int)msgID, msgParam, delayTime, protoObj)); }
public static void DispatchMsg(PvpCode msgId, object msgParam, float delay = 0f) { MobaMessage message = MobaMessageManager.GetMessage(msgId, msgParam, delay, null); MobaMessageManager.DispatchMsg(message); }