public override void OnOperationResponse(OperationResponse operationResponse) { //根据子操作代码分别进行不同的处理 SubCode subCode = ParameterTool.GetParameter <SubCode>(operationResponse.Parameters, ParameterCode.SubCode, false); switch (subCode) { case SubCode.GetRole: //Debug.Log("SubCode.GetRole"); List <Role> list = ParameterTool.GetParameter <List <Role> >(operationResponse.Parameters, ParameterCode.RoleList); OnGetRole(list); break; case SubCode.AddRole: //Debug.Log("SubCode.AddRole"); Role role = ParameterTool.GetParameter <Role>(operationResponse.Parameters, ParameterCode.Role); OnAddRole(role); break; case SubCode.SelectRole: //Debug.Log("SubCode.SelectRole"); OnSelectRole(); break; } }
public override void OnResponse(OperationResponse response) { base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; Dictionary <byte, object> parameter = response.Parameters; if (errCode != ErrorCode.Success) { this.HandleErrorCode(errCode); Debug.Log(string.Format("ResponseReceived, OperationCode = {0}, ReturnCode = {1}, DebugMsg = {2}", opCode, errCode, response.DebugMessage)); return; } switch (opCode) { case OperationCode.UserUpdate: { SubCode subCode = (SubCode)parameter[(byte)ParameterCode.SubCode]; switch (subCode) { case SubCode.AddFriend: HandleReponseAddFriend(response); break; } } break; default: break; } }
public override void OnOperationResponse(OperationResponse operationResponse) { SubCode subCode = ParameterTool.GetSubCode(operationResponse.Parameters); switch (subCode) { case SubCode.GetSkillDBList: //Debug.Log("OnGetSkillList"); List <SkillDB> skillList = ParameterTool.GetParameter <List <SkillDB> >(operationResponse.Parameters, ParameterCode.SkillDBList); OnGetSkillList(skillList); break; case SubCode.AddSkillDB: //Debug.Log("OnAddSkillDB"); SkillDB skillAdd = ParameterTool.GetParameter <SkillDB>(operationResponse.Parameters, ParameterCode.SkillDB); OnAddSkillDB(skillAdd); break; case SubCode.UpgradeSkillDB: //Debug.Log("OnUpgradeSkillDB"); SkillDB skillUpgrade = ParameterTool.GetParameter <SkillDB>(operationResponse.Parameters, ParameterCode.SkillDB); OnUpgradeSkillDB(skillUpgrade); break; } }
public override void OnOperationResponse(OperationResponse operationResponse) { SubCode subCode = ParameterTool.GetSubCode(operationResponse.Parameters); switch (subCode) { case SubCode.TeamFight: if (operationResponse.ReturnCode == (short)ReturnCode.HavingTeam) //组队成功 { //Debug.Log("SubCode.TeamFight"); List <Role> roleList = ParameterTool.GetParameter <List <Role> >(operationResponse.Parameters, ParameterCode.RoleList); int masterRoleId = ParameterTool.GetParameter <int>(operationResponse.Parameters, ParameterCode.MasterRoleId, false); OnHavingTeam(roleList, masterRoleId); } else if (operationResponse.ReturnCode == (short)ReturnCode.WaitingTeam) //组队失败 { //Debug.Log("SubCode.TeamFight"); OnWaitingTeam(); } break; case SubCode.CancelTeam: //Debug.Log("SubCode.CancelFight"); OnCancelTeam(); break; } }
public override void OnHandlerMessage(Photon.SocketServer.OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { SubCode subCode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false); response.Parameters.Add((byte)ParameterCode.SubCode, subCode); switch (subCode) { case SubCode.AddTaskDB: TaskDB taskDB = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB); taskDB.Role = peer.LoginRole; taskDBManager.AddTaskDB(taskDB); taskDB.Role = null; ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDB, taskDB); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.GetTaskDB: List <TaskDB> list = taskDBManager.GetTaskDBList(peer.LoginRole); foreach (var taskDb in list) { taskDb.Role = null; } ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDBList, list); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.UpdateTaskDB: TaskDB taskDB2 = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB); taskDB2.Role = peer.LoginRole; taskDBManager.UpdateTaskDB(taskDB2); response.ReturnCode = (short)ReturnCode.Success; break; } }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subCode = ParameterTool.GetParameters <SubCode>(response.Parameters, ParameterCode.SubCode, false); switch (subCode) { case SubCode.SendTeam: if (response.ReturnCode == (short)ReturnCode.GetTeam) { List <Role> list = ParameterTool.GetParameters <List <Role> >(response.Parameters, ParameterCode.RoleList); int masterRoleID = ParameterTool.GetParameters <int>(response.Parameters, ParameterCode.MasterRoleID, false); //组队成功 if (OnGetTeam != null) { OnGetTeam(list, masterRoleID); } } else if (response.ReturnCode == (short)ReturnCode.WaitTeam) { if (OnWaitTeam != null) { OnWaitTeam(); } //正在组队 } break; case SubCode.CancelTeam: if (OnCancelTeam != null && response.ReturnCode == (short)ReturnCode.Success) { OnCancelTeam(); } break; } }
public void SendRequest(OperationCode opCode, SubCode subCode, Dictionary <byte, object> parameters) { Debug.Log("到PhotonEngine的82行: " + opCode); parameters.Add((byte)ParameterCode.SubCode, subCode); peer.OpCustom((byte)opCode, parameters, true); Debug.Log("到PhotonEngine的85行: " + opCode); }
public override void OnOperationResponse(OperationResponse response) { print("到RoleController的43行: " + response.ToString()); SubCode subCode = ParameterTool.GetParameter <SubCode>(response.Parameters, ParameterCode.SubCode, false); switch (subCode) { case SubCode.GetRole: List <Role> list = ParameterTool.GetParameter <List <Role> >(response.Parameters, ParameterCode.RoleList); if (OnGetRole != null) { OnGetRole(list); } break; case SubCode.AddRole: Role role = ParameterTool.GetParameter <Role>(response.Parameters, ParameterCode.Role); if (OnAddRole != null) { OnAddRole(role); } break; case SubCode.SelectRole: print("到RoleController的66行: " + SubCode.SelectRole); if (OnSelectRole != null) { OnSelectRole(); } break; } }
public override void OnEvent(EventData eventData) { SubCode subcode = ParameterTool.GetSubcode(eventData.Parameters); switch (subcode) { case SubCode.CreateEnemy: CreateEnemyModel model = ParameterTool.GetParameter <CreateEnemyModel>(eventData.Parameters, ParameterCode.CreateEnemyModel); if (OnCreateEnemy != null) { OnCreateEnemy(model); } break; case SubCode.SyncPositionAndRotation: EnemyPositionModel model1 = ParameterTool.GetParameter <EnemyPositionModel>(eventData.Parameters, ParameterCode.EnemyPositionModel); if (OnSyncEnemyPositionAndRotation != null) { OnSyncEnemyPositionAndRotation(model1); } break; case SubCode.SyncAnimation: EnemyAnimationModel model2 = ParameterTool.GetParameter <EnemyAnimationModel>(eventData.Parameters, ParameterCode.EnemyAnimationModel); if (OnSyncEnemyAnimation != null) { OnSyncEnemyAnimation(model2); } break; } }
//public void UpdateRole(Role role) //{ // Dictionary<byte, object> parameters = new Dictionary<byte, object>(); // parameters.Add((byte)ParameterCode.Role, JsonMapper.ToJson(role)); // PhotonEngine.Instance.SendRequest(OpCode, SubCode.UpdateRole, parameters); //} public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subcode = ParameterTool.GetParameter <SubCode>(response.Parameters, ParameterCode.SubCode, false); switch (subcode) { case SubCode.GetRole: List <Role> list = ParameterTool.GetParameter <List <Role> >(response.Parameters, ParameterCode.RoleList); OnGetRole(list); break; case SubCode.AddRole: Role role = ParameterTool.GetParameter <Role>(response.Parameters, ParameterCode.Role); if (response.ReturnCode == (short)ReturnCode.Fail) { MessageManager._instance.ShowMessage(response.DebugMessage); return; } OnAddRole(role); break; case SubCode.SelectRole: if (OnSelectRole != null) { OnSelectRole(); } break; } if (response.ReturnCode == (short)ReturnCode.Fail) { MessageManager._instance.ShowMessage(response.DebugMessage); } }
public override void OnEvent(EventData eventData) { SubCode subCode = ParameterTool.GetParameters <SubCode>(eventData.Parameters, ParameterCode.SubCode, false); switch (subCode) { case SubCode.CreateEnemy: //Debug.Log("Get the response from server.."); CreateEnemyModel model = ParameterTool.GetParameters <CreateEnemyModel>(eventData.Parameters, ParameterCode.CreateEnemyModel); if (OnCreateEnemy != null) { OnCreateEnemy(model); } break; case SubCode.AsyncPostionAndEularAngler: EnemyPostionModel enemyPosmodel = ParameterTool.GetParameters <EnemyPostionModel>(eventData.Parameters, ParameterCode.EnemyPostionModel); if (OnAsyncEnemyPostionRotation != null) { OnAsyncEnemyPostionRotation(enemyPosmodel); } break; case SubCode.SyncEnemyAnimation: EnemyAnimationModel enemyAnimmodel = ParameterTool.GetParameters <EnemyAnimationModel>(eventData.Parameters, ParameterCode.EnemyAnimationModel); if (OnSyncEnemyAnimation != null) { OnSyncEnemyAnimation(enemyAnimmodel); } break; } }
public override void OnOperationResponse(OperationResponse response) { SubCode subCode = ParameterTool.GetParameter <SubCode>(response.Parameters, ParameterCode.SubCode, false); switch (subCode) { case SubCode.GetTaskDB: List <TaskDB> list = ParameterTool.GetParameter <List <TaskDB> >(response.Parameters, ParameterCode.TaskDBList); if (OnGetTaskDBList != null) { OnGetTaskDBList(list); } break; ; case SubCode.AddTaskDB: TaskDB taskDb = ParameterTool.GetParameter <TaskDB>(response.Parameters, ParameterCode.TaskDB); if (OnAddTaskDB != null) { OnAddTaskDB(taskDb); } break; ; case SubCode.UpdateTaskDB: if (OnUpdateTaskDB != null) { OnUpdateTaskDB(); } break; } }
public override void OnResponse(OperationResponse response) { base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; if (errCode != ErrorCode.Success) { this.HandleErrorCode(errCode); Debug.Log(string.Format("ResponseReceived, OperationCode = {0}, ReturnCode = {1}, DebugMsg = {2}", opCode, errCode, response.DebugMessage)); return; } switch (opCode) { case OperationCode.UserUpdate: { SubCode subCode = (SubCode)response.Parameters[(byte)ParameterCode.SubCode]; switch (subCode) { case SubCode.GetHires: { HandleGetHires(response); } break; } } break; default: break; } }
public override void OnEventData(EventData data) { SubCode subCode = ParameterTool.GetSubCode(data.Parameters); switch (subCode) { case SubCode.SyncEnemyCreat: //Debug.Log("SubCode.CreatEnemy"); EnemyCreatModel model = ParameterTool.GetParameter <EnemyCreatModel>(data.Parameters, ParameterCode.CreatEnemy); OnSyncEnemyCreat(model); break; case SubCode.SyncPositionAndRotation: //Debug.Log("SubCode.SyncPositionAndRotation"); EnemyPositionModel model2 = ParameterTool.GetParameter <EnemyPositionModel>(data.Parameters, ParameterCode.EnemyPosition); OnSyncEnemyPosition(model2); break; case SubCode.SyncEnemyAnim: //Debug.Log("SubCode.SyncPositionAndRotation"); EnemyAnimModel model3 = ParameterTool.GetParameter <EnemyAnimModel>(data.Parameters, ParameterCode.EnemyAnim); OnSyncEnemyAnim(model3); break; } }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer) { SubCode subCode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false); Dictionary <byte, object> parameters = response.Parameters; parameters.Add((byte)ParameterCode.SubCode, subCode); switch (subCode) { case SubCode.GetTaskDBList: List <TaskDB> taskDBList = manager.GetTaskDBList(peer.LoginRole); foreach (var taskDBTemp in taskDBList) { taskDBTemp.Role = null; //防止json解析错误 } ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDBList, taskDBList); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.AddTaskDB: TaskDB taskDBAdd = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB); taskDBAdd.Role = peer.LoginRole; manager.AddTaskDB(taskDBAdd); taskDBAdd.Role = null; ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDB, taskDBAdd); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.UpdateTaskDB: TaskDB taskDBUpdate = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB); taskDBUpdate.Role = peer.LoginRole; manager.UpdateTaskDB(taskDBUpdate); response.ReturnCode = (short)ReturnCode.Success; break; } }
private void OnRecord(IMClientPeer peer, OperationRequest request) { const SubCode subCode = SubCode.Chat_Record; if (!TryInitResponse(subCode, peer, request, out var parameters, ParameterKeys.CHAT_RECORD_REQUEST, out ChatRecordRequestModel model)) { return; } //DB查询聊天记录 var records = ChatManager.GetRecordsBySendAndRecUsername(peer.LoginUser?.Username, model.ReceiveUsername, model.MinDay, model.MaxDay); var tmpRec = ChatManager.GetRecordsBySendAndRecUsername(model.ReceiveUsername, peer.LoginUser?.Username, model.MinDay, model.MaxDay); if (tmpRec != null) { if (records == null) { records = tmpRec; } else { records.AddRange(tmpRec); } } records?.Sort((left, right) => left.Time.CompareTo(right.Time)); //响应 peer.SendResponse(ReturnCode.Success, parameters.AddParameter(ParameterKeys.CHAT_RECORD_RESPONSE, new ChatRecordResponseModel(records))); }
public override void OnEvent(EventData eventData) { SubCode subCode = ParameterTool.GetSubcode(eventData.Parameters); switch (subCode) { case SubCode.GetTeam: List <Role> roles = ParameterTool.GetParameter <List <Role> >(eventData.Parameters, ParameterCode.RoleList); int masterRoleID = ParameterTool.GetParameter <int>(eventData.Parameters, ParameterCode.MasterRoleID, false); if (OnGetTeam != null) { OnGetTeam(roles, masterRoleID); } break; case SubCode.SyncPositionAndRotation: int roleID = ParameterTool.GetParameter <int>(eventData.Parameters, ParameterCode.RoleID, false); Vector3 pos = ParameterTool.GetParameter <Vector3Obj>(eventData.Parameters, ParameterCode.Position).ToVector3(); Vector3 eulerAngles = ParameterTool.GetParameter <Vector3Obj>(eventData.Parameters, ParameterCode.EulerAngles).ToVector3(); if (OnSyncPositionAndRotation != null) { OnSyncPositionAndRotation(roleID, pos, eulerAngles); } break; case SubCode.SyncMoveAnimation: int roleID2 = ParameterTool.GetParameter <int>(eventData.Parameters, ParameterCode.RoleID, false); PlayerMoveAnimationModel model = ParameterTool.GetParameter <PlayerMoveAnimationModel>(eventData.Parameters, ParameterCode.PlayerMoveAnimationModel); if (OnSyncMoveAnimation != null) { OnSyncMoveAnimation(roleID2, model); } break; case SubCode.SyncAnimation: int roleID3 = ParameterTool.GetParameter <int>(eventData.Parameters, ParameterCode.RoleID, false); PlayerAnimationModel model2 = ParameterTool.GetParameter <PlayerAnimationModel>(eventData.Parameters, ParameterCode.PlayerAnimationModel); if (OnSyncPlayerAnimation != null) { OnSyncPlayerAnimation(roleID3, model2); } break; case SubCode.SendGameState: GameStateModel model3 = ParameterTool.GetParameter <GameStateModel>(eventData.Parameters, ParameterCode.GameStateModel); if (OnGameStateChange != null) { OnGameStateChange(model3); } break; } }
public override void OnOperationResponse(OperationResponse response) { SubCode subcode = ParameterTool.GetSubcode(response.Parameters); switch (subcode) { case SubCode.SendTeam: if (response.ReturnCode == (int)ReturnCode.GetTeam) { List <Role> roles = ParameterTool.GetParameter <List <Role> >(response.Parameters, ParameterCode.RoleList); int masterRoleID = ParameterTool.GetParameter <int>(response.Parameters, ParameterCode.MasterRoleID, false); if (OnGetTeam != null) { OnGetTeam(roles, masterRoleID); } } else if (response.ReturnCode == (int)ReturnCode.WartingTeam) { if (OnWaitingTeam != null) { OnWaitingTeam(); } } break; case SubCode.CancelTeam: if (OnCancelTeam != null) { OnCancelTeam(); } break; } }
// void SendMoveAnimationEvent(ClientPeer peer, OperationCode opCode, SubCode subCode, int roleid, Dictionary <byte, object> parameters) { EventData data = new EventData(); data.Parameters = parameters; ParameterTool.AddOperationcodeSubcodeRoleId(parameters, opCode, roleid); peer.SendEvent(data, new SendParameters()); }
//发送团队角色动画进行同步 public void SendMoveAnimationToPeer(ClientPeer peer, OperationCode opCode, SubCode subCode, int roleId, Dictionary <byte, object> parameters) { EventData data = new EventData(); data.Parameters = parameters; ParameterTool.AddEventToPeer(data.Parameters, opCode, subCode, roleId); peer.SendEvent(data, new SendParameters()); }
private void OnSuccessOperationRequestEvent(OperationCode operationCode, SubCode subCode, OperationRequest request) { //TODO if (operationCode != OperationCode.Chat) { return; } }
public int SubscribeCodes(string username, string[] codelist) { if (_dataAdapter != null) { List <string> subcodes = new List <string>(); for (int i = 0; i < codelist.Length; i++) { string code = codelist[i]; if (_codes.ContainsKey(code)) { //更新代码时间 SubCode sc = _codes[code]; sc.Flush(username); } else { //添加代码 if (StockCodeManager.GetInstance.Codes.ContainsKey(code)) { //有效代码 SubCode sc = new SubCode(); sc.Code = code; sc.Name = StockCodeManager.GetInstance.GetStockName(code); sc.SubTime = DateTime.Now; sc.FlushTime = DateTime.Now; sc.Users.Add(username); _codes.Add(code, sc); subcodes.Add(code); } } } if (_clients.ContainsKey(username)) { //为用户添加订阅代码 _clients[username].AddSubCodes(codelist.ToList <string>()); } else { //添加用户信息 UserClient uc = new UserClient(); uc.Username = username; uc.AddSubCodes(codelist.ToList <string>()); _clients.Add(username, uc); } if (subcodes.Count > 0) { //添加数据源的订阅代码 _dataAdapter.RegisterCodes(subcodes); App.Logger.Info(string.Format("DataService:用户{0}添加订阅,订阅列表:{1}", username, string.Join(",", subcodes))); } return(subcodes.Count); } return(0); }
private void OnAddResponse(IMClientPeer peer, OperationResponse response) { const SubCode subCode = SubCode.Contact_Add_Response; if (!TryInitResponse(subCode, peer, response, out var parameters, ParameterKeys.CONTACT_ADD_CLIENT_RESPONSE, out ContactAddClientResponseModel model)) { return; } if (peer.LoginUser == null) { mLogger.ErrorFormat("响应失败!客户端:{0}未登陆!", peer); return; } var contactAddRequest = ContactAddRequestManager.GetContactAddRequest(model.RequestUsername, peer.LoginUser.Username); if (contactAddRequest == null) { peer.SendResponse(ReturnCode.UsernameDoesNotExist, parameters); return; } var responseCode = model.Accept ? ContactAddRequest.ContactAddResponseCode.Accept : ContactAddRequest.ContactAddResponseCode.Refuse; //DB更新 contactAddRequest.ResponseCode = (int)responseCode; ContactAddRequestManager.UpdateContactAddRequest(contactAddRequest); var requestUser = UserManager.GetUser(model.RequestUsername); if (model.Accept) { //DB添加 ContactManager.AddContact(new Contact { Username = model.RequestUsername, ContactUsername = peer.LoginUser.Username }); ContactManager.AddContact(new Contact { Username = peer.LoginUser.Username, ContactUsername = requestUser.Username }); } //响应 ContactAddServerResponseModel responseModel1 = new ContactAddServerResponseModel(false, responseCode, new UserModel(requestUser)); peer.SendResponse(ReturnCode.Success, parameters.AddParameter(ParameterKeys.CONTACT_ADD_SERVER_RESPONSE, responseModel1)); //如果请求方在线,发送响应 if (IMApplication.Instance.TryGetPeerByUsername(model.RequestUsername, out var requestPeer)) { ContactAddServerResponseModel responseModel2 = new ContactAddServerResponseModel(true, responseCode, new UserModel(peer.LoginUser)); parameters[ParameterKeys.CONTACT_ADD_SERVER_RESPONSE] = responseModel2; requestPeer.SendRequest(parameters); } }
public override void OnResponse(OperationResponse response) { _waitServer = false; base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; if (errCode != ErrorCode.Success) { Debug.Log("errCode" + errCode + " - opCode " + opCode + " " + response.DebugMessage); this.HandleErrorCode(errCode); return; } switch (opCode) { case OperationCode.RoleUpdate: _uiHeroManger.OnResponseRoleUpdate(); break; case OperationCode.RolesList: HandleRoleList(response); break; case OperationCode.UserUpdate: { SubCode subCode = (SubCode)response.Parameters[(byte)ParameterCode.SubCode]; switch (subCode) { case SubCode.CheckCash: // _uiHeroManger.OnRefreshGold(); break; case SubCode.ItemSell: HandleItemSell(response); break; case SubCode.RoleSetItem: _uiHeroManger.OnResponseEquipment(); break; //case SubCode.GetHires: // HandleGetHires(response); // break; case SubCode.SetHire: HandleSetHires(response); break; } } break; default: break; } }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { SubCode subCode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false); ParameterTool.AddParmeter(response.Parameters, ParameterCode.SubCode, subCode, false); switch (subCode) { case SubCode.GetInventoryItemDB: List <InventoryItemDB> list = inventoryItemDbManager.GetInventoryItemDB(peer.LoginRole); foreach (var item in list) { item.Role = null; } ParameterTool.AddParmeter(response.Parameters, ParameterCode.InventoryItemDBList, list); break; case SubCode.AddInventoryItemDB: InventoryItemDB itemDb = ParameterTool.GetParameter <InventoryItemDB>(request.Parameters, ParameterCode.InventoryItemDB); itemDb.Role = peer.LoginRole; inventoryItemDbManager.AddInventoryItemDB(itemDb); itemDb.Role = null; ParameterTool.AddParmeter(response.Parameters, ParameterCode.InventoryItemDB, itemDb); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.UpdateInventoryItemDB: InventoryItemDB itemDb2 = ParameterTool.GetParameter <InventoryItemDB>(request.Parameters, ParameterCode.InventoryItemDB); itemDb2.Role = peer.LoginRole; inventoryItemDbManager.UpdateInventoryItemDB(itemDb2); break; case SubCode.UpdateInventoryItemDBList: List <InventoryItemDB> list2 = ParameterTool.GetParameter <List <InventoryItemDB> >(request.Parameters, ParameterCode.InventoryItemDBList); foreach (var itemDB3 in list2) { itemDB3.Role = peer.LoginRole; } inventoryItemDbManager.UpdateInventoryItemDBList(list2); break; case SubCode.UpgradeEquip: InventoryItemDB itemDb4 = ParameterTool.GetParameter <InventoryItemDB>(request.Parameters, ParameterCode.InventoryItemDB); Role role = ParameterTool.GetParameter <Role>(request.Parameters, ParameterCode.Role); peer.LoginRole = role; role.User = peer.LoginUser; itemDb4.Role = role; inventoryItemDbManager.UpgradeEquip(itemDb4, role); break; } }
public override void OnHandleMessage(OperationRequest request, OperationResponse response, MasterClientPeer peer, SendParameters sendParameters) { var user = ParameterTool.GetParameter <User>(request.Parameters, ParameterCode.User); var userDB = manager.GetUserByAccesstoken(user.Accesstoken); SubCode subCode = ParameterTool.GetSubcode(request.Parameters); ParameterTool.AddSubcode(response.Parameters, subCode); switch (subCode) { case SubCode.AccLogin: { if (userDB != null && userDB.Password == MD5Tool.GetMD5(user.Password)) { ParameterTool.AddParameter <User>(response.Parameters, ParameterCode.User, userDB); //用户名和密码正确,登陆成功 response.ReturnCode = (short)ReturnCode.Success; peer.User = userDB; //if (MasterApplication.Instance.TeamCtrl.ContansUser(userDB.ID))//如果之前正在游戏中 //{ // peer.Team = MasterApplication.Instance.TeamCtrl.GetTeamByUser(userDB.ID); //} } else { response.ReturnCode = (short)ReturnCode.Fail; response.DebugMessage = "用户名或密码错误"; } //string username = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Username, false); // password = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Password, false); Log("Login:acesstoken=" + user.Accesstoken + ",password="******"用户已存在"; } //string username = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Username, false); //string password = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Password, false); Log("Register:acesstoken=" + user.Accesstoken + ",password=" + user.Password); } break; } }
//发送给客户端masterId public void SendMasterIdToPeer(ClientPeer peer, OperationCode opCode, SubCode subCode, int masterRoleId, List <Role> roleList) { EventData data = new EventData(); data.Parameters = new Dictionary <byte, object>(); ParameterTool.AddOperationCode(data.Parameters, opCode); ParameterTool.AddSubCode(data.Parameters, subCode); ParameterTool.AddParameter(data.Parameters, ParameterCode.MasterRoleId, masterRoleId, false); ParameterTool.AddParameter(data.Parameters, ParameterCode.RoleList, roleList); peer.SendEvent(data, new SendParameters()); }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { //先得到子操作代码,根据子操作代码,分别进行不同的处理 SubCode subCode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false); Dictionary <byte, object> parameters = response.Parameters; parameters.Add((byte)ParameterCode.SubCode, subCode); response.OperationCode = request.OperationCode; switch (subCode) { case SubCode.GetRole: List <Role> rolelList = roleManager.GetRoleListByUser(peer.LoginUser); foreach (var role1 in rolelList) { role1.User = null; } ParameterTool.AddParmeter(parameters, ParameterCode.RoleList, rolelList); break; case SubCode.AddRole: Role role = ParameterTool.GetParameter <Role>(request.Parameters, ParameterCode.Role); //request ?? response 互换实验看看 ??request正确 role.User = peer.LoginUser; roleManager.AddRole(role); role.User = null; ParameterTool.AddParmeter(response.Parameters, ParameterCode.Role, role); break; case SubCode.SelectRole: peer.LoginRole = ParameterTool.GetParameter <Role>(request.Parameters, ParameterCode.Role); break; case SubCode.UpdateRole: Role role2 = ParameterTool.GetParameter <Role>(request.Parameters, ParameterCode.Role); role2.User = peer.LoginUser; roleManager.UpdateRole(role2); role2.User = null; response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.GetTumoRole: User user = ParameterTool.GetParameter <User>(request.Parameters, ParameterCode.User); log.Debug("Role63" + user.Username); User user1 = userManager.GetUserByUsernmae(user.Username); List <Role> tumoRolelList = roleManager.GetRoleListByUser(user1); foreach (var role1 in tumoRolelList) { role1.User = null; } ParameterTool.AddParmeter(parameters, ParameterCode.TumoRoleList, tumoRolelList); log.Debug("Role70" + tumoRolelList[0].Name); break; } }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { SubCode subcode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false); ParameterTool.AddParameter(response.Parameters, ParameterCode.SubCode, subcode, false); switch (subcode) { case SubCode.GetInventoryDB: Role role = peer.LoginRole; List <InventoryDB> list = inventoryManager.GetInventoryDB(role); foreach (var inventorydb in list) { inventorydb.Role = null; } ParameterTool.AddParameter(response.Parameters, ParameterCode.InventoryDBList, list); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.AddInventoryDB: TaidouServer.log.Debug("在此将物品添加到数据库中"); InventoryDB itemDb = ParameterTool.GetParameter <InventoryDB>(request.Parameters, ParameterCode.InventoryDB); itemDb.Role = peer.LoginRole; TaidouServer.log.Debug(itemDb.Level); inventoryManager.AddInventoryDB(itemDb); itemDb.Role = null; ParameterTool.AddParameter(response.Parameters, ParameterCode.InventoryDB, itemDb); response.ReturnCode = (short)ReturnCode.Success; break; case SubCode.UpdateInventoryDB: InventoryDB itemdb1 = ParameterTool.GetParameter <InventoryDB>(request.Parameters, ParameterCode.InventoryDB); itemdb1.Role = peer.LoginRole; inventoryManager.UpdateInventoryDB(itemdb1); break; case SubCode.ChangeInventoryDBList: List <InventoryDB> itemList = ParameterTool.GetParameter <List <InventoryDB> >(request.Parameters, ParameterCode.InventoryDBList); foreach (var temp in itemList) { temp.Role = peer.LoginRole; } inventoryManager.ChangeInventoryDBList(itemList); break; case SubCode.UpgradeEquip: InventoryDB itemdb2 = ParameterTool.GetParameter <InventoryDB>(request.Parameters, ParameterCode.InventoryDB); Role role2 = ParameterTool.GetParameter <Role>(request.Parameters, ParameterCode.Role); peer.LoginRole = role2; role2.User = peer.LoginUser; itemdb2.Role = role2; inventoryManager.UpgradeEquip(itemdb2, role2); break; } }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { SubCode subCode = ParameterTool.GetSubcode(request.Parameters); switch (subCode) { case SubCode.SyncBossAnimation: RequestTool.TransmitRequst(peer, request, OpCode); break; } }
private void SendMoveAnimationEvent(ClientPeer peer,OperationCode opCode,SubCode subCode,int roleID,Dictionary<byte,object> parameters ) { EventData data = new EventData(); data.Parameters = parameters; ParameterTool.AddOperationcodeSubcodeRoleID(parameters,opCode,roleID); peer.SendEvent(data, new SendParameters()); }
public void SendRequest(OperationCode opCode, SubCode subCode, Dictionary<byte, object> parameters) { Debug.Log("sent request to server ,opcode : " + opCode + " subcode : " + subCode); parameters.Add((byte)ParameterCode.SubCode,subCode); peer.OpCustom((byte) opCode, parameters, true); }
//向客户端发送位置和旋转的数据 进行同步 private void SendEventByPeer(ClientPeer peer,OperationCode opCode,SubCode subCode,int roleId,object posObj,object eulerAnglesObj) { EventData data = new EventData(); data.Parameters = new Dictionary<byte, object>(); ParameterTool.AddParameter(data.Parameters,ParameterCode.OperationCode, opCode,false); ParameterTool.AddParameter(data.Parameters,ParameterCode.SubCode, subCode,false); data.Parameters.Add((byte) ParameterCode.RoleID,roleId); data.Parameters.Add((byte) ParameterCode.Position,posObj.ToString()); data.Parameters.Add((byte) ParameterCode.EulerAngle,eulerAnglesObj.ToString()); peer.SendEvent(data, new SendParameters()); }
private void SentEventByPeer(ClientPeer peer,OperationCode opCode, SubCode subcode,List<Role> rolelist,int masterRoleID) { //OperationResponse response = new OperationResponse(); //response.Parameters = new Dictionary<byte, object>(); //ParameterTool.AddSubCode(response.Parameters,subcode); //ParameterTool.AddParameter(response.Parameters,ParameterCode.RoleList, rolelist); //response.ReturnCode = (short) ReturnCode.GetTeam; //peer.SendOperationResponse(response, sendParameters); EventData eventData = new EventData(); eventData.Parameters = new Dictionary<byte, object>(); ParameterTool.AddParameter(eventData.Parameters,ParameterCode.OperationCode,opCode,false); ParameterTool.AddSubCode(eventData.Parameters,subcode); ParameterTool.AddParameter(eventData.Parameters,ParameterCode.RoleList,rolelist); ParameterTool.AddParameter(eventData.Parameters,ParameterCode.MasterRoleID, masterRoleID,false); peer.SendEvent(eventData,new SendParameters()); }