//让某个服务器卸载玩家数据 private void UnloadData(ulong characterId, SceneInfo oldSceneInfo, Action <ServiceDesc> callback) { PlayerLog.WriteLog(888, "UnloadData characterId={0},ServerId={1},SceneId={2},SceneGuid={3}", characterId, oldSceneInfo.ServerId, oldSceneInfo.SceneId, oldSceneInfo.SceneGuid); ConnectLostLogger.Info("character {0} SceneBroker UnloadData 1", characterId); var content = new __RPC_Scene_UnloadData_ARG_uint64_characterId__(); content.CharacterId = characterId; var message = new ServiceDesc(); message.FuncId = 3020; message.ServiceType = (int)ServiceType.Scene; message.PacketId = GetUniquePacketId(); message.Data = ProtocolExtension.Serialize(content); message.Type = (int)MessageType.BS; message.CharacterId = characterId; Logger.Info("Notify Scene server UnloadData {0}", characterId); var act = new Action <bool, ServiceDesc>((b, item) => { PlayerLog.WriteLog(888, "UnloadData characterId={0},result={1},error={2}", characterId, b, item.Error); if (b) { if (item.Error == 0) { ConnectLostLogger.Info("character {0} SceneBroker UnloadData 3", characterId); Logger.Info("Scene server UnloadData replied {0}", characterId); callback(item); } else { ConnectLostLogger.Info("character {0} SceneBroker UnloadData 4", characterId); Logger.Error("UnloadData failed {0}....", item.Error); } } else { ConnectLostLogger.Info("character {0} SceneBroker UnloadData 5", characterId); Logger.Error("UnloadData timeout...."); } }); RegisterCallback(message.PacketId, act); ConnectLostLogger.Info("character {0} SceneBroker UnloadData 2", characterId); oldSceneInfo.Server.SendMessage(message); }
private void NotifyConnect(CharacterSceneInfo info, Action <ServiceDesc> callback) { ConnectLostLogger.Info("client {0} - {1} SceneBroker NotifyConnect 1", info.ClientId, info.CharacterId); Logger.Info("NotifyConnect {0}, {1}.", info.CharacterId, info.SceneInfo.Server.RemoteEndPoint); var desc = new ServiceDesc(); desc.Type = (int)MessageType.SS; desc.FuncId = 3501; desc.CharacterId = info.CharacterId; desc.ClientId = info.ClientId; desc.PacketId = GetUniquePacketId(); var content = new __RPC_Scene_SSNotifyCharacterOnConnet_ARG_uint64_clientId_uint64_characterId__(); content.CharacterId = info.CharacterId; content.ClientId = info.ClientId; desc.Data = ProtocolExtension.Serialize(content); var act = new Action <bool, ServiceDesc>((b, item) => { if (b) { if (item.Error == 0) { ConnectLostLogger.Info("client {0} - {1} SceneBroker NotifyConnect 3", info.ClientId, info.CharacterId); Logger.Info("Scene server Connected replied {0}", info.CharacterId); callback(item); } else { ConnectLostLogger.Error("client {0} - {1} SceneBroker NotifyConnect 4", info.ClientId, info.CharacterId); Logger.Error("NotifyConnect failed {0}....", item.Error); } } else { ConnectLostLogger.Error("client {0} - {1} SceneBroker NotifyConnect 5", info.ClientId, info.CharacterId); Logger.Error("NotifyConnect timeout...."); } }); ConnectLostLogger.Info("client {0} - {1} SceneBroker NotifyConnect 2", info.ClientId, info.CharacterId); RegisterCallback(desc.PacketId, act); info.SceneInfo.Server.SendMessage(desc); }