public void handle_recv_sys_msg(cmd_msg msg) { GetSystemMessageRes res = proto_man.protobuf_deserialize <GetSystemMessageRes>(msg.body); Debug.Log(res); if (res == null) { return; } if (res.status != Respones.OK) { Debug.Log("sys_msg_status: " + res.status); return; } if (this.sys_msg_version == res.vernum) { Debug.Log("use the local data"); } else { this.sys_msg_version = res.vernum; this.sys_msgs = res.info;//List<string> info = res.info; } event_manager.Instance.dispatch_event(event_manager.EVT_GET_SYS_EMAIL, this.sys_msgs); }
private void on_auth_server_return(cmd_msg msg) { Cmd ctype = (Cmd)msg.ctype; switch (ctype) { case Cmd.eGuestLoginRes: this.on_guest_login_return(msg); break; case Cmd.eEditProfileRes: this.on_edit_profile_return(msg); break; case Cmd.eAccountUpgradeRes: this.on_guest_account_upgrade_return(msg); break; case Cmd.eUnameLoginRes: this.on_uname_login_return(msg); break; case Cmd.eLoginOutRes: this.on_login_out_return(msg); break; } }
void on_system_server_return(cmd_msg msg) { Debug.Log("------------------------------------------"); Debug.Log("recv_msg_system_type=> " + msg.ctype); switch (msg.ctype) { case (int)Cmd.eGetUgameInfoRes: this.handle_get_ugame_info(msg); break; case (int)Cmd.eRecvLoginBonuesRes: this.handle_recv_login_bonues(msg); break; case (int)Cmd.eGetWorldRankUchipRes: this.handle_recv_world_rank(msg); break; case (int)Cmd.eGetSystemMessageRes: this.handle_recv_sys_msg(msg); break; default: Debug.Log("recv_msg not register call function===> ctype=> " + msg.ctype); break; } }
private void on_guest_login_return(cmd_msg msg) { GuestLoginRes res = proto_man.protobuf_deserialize <GuestLoginRes>(msg.body); if (res == null) { Debug.LogError("res == null"); return; } if (res.status != Respones.OK) { PlayerPrefs.DeleteKey("moba_guest_key"); Debug.LogError("error to login: "******" " + uinfo.uid + " " + uinfo.uface); ugame.Instance.save_uinfo(uinfo, true, this.g_key); event_manager.Instance.dispatch_event("login_success"); event_manager.Instance.dispatch_event("sync_uinfo"); }
private void on_get_sys_msg_return(cmd_msg msg) { GetSysMsgRes res = proto_man.protobuf_deserialize <GetSysMsgRes>(msg.body); if (res == null) { Debug.LogError("error !!!"); return; } if (res.status != Respones.OK) { Debug.LogError("error !!! " + res.status); return; } if (this.ver_num == res.ver_num) { } else { this.ver_num = res.ver_num; this.sys_msgs = res.sys_msgs; } event_manager.Instance.dispatch_event("get_sys_email", this.sys_msgs); }
void on_chat_room_server_resp(cmd_msg msg) { switch (msg.ctype) { case (int)game.Cmd.eLoginRes: on_login_resp(msg.body); break; case (int)game.Cmd.eExitRes: on_exit_resp(msg.body); break; case (int)game.Cmd.eSendMsgRes: on_send_resp(msg.body); break; case (int)game.Cmd.eOnUserLogin: on_user_login(msg.body); break; case (int)game.Cmd.eOnUserExit: on_user_exit(msg.body); break; case (int)game.Cmd.eOnSendMsg: on_user_msg(msg.body); break; } }
void on_guest_login_return(cmd_msg msg) { GuestLoginRes res = proto_man.protobuf_deserialize <GuestLoginRes>(msg.body); if (res == null) { return; } if (res.status != Respones.OK) { Debug.Log("Guest login status: " + res.status); return; } UserCenterInfo uinfo = res.uinfo; ugame.Instance.save_uinfo(uinfo, true, this.g_key); // 保存游戏的key到本地 if (this.is_save_gkey) { this.is_save_gkey = false; PlayerPrefs.SetString("bycw_moba_guest_key", this.g_key); } //end event_manager.Instance.dispatch_event("login_success", null); event_manager.Instance.dispatch_event("sync_uinfo", null); }
private void OnGuestLoginReturn(cmd_msg msg) { GuestLoginRes res = proto_man .protobuf_deserialize <GuestLoginRes>(msg.body); if (res == null) { return; } if (res.status != Response.OK) { Debug.Log("Guest Login status:" + res.status); return; } UserCenterInfo uinfo = res.uinfo; UGame.Instance.SaveUInfo(uinfo, true, this.g_key); //保存游客Key到本地 if (this._isSaveGKey) { this._isSaveGKey = false; PlayerPrefs.SetString("xcy_moba_guest_key", this.g_key); } EventManager.Instance.DispatchEvent("login_success", null); EventManager.Instance.DispatchEvent("sync_uinfo", null); }
void OnAuthServerReturn(cmd_msg msg) { switch (msg.ctype) { case (int)Cmd.eGuestLoginRes: OnGuestLoginReturn(msg); break; case (int)Cmd.eEditProfileRes: OnEditProfileReturn(msg); break; case (int)Cmd.eAccountUpgradeRes: OnGuestAccountUpgradeReturn(msg); break; case (int)Cmd.eUnameLoginRes: OnUnameLoginReturn(msg); break; case (int)Cmd.eLoginOutRes: OnUserLoginOutReturn(msg); break; } }
void on_auth_server_return(cmd_msg msg) { Debug.Log("------------------------------------------"); Debug.Log("recv_msg_type=> " + msg.ctype); switch (msg.ctype) { case (int)Cmd.eGuestLoginRes: this.handle_guest_login_res(msg); break; case (int)Cmd.eEditProfileRes: this.handle_edit_profile_res(msg); break; case (int)Cmd.eAccountUpgradeRes: this.handle_accout_upgrade_res(msg); break; case (int)Cmd.eUnameLoginRes: this.handle_uname_login_res(msg); break; case (int)Cmd.eLoginOutRes: this._handle_login_out_res(msg); break; default: Debug.Log("recv_msg not register call function===> ctype=> " + msg.ctype); break; } }
void handle_user_arrived(cmd_msg msg) { UserArrived res = proto_man.protobuf_deserialize <UserArrived>(msg.body); if (res == null) { return; } Debug.Log("user arrived " + res.unick + " " + res.uface + " " + res.usex); }
void handle_enter_match(cmd_msg msg) { EnterMatch res = proto_man.protobuf_deserialize <EnterMatch>(msg.body); if (res == null) { return; } Debug.Log("enter match: " + res.zid + " " + res.matchid); }
void handle_udp_test(cmd_msg msg) { UdpTest res = proto_man.protobuf_deserialize <UdpTest>(msg.body); if (res == null) { return; } Debug.Log("server return " + res.content); }
void handle_logic_frame(cmd_msg msg) { LogicFrame res = proto_man.protobuf_deserialize <LogicFrame>(msg.body); if (res == null) { return; } event_manager.Instance.dispatch_event(event_manager.EVT_LOGIC_FRAME_UPDATE, res); }
void on_guest_account_upgrade_return(cmd_msg msg) { AccountUpgradeRes res = proto_man.protobuf_deserialize <AccountUpgradeRes>(msg.body); if (res.status == Respones.OK) { ugame.Instance.is_guest = false; } event_manager.Instance.dispatch_event("upgrade_account_return", res.status); }
void handle_accout_upgrade_res(cmd_msg msg) { AccountUpgradeRes res = proto_man.protobuf_deserialize <AccountUpgradeRes>(msg.body); Debug.Log(res.status); if (res.status == Respones.OK) { ugames.Instance.is_guest = false; event_manager.Instance.dispatch_event(event_manager.EVT_ACCOUNT_UPGRADE, res); } }
//解码 public static bool unpack_cmd_msg(byte[] data, int start, int cmd_len, out cmd_msg msg) { msg = new cmd_msg(); msg.stype = data_viewer.read_ushort_len(data, start); msg.ctype = data_viewer.read_ushort_len(data, start + 2); int body_len = cmd_len - HEADER_SIZE; msg.body = new byte[body_len]; Array.Copy(data, start + HEADER_SIZE, msg.body, 0, body_len); return(true); }
private void OnUdpTest(cmd_msg msg) { UdpTest res = proto_man .protobuf_deserialize <UdpTest>(msg.body); if (res == null) { return; } Debug.Log("Server Udp Return " + res.content); }
private void on_udp_test(cmd_msg msg) { UdpTest res = proto_man.protobuf_deserialize <UdpTest>(msg.body); if (null == res) { return; } Debug.LogError("udp_test " + res.content); }
private void OnServerLogicFrame(cmd_msg msg) { LogicFrame res = proto_man .protobuf_deserialize <LogicFrame>(msg.body); if (res == null) { return; } //Debug.Log(res.frameid);//当前帧id,和当前玩家没有同步到的操作 EventManager.Instance.DispatchEvent("on_logic_update", res); }
private void on_server_logic_frame(cmd_msg msg) { LogicFrame res = proto_man.protobuf_deserialize <LogicFrame>(msg.body); if (res == null) { return; } //Debug.Log("当前玩家没有同步的操作" + res.cur_frameid); //当前帧,以及当前玩家没有同步的操作 event_manager.Instance.dispatch_event(logic_update, res); }
void handle_game_start_res(cmd_msg msg) { Debug.Log("game_start_res"); GameStart res = proto_man.protobuf_deserialize <GameStart>(msg.body); if (res == null) { return; } ugames.Instance.player_math_info = res.playerMathInfo; event_manager.Instance.dispatch_event(event_manager.EVT_GAME_START, null); }
void handle_user_arrived(cmd_msg msg) { UserArrived res = proto_man.protobuf_deserialize <UserArrived>(msg.body); if (res == null) { return; } Debug.Log("user arrived " + res.unick + " " + res.uface + " " + res.usex); ugames.Instance.other_users.Add(res); event_manager.Instance.dispatch_event(event_manager.EVT_USER_ARRIVIED_MATCH, res); }
private void OnUserArrivedReturn(cmd_msg msg) { UserArrived res = proto_man .protobuf_deserialize <UserArrived>(msg.body); if (res == null) { return; } Debug.Log(res.unick + " user arrived!"); UGame.Instance.otherUsers.Add(res); EventManager.Instance.DispatchEvent("user_arrived", res); }
void Update() { lock (net_events) { while (net_events.Count > 0) { cmd_msg msg = net_events.Dequeue(); if (event_listeners.ContainsKey(msg.stype)) { event_listeners[msg.stype](msg); } } } }
void handle_enter_zone_res(cmd_msg msg) { EnterZoneRes res = proto_man.protobuf_deserialize <EnterZoneRes>(msg.body); if (res == null) { return; } if (res.status != Respones.OK) { Debug.Log("enter zone status: " + res.status); return; } }
//本玩家进入比赛房间 private void on_user_arrived_return(cmd_msg msg) { UserArrived res = proto_man.protobuf_deserialize <UserArrived>(msg.body); if (null == res) { return; } event_manager.Instance.dispatch_event("user_arrived", res); Debug.Log(string.Format("enter match success unick = {0}, uface = {1}, usex = {2}", res.unick, res.uface, res.usex)); ugame.Instance.other_users.Add(res); }
void handle_enter_match(cmd_msg msg) { EnterMatch res = proto_man.protobuf_deserialize <EnterMatch>(msg.body); if (res == null) { return; } Debug.Log("enter match: " + res.zid + " " + res.matchid); ugames.Instance.zid = res.zid; ugames.Instance.matchid = res.matchid; ugames.Instance.self_seatid = res.seatid; ugames.Instance.self_side = res.side; }
private void on_login_out_return(cmd_msg msg) { LoginOutRes res = proto_man.protobuf_deserialize <LoginOutRes>(msg.body); if (res.status != Respones.OK) { Debug.LogError("Error to login out"); return; } ugame.Instance.user_login_out(); event_manager.Instance.dispatch_event("login_out"); }
private void Update() { lock (this.net_events) { while (this.net_events.Count > 0) { cmd_msg msg = this.net_events.Dequeue(); if (this.event_listeners.ContainsKey(msg.stype)) { this.event_listeners[msg.stype](msg); } } } }