using System; using System.Collections.Generic; using ProtoCSStruct; using Sog; namespace Friend { public class CallBackFuncParam { public Func 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> m_callBackStruct = new Dictionary>(); // 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 list = new List(); // list.Add(callBack); // m_callBackStruct.Add(fromUid, list); // } // return true; //} public static void OnPlayerQueryOtherRoleInfoRes(uint serverId, StructPacket packet) { ref CSPlayerQueryOtherRoleInfoRes res = ref packet.GetMessage(); if (m_callBackStruct.ContainsKey(res.FromUid)) { foreach (var callbackList in m_callBackStruct[res.FromUid]) { callbackList.CallBack(ref res); } m_callBackStruct.Remove(res.FromUid); } } } }