You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
1 month ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using ProtoCSStruct;
|
||
|
using Sog;
|
||
|
|
||
|
namespace Friend
|
||
|
{
|
||
|
|
||
|
public class CallBackFuncParam
|
||
|
{
|
||
|
public Func<long, object, CSPlayerQueryOtherRoleInfoRes, int> callBackFunc;
|
||
|
public long fromuid;
|
||
|
public object param1;
|
||
|
|
||
|
public void CallBack(ref CSPlayerQueryOtherRoleInfoRes res)
|
||
|
{
|
||
|
callBackFunc?.Invoke(fromuid, param1, res);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static class QueryPlayerAndCallBack
|
||
|
{
|
||
|
private static Dictionary<long, List<CallBackFuncParam>> m_callBackStruct = new Dictionary<long, List<CallBackFuncParam>>();
|
||
|
|
||
|
// friend现在直连game, 不连world了
|
||
|
//public static bool QueryPlayerInfo(long fromUid, long targetUid, QueryRoleType queryType, CallBackFuncParam callBack)
|
||
|
//{
|
||
|
// CSPlayerQueryOtherRoleInfoReq req = new CSPlayerQueryOtherRoleInfoReq();
|
||
|
// req.TargetUid = targetUid;
|
||
|
// req.Type = queryType;
|
||
|
|
||
|
// if (m_callBackStruct.ContainsKey(fromUid))
|
||
|
// {
|
||
|
// m_callBackStruct[fromUid].Add(callBack);
|
||
|
|
||
|
// FriendServerUtils.GetPacketSender().SendToWorldServer((int)CSGameMsgID.PlayerQueryOtherRoleInfoReq, ref req, fromUid);
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// List<CallBackFuncParam> list = new List<CallBackFuncParam>();
|
||
|
// list.Add(callBack);
|
||
|
// m_callBackStruct.Add(fromUid, list);
|
||
|
// }
|
||
|
// return true;
|
||
|
//}
|
||
|
|
||
|
public static void OnPlayerQueryOtherRoleInfoRes(uint serverId, StructPacket packet)
|
||
|
{
|
||
|
ref CSPlayerQueryOtherRoleInfoRes res = ref packet.GetMessage<CSPlayerQueryOtherRoleInfoRes>();
|
||
|
if (m_callBackStruct.ContainsKey(res.FromUid))
|
||
|
{
|
||
|
foreach (var callbackList in m_callBackStruct[res.FromUid])
|
||
|
{
|
||
|
callbackList.CallBack(ref res);
|
||
|
}
|
||
|
m_callBackStruct.Remove(res.FromUid);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|