/// <summary> /// 消息回调监听 /// </summary> /// <param name="cmdId">消息ID</param> /// <param name="param1">参数1</param> /// <param name="param2">参数2</param> public void OnReceiveData(uint cmdId, object param1, object param2) { Debug.Log("消息监听1:" + cmdId); switch (cmdId) { case NetMessageDef.ResGetTopList: listinfo.Clear(); protos.integral.ResGetTopList list = param1 as protos.integral.ResGetTopList; foreach (protos.integral.TopInfo info in list.topInfo) { listinfo.Add(info); } ShowRanking(); break; } }
public void OnReceiveData(uint cmdId, object param1, object param2) { if (cmdId == NetMessageDef.ResLogin) { protos.Login.ResLogin info = param1 as protos.Login.ResLogin; Debug.Log("结果类型:" + info.results); Debug.Log("结果细节:" + info.details); //protos.friend.ReqGetFriendList getFriendList = new protos.friend.ReqGetFriendList(); //getFriendList.feiendId = 1; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGetFriendList, getFriendList)); //protos.friend.ReqGiveVigor giveVigor = new protos.friend.ReqGiveVigor(); //giveVigor.feiendId = 2; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGiveVigor, giveVigor)); //protos.friend.ReqAddFriend addFriend = new protos.friend.ReqAddFriend(); //addFriend.feiendId = 2; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqAddFriend, addFriend)); //protos.friend.ReqDeleteFriend addFriend = new protos.friend.ReqDeleteFriend(); //addFriend.feiendId = 2; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqDeleteFriend, addFriend)); //protos.friend.ReqFindFriend addFriend = new protos.friend.ReqFindFriend(); //addFriend.name = "王"; //addFriend.page = 1; //addFriend.pageSize = 10; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqFindFriend, addFriend)); //protos.integral.ReqAddIntegral addIntegral = new protos.integral.ReqAddIntegral(); //addIntegral.userId = 1; //addIntegral.integral = 10; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqAddIntegral, addIntegral)); protos.integral.ReqGetTopList getTopList = new protos.integral.ReqGetTopList(); getTopList.topNums = 10; GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGetTopList, getTopList)); } else if (cmdId == NetMessageDef.ResFriendList) { protos.friend.ResFriendList list = param1 as protos.friend.ResFriendList; //protos.friend.UserInfo foreach (protos.friend.UserInfo info in list.userInfo) { Debug.Log(string.Format("name={0} lv={1} id={2}", info.name, info.lv, info.uid)); } Debug.Log("好友个数:" + list.userInfo.Count); } else if (cmdId == NetMessageDef.ResReturnDefaultInfo) { protos.ReturnMessage.ResDefaultInfo info = param1 as protos.ReturnMessage.ResDefaultInfo; Debug.Log("结果:" + info.results); Debug.Log("细节:" + info.details); } else if (cmdId == NetMessageDef.ResFindFriendList) { protos.friend.ResFindFriendList list = param1 as protos.friend.ResFindFriendList; foreach (protos.friend.UserInfo info in list.userInfo) { Debug.Log(string.Format("name={0} lv={1} id={2}", info.name, info.lv, info.uid)); } Debug.Log("符合条件用户个数:" + list.userInfo.Count); } else if (cmdId == NetMessageDef.ResGetTopList) { protos.integral.ResGetTopList list = param1 as protos.integral.ResGetTopList; foreach (protos.integral.TopInfo info in list.topInfo) { Debug.Log(string.Format("name={0} lv={1} id={2} integral={3}", info.name, info.lv, info.uid, info.integral)); } Debug.Log("排行榜用户个数:" + list.topInfo.Count); } }