public override void MessageReceive(SocketModel model) { switch (model.Command) { case FightProtocol.START_BRO: start(model.GetMessage <FightRoomModel>()); break; case FightProtocol.MOVE_BRO: move(model.GetMessage <MoveDTO>()); break; case FightProtocol.ATTACK_BRO: attack(model.GetMessage <AttackDTO>()); break; case FightProtocol.DAMAGE_BRO: damage(model.GetMessage <DamageDTO>()); break; case FightProtocol.SKILL_UP_SRES: skillUP(model.GetMessage <FightSkill>()); break; default: break; } }
/// <summary> /// 对时消息处理,分为server请求的和client请求的 /// </summary> /// <param name="sm"></param> public override void OnMessageReceived(SocketModel sm) { switch (sm.command) { case TimeProtocol.CHECK_SRES: DelayCheckDTO delayCheckDTO = sm.GetMessage <DelayCheckDTO>(); if (delayCheckDTO.timeStamps.Count <= delayCheckDTO.checkNum * 2) { //对时次数不够,就继续对够 delayCheckDTO.timeStamps.Add(DateTime.Now.Ticks); Send(TimeProtocol.CHECK_CREQ, delayCheckDTO); } if (delayCheckDTO.timeStamps.Count == delayCheckDTO.checkNum * 2 + 1) //这里的最后一个timestamp是client的 { //对时次数够了,计算时差和延迟 GameRuntimeData.delayAndFloating = GetDelayAndFloatingOdd(delayCheckDTO.timeStamps); MgrCenter.Instance.SendMsg(Msgs.GetMsgDelayAndFloating((ushort)NetEventTime.DelayGot, GameRuntimeData.delayAndFloating)); } break; case TimeProtocol.CHECK_SREQ: DelayCheckDTO delayCheck = sm.GetMessage <DelayCheckDTO>(); if (delayCheck.timeStamps.Count < delayCheck.checkNum * 2) { delayCheck.timeStamps.Add(DateTime.Now.Ticks); Send(TimeProtocol.CHECK_CRES, delayCheck); } else { //对时次数够了,计算时差和延迟,这里注意最后一个时间戳是server发来的,因此需要再把现在的时间加上再计算 delayCheck.timeStamps.Add(DateTime.Now.Ticks); GameRuntimeData.delayAndFloating = GetDelayAndFloatingEven(delayCheck.timeStamps); MgrCenter.Instance.SendMsg(Msgs.GetMsgDelayAndFloating((ushort)NetEventTime.DelayGot, GameRuntimeData.delayAndFloating)); } break; } }
public void MessageReceive(SocketModel model) { switch (model.Command) { case SelectProtocol.DESTROY_BRO: Application.LoadLevel(1); break; case SelectProtocol.ENTER_SRES: Enter(model.GetMessage<SelectRoomDTO>()); break; case SelectProtocol.ENTER_EXBRO: Enter(model.GetMessage<int>()); break; case SelectProtocol.FIGHT_BRO: Application.LoadLevel(3); break; case SelectProtocol.READY_BRO: Ready(model.GetMessage<SelectModel>()); break; case SelectProtocol.SELECT_BRO: Select(model.GetMessage<SelectModel>()); break; case SelectProtocol.SELECT_SRES: WarningManager.errors.Add(new WarningModel("角色选择失败")); break; case SelectProtocol.TALK_BRO: Talk(model.GetMessage<string>()); break; } }
public void MessageReceive(UserToken token, SocketModel model) { switch (model.command) { case FightProtocol.Fight_REQS: //Console.WriteLine(model.message); FightDis(token, model.GetMessage <int>()); break; case FightProtocol.CallFight_REQS: CallFightDis(token, model.GetMessage <int>()); break; case FightProtocol.PlayerMove_REQS: Move(model.GetMessage <AccountDTO>(), FightProtocol.PlayerMove_ANS, token); break; case FightProtocol.BallMove_REQS: Move(model.GetMessage <AccountDTO>(), FightProtocol.BallMove_ANS, token); break; default: break; } }
public void OnMessageReceived(UserToken token, SocketModel sm) { switch (sm.command) { case TimeProtocol.CHECK_CREQ: //客户端发起对时请求 DelayCheckDTO delayCheckDTO = sm.GetMessage <DelayCheckDTO>(); if (delayCheckDTO.timeStamps.Count < delayCheckDTO.checkNum * 2) { delayCheckDTO.timeStamps.Add(DateTime.Now.Ticks); Send(token, TimeProtocol.CHECK_SRES, delayCheckDTO); } else { //对时次数够了,计算时差和延迟,这里注意最后一个时间戳是client发来的,因此需要再把现在的时间加上进行计算 delayCheckDTO.timeStamps.Add(DateTime.Now.Ticks); DelayAndFloating df = GetDelayAndFloatingEven(delayCheckDTO.timeStamps); userBiz.CacheDelayAndFloating(GetUserId(token), df); } break; case TimeProtocol.CHECK_CRES: //客户端的回应 DelayCheckDTO delayCheck = sm.GetMessage <DelayCheckDTO>(); if (delayCheck.timeStamps.Count <= delayCheck.checkNum * 2) { //对时次数不够,就继续对够 delayCheck.timeStamps.Add(DateTime.Now.Ticks); Send(token, TimeProtocol.CHECK_SREQ, delayCheck); } if (delayCheck.timeStamps.Count == delayCheck.checkNum * 2 + 1) { //对时次数够了,计算时差和延迟 DelayAndFloating df = GetDelayAndFloatingOdd(delayCheck.timeStamps); userBiz.CacheDelayAndFloating(GetUserId(token), df); } break; } }
public void MessageReceive(SocketModel model) { switch (model.command) { case AccountProtocol.REGISTER_SRES: int registResult = model.GetMessage <int>(); registRes(registResult); break; case AccountProtocol.LOGIN_SRES: int accResult = model.GetMessage <int>(); loginRes(accResult); break; case AccountProtocol.OFFLINE_SRES: break; default: break; } }
public void MessageReceive(UserToken token, SocketModel message) { if (!cache.CacheFactory.accountCache.IsOnline(token)) { return; } switch (message.command) { // 请求用户数据 case UserProtocol.GETINFO_CREQ: GetInfo(token); break; // 重命名请求 case UserProtocol.RENAME_CREQ: ReName(token, message); break; // 存储图片请求 case UserProtocol.UPDATEIMG_CREQ: ImageModel im = message.GetMessage <ImageModel>(); SaveImage(token, im); break; // 修改用户信息 case UserProtocol.UPDATEINFO_CREQ: UserModel tmp = message.GetMessage <UserModel>(); updateUserModel(token, tmp); break; } }
public void MessageReceive(SocketModel model) { switch (model.command) { //处理服务器返回登录的结果 case LoginProtocol.Login_SRes: { int status = model.GetMessage <int>(); switch (status) { case 0: GameApp.Instance.CommonHintDlg.OpenHint("登录成功"); LoginReceive(); break; case -1: GameApp.Instance.CommonHintDlg.OpenHint("请求错误"); break; case -2: GameApp.Instance.CommonHintDlg.OpenHint("请求不合法"); break; case -3: GameApp.Instance.CommonHintDlg.OpenHint("没有此帐号"); break; case 4: GameApp.Instance.CommonHintDlg.OpenHint("密码错误"); break; case -5: GameApp.Instance.CommonHintDlg.OpenHint("帐号已登录"); break; } } break; //处理快速注册请求的结果 case LoginProtocol.QuickReg_SRes: { ResponseRegisterModel rrm = model.GetMessage <ResponseRegisterModel>(); if (rrm == null || rrm.Status != 0) { GameApp.Instance.CommonHintDlg.OpenHint("注册失败"); return; } Debug.Log("注册成功,密码是:" + rrm.Password); LoginReceive(); //请求信息 } break; } }
public void MessageReceive(SocketModel model) { switch (model.command) { case LoginProtocol.LOGIN_SRES: login(model.GetMessage <int>()); break; case LoginProtocol.REG_SRES: reg(model.GetMessage <int>()); break; } }
public void MessageReceive(UserToken token, SocketModel message) { switch (message.command) { case AccountProtocol.Login_CREQ: Login(token, message.GetMessage <AccountDTO>()); break; case AccountProtocol.Reg_CREQ: Creat(token, message.GetMessage <AccountDTO>()); break; } }
public void MessageReceive(SocketModel model) { // WarningManager.errors.Add(new WarningModel(model.Message+"")); switch (model.Command) { case LoginProtocol.LOGIN_SRES: Login(model.GetMessage<int>()); break; case LoginProtocol.REG_SRES: Reg(model.GetMessage<int>()); break; } }
// private Dictionary<int, GameObject> teamTwo = new Dictionary<int, GameObject>(); public void MessageReceive(SocketModel model) { switch (model.command) { case FightProtocol.START_BRO: start(model.GetMessage <FightRoomModel>()); break; case FightProtocol.MOVE_BRO: move(model.GetMessage <MoveDTO>()); break; } }
public void OnMessageReceived(UserToken token, SocketModel sm) { switch (sm.command) { case LoginProtocol.LOGIN_CREQ: Login(token, sm.GetMessage <AccountInfoDTO>()); break; case LoginProtocol.REG_CREQ: Reg(token, sm.GetMessage <AccountInfoDTO>()); break; } }
public void MessageReceive(NetFrame.UserToken token, SocketModel message) { switch (message.Command) { case LoginProtocol.LOGIN_CREQ: Login(token, message.GetMessage <AccountModel>()); break; case LoginProtocol.REG_CREQ: Reg(token, message.GetMessage <AccountModel>()); break; } }
public void MessageReceive(UserToken token, SocketModel message) { message.Message = SerializeUtil.DesDecode <AccountInfoDTO>(message.Message as byte[]); switch (message.Command) { case LoginProtocol.LOGIN_CREQ: login(token, message.GetMessage <AccountInfoDTO>()); break; case LoginProtocol.REG_CREQ: reg(token, message.GetMessage <AccountInfoDTO>()); break; } }
public void MessageReceive(UserToken token, SocketModel message) { //登录模块没有子模块,所以直接判断命令协议 switch (message.Command) { case LoginProtocol.LOGIN_CREQ: Login(token, message.GetMessage<AccountInfoDTO>()); break; case LoginProtocol.REG_CREQ: Reg(token, message.GetMessage<AccountInfoDTO>()); break; } }
public void MessageReceive(SocketModel model) { // WarningManager.errors.Add(new WarningModel(model.Message+"")); switch (model.Command) { case LoginProtocol.LOGIN_SRES: Login(model.GetMessage <int>()); break; case LoginProtocol.REG_SRES: Reg(model.GetMessage <int>()); break; } }
public void MessageReceive(SocketModel model) { model.Message = SerializeUtil.DesDecode <int>(model.Message as byte[]); switch (model.Command) { case LoginProtocol.LOGIN_SRES: login(model.GetMessage <int>()); break; case LoginProtocol.REG_SRES: reg(model.GetMessage <int>()); break; } }
public void MessageReceive(UserToken token, SocketModel message) { //登录模块没有子模块,所以直接判断命令协议 switch (message.Command) { case LoginProtocol.LOGIN_CREQ: Login(token, message.GetMessage <AccountInfoDTO>()); break; case LoginProtocol.REG_CREQ: Reg(token, message.GetMessage <AccountInfoDTO>()); break; } }
public void MessageReceive(SocketModel model) { switch (model.Command) { case UserProtocol.INFO_SRES: GetInfo(model.GetMessage<UserDTO>()); break; case UserProtocol.CREATE_SRES: CreateRole(model.GetMessage<bool>()); break; case UserProtocol.ONLINE_SRES: OnLine(model.GetMessage<UserDTO>()); break; } }
//开局 public void RoomGameStart(SocketModel socketModel) { // GameInfo.Instance.isGameStart = 1; int value = socketModel.GetCommand(); if (value > 0) { //手牌 List <int> list = socketModel.GetData(); list.Reverse(); GameInfo.Instance.myHandMj = list; //房间信息 List <string> msg = socketModel.GetMessage(); GameInfo.Instance.zhuangjia = int.Parse(msg[0]); GameInfo.Instance.round = int.Parse(msg[1]); GameInfo.Instance.mjLeft = int.Parse(msg[2]); //开始后,设置所有人状态为未准备 GameInfo.Instance.isMyReady = 0; GameInfo.Instance.isRightReady = 0; GameInfo.Instance.isTopReady = 0; GameInfo.Instance.isLeftReady = 0; //通知UI游戏开始了 GameEvent.DoGameStartEvent(1); Debug.Log("人满开局发牌 " + list); } int mjNum = socketModel.GetCommand(); RoomEvent.DoActionLeftMj(mjNum); }
//摸牌 public void MoPai(SocketModel socketModel) { //GameEvent.DoMsgTipEvent(" 收到摸牌数据"); List <string> msgList = socketModel.GetMessage(); //如果是自己摸牌 Debug.Log("摸牌的位置=" + int.Parse(msgList[0])); if (int.Parse(msgList[0]) == GameInfo.Instance.positon) { Debug.Log("是自己摸牌 摸的牌= " + int.Parse(msgList[1])); //GameEvent.DoMsgTipEvent("是自己摸牌 摸的牌= " + int.Parse(msgList[1])); //摸起的牌放到手牌队列里 int mj = int.Parse(msgList[1]); GameInfo.Instance.putMjtoHandList(mj); //广播给UI显示 GameEvent.DoMoPai(mj); Debug.Log("摸牌==" + mj); //是否能,杠,糊 List <int> list = socketModel.GetData(); RoomEvent.DoActionList(list); //如果Action有数据,可以杠 if (socketModel.GetAdata() != null && socketModel.GetAdata().Count > 0) { Debug.Log("可以杠牌=" + socketModel.GetAdata().Count); GameInfo.Instance.gangList = socketModel.GetAdata();//杠的数据保存在INFO, 选择牌型后清空 } } //不管是谁摸,更新牌的数量 Debug.Log("剩余牌的数量=" + socketModel.GetCommand()); int mjNum = socketModel.GetCommand(); RoomEvent.DoActionLeftMj(mjNum); }
public void MessageReceive(SocketModel model) { switch (model.command) { case UserProtocol.GETINFO_SRES: { UserModel um = model.GetMessage <UserModel>(); if (um != null) { GameApp.Instance.CommonHintDlgScript.OpenHint("获取用户信息成功" + um.nickname); GameSession.Instance.UserInfo = um; //用户信息加载成功后,加载main场景 GameApp.Instance.GameLevelManagerScript.LoadScene(GameResources.SceneName.MAIN); } else { //用户信息加载失败,显示提示信息,先关闭网络再开启网络 GameApp.Instance.CommonHintDlgScript.OpenHint("获取用户信息失败"); ExtendHandler.Close(); ExtendHandler.Connect(); } GameApp.Instance.CommonHintDlgScript.OpenHint("获取no" + um.nickname); } break; } }
/// <summary> /// 用户消息到达 /// </summary> /// <param name="token"></param> /// <param name="message"></param> public void MessageReceive(UserToken token, SocketModel message) { //处理客户端的请求 switch (message.command) { //处理客户端的登录请求 case GameProtocol.LoginProtocol.ENTER_CREQ: DebugUtil.Instance.LogToTime("用户请求登录消息到达"); //对三级消息体的转换 RequestLoginModel rlm = message.GetMessage <RequestLoginModel>(); //获取登录的结果 int result = BizFactory.login.Login(token, rlm); //完成了一次对客户端的消息返回 token.write(TypeProtocol.LOGIN, LoginProtocol.ENTER_SRES, result); break; //处理客户端的快速注册请求 case GameProtocol.LoginProtocol.QUICKREG_CREQ: DebugUtil.Instance.LogToTime("用户请求快速注册消息到达"); ResponseRegisterModel rrmodel = BizFactory.login.Reg(token); //完成了一次对客户端请求注册的消息返回 token.write(TypeProtocol.LOGIN, LoginProtocol.QUICKREG_SRES, rrmodel); break; } }
public void MessageReceive(SocketModel message) { switch (message.command) { case InventoryProtocol.GetInventory_SRES: GetInventory(message.GetMessage <List <InventoryItemDTO> >()); break; case InventoryProtocol.AddInventory_SRES: AddInventory(message.GetMessage <InventoryItemDTO>()); break; case InventoryProtocol.DeleteInventory_SRES: break; } }
public void MessageReceive(UserToken token, SocketModel model) { switch (model.command) { case LoginRegistProtocol.REG_REQS: Regist(token, model.GetMessage <AccountDTO>()); break; case LoginRegistProtocol.Login_REQS: Login(token, model.GetMessage <AccountDTO>()); break; default: break; } }
public void MessageReceive(SocketModel model) { AliveModel am = model.GetMessage <AliveModel>(); if (am != null) { switch (am.Statue) { case 0: //让客户端的包时间和服务器保持一致 GameApp.Instance.AliveMgr.SeverTime = am.Time; break; case -1: //重新发送 GameApp.Instance.AliveMgr.LivingSelf(); break; case -2: //非法或离线 GameApp.Instance.CommonHintDlg.OpenHint("您已断开连接"); break; } } }
//分享钻石 public void FenXiangRqs(SocketModel socketModel) { if (socketModel.GetCommand() == 18) { List <int> list = socketModel.GetData(); int fk = list[0]; GameInfo.Instance.setUserFk(fk); GameEvent.DoMsgTipEvent("分享钻石成功!"); List <string> mList = socketModel.GetMessage(); MailData md = new MailData(); md.setDataTime(mList[0]); md.setFk(int.Parse(mList[1])); md.setGid(int.Parse(mList[2])); md.setStype(int.Parse(mList[3])); GameInfo.Instance.mailList.Insert(0, md); } else if (socketModel.GetCommand() == 17) { GameEvent.DoMsgTipEvent("用户不存在!"); } else { GameEvent.DoMsgTipEvent("未知错误!"); } }
void CreateRoom(SocketModel mes) { RoomInfoDTO dto = mes.GetMessage <RoomInfoDTO>(); uiMgr.LoadPerpareUI(); PrepareUI.GetInstance().CreateRoom(dto); }
public void MessageReceive(SocketModel message) { UiMananager._instance.SetButtonState(true); switch (message.command) { case AccountProtocol.Login_SRES: int login = message.GetMessage <int>(); Login(login); break; case AccountProtocol.Reg_SRES: int reg = message.GetMessage <int>(); Reg(reg); break; } }
public void MessageReceive(SocketModel model) { ChatMesDTO dto = model.GetMessage <ChatMesDTO>(); string mes = dto.userName + ":" + dto.mes; chattingUI.AddSentence(mes); }
void StartGame(SocketModel mes) { DuelRoomMesDTO dto = mes.GetMessage <DuelRoomMesDTO>(); Debug.Log("开始游戏"); uiMgr.LoadDuelField(); Duel.GetInstance().StartGame(); }
public void MessageReceive(SocketModel model) { switch (model.command) { case UserProtocol.INFO_SRES: info(model.GetMessage <UserDTO>()); break; case UserProtocol.CREATE_SRES: create(model.GetMessage <bool>()); break; case UserProtocol.ONLINE_SRES: online(model.GetMessage <UserDTO>()); break; } }
public void MessageReceive(SocketModel message) { switch (message.command) { case SkillProtocol.GetskillList_SRES: GetSkillList(message.GetMessage <List <SkillDTO> >()); break; case SkillProtocol.Updateskill_SRES: UpdateSkill(message.GetMessage <SkillDTO>()); break; case SkillProtocol.SkillUp_SRES: SkillUp(message.GetMessage <SkillDTO>()); break; } }
// private Dictionary<int, GameObject> teamTwo = new Dictionary<int, GameObject>(); public void MessageReceive(SocketModel model) { switch (model.Command) { case FightProtocol.START_BRO: StartFight(model.GetMessage<FightRoomModel>()); break; case FightProtocol.MOVE_BRO: Move(model.GetMessage<MoveDTO>()); break; case FightProtocol.ATTACK_BRO: Move(model.GetMessage<MoveDTO>()); break; case FightProtocol.DAMAGE_BRO: Damage(model.GetMessage<DamageDTO>()); break; } }
public void MessageReceive(UserToken token, SocketModel message) { switch (message.Command) { case UserProtocol.CREATE_CREQ: CreateRole(token, message.GetMessage<string>()); break; case UserProtocol.INFO_CREQ: GetInfo(token); break; case UserProtocol.ONLINE_CREQ: OnLine(token); break; } }
public void MessageReceive(UserToken token, SocketModel message) { switch (message.Command) { case FightProtocol.ENTER_CREQ: Enter(token); break; case FightProtocol.MOVE_CREQ: Move(token,message.GetMessage<MoveDTO>()); break; case FightProtocol.ATTACK_CREQ: Attack(token,message.GetMessage<int>()); break; case FightProtocol.DAMAGE_CREQ: Damage(token, message.GetMessage<DamageDTO>()); break; } }
public void MessageReceive(UserToken token, SocketModel message) { switch (message.Command) { case SelectProtocol.ENTER_CREQ: EnterRoom(token); break; case SelectProtocol.SELECT_CREQ: SelectHero(token, message.GetMessage<int>()); break; case SelectProtocol.TALK_CREQ: Talk(token,message.GetMessage<string>()); break; case SelectProtocol.READY_CREQ: Ready(token); break; } }