87 lines
2.1 KiB
C#
87 lines
2.1 KiB
C#
using Nettention.Proud;
|
|
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCommon.BusinessLogDomain;
|
|
using MetaAssets;
|
|
|
|
|
|
using SESSION_ID = System.Int32;
|
|
|
|
|
|
|
|
namespace GameServer;
|
|
|
|
|
|
public class BattleFFAModeHostMigrator : IHostMigrator
|
|
{
|
|
private string m_host_user_guid = string.Empty;
|
|
|
|
public Result defineHost(HostID p2pGroupId, SuperPeerSelectionPolicy policy, HostID[] excludes)
|
|
{
|
|
var pround_net_listener = GameServerApp.getServerLogic().getProudNetListener();
|
|
var net_server = pround_net_listener.getNetServer();
|
|
|
|
var host_id = net_server.GetMostSuitableSuperPeerInGroup(p2pGroupId, policy, excludes);
|
|
//net_server.GetClientInfo(host_id);
|
|
|
|
string err_msg = string.Empty;
|
|
var result = new Result();
|
|
|
|
if (host_id == 0)
|
|
{
|
|
err_msg = $"there is not suitable super peer !!!! host_id : {host_id}";
|
|
result.setFail(ServerErrorCode.NotFoundUser, err_msg);
|
|
return result;
|
|
}
|
|
|
|
var session = pround_net_listener.onLookupEntityWithSession((SESSION_ID)host_id);
|
|
if (session is null)
|
|
{
|
|
err_msg = $"session is null!!!! host_id : {host_id}";
|
|
result.setFail(ServerErrorCode.NotFoundUser, err_msg);
|
|
return result;
|
|
}
|
|
var player = session as Player;
|
|
if (player is null)
|
|
{
|
|
err_msg = $"player is null!!!! host_id : {host_id}";
|
|
result.setFail(ServerErrorCode.NotFoundUser, err_msg);
|
|
return result;
|
|
}
|
|
|
|
m_host_user_guid = player.getUserGuid();
|
|
return result;
|
|
}
|
|
|
|
public Result modifyHost(string userGuid)
|
|
{
|
|
m_host_user_guid = userGuid;
|
|
return new Result();
|
|
}
|
|
|
|
public Result removeHost()
|
|
{
|
|
m_host_user_guid = string.Empty;
|
|
return new Result();
|
|
}
|
|
|
|
public string getHostUserGuid()
|
|
{
|
|
return m_host_user_guid;
|
|
}
|
|
|
|
public (Result, bool) migrateCheck(bool ignoreInterval)
|
|
{
|
|
return (new Result(), false);
|
|
}
|
|
|
|
public void setGroupHostId(HostID groupId)
|
|
{
|
|
}
|
|
}
|