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.
70 lines
1.6 KiB
70 lines
1.6 KiB
/*
|
|
Sog 游戏基础库
|
|
2016 by zouwei
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
|
|
namespace Account
|
|
{
|
|
public class PlayerTableOp : BaseReloadableService
|
|
{
|
|
//数据表,需要外部传入,保证reload不出问题
|
|
|
|
private PlayerTable m_table;
|
|
|
|
public override int GetServiceType()
|
|
{
|
|
return AccountServiceType.PlayerTableOp;
|
|
}
|
|
|
|
//销毁的时候置空
|
|
public override void Dispose()
|
|
{
|
|
m_table = null;
|
|
}
|
|
|
|
//构造的时候外部传入table对象
|
|
public PlayerTableOp(PlayerTable table)
|
|
{
|
|
m_table = table;
|
|
}
|
|
|
|
|
|
public PlayerSession GetPlayerSession(long sessionID)
|
|
{
|
|
PlayerSession session;
|
|
m_table.m_sessionsTable.TryGetValue(sessionID, out session);
|
|
|
|
return session;
|
|
}
|
|
|
|
//不允许重复添加
|
|
public void AddPlayerSession(long sessionID, PlayerSession playerSession)
|
|
{
|
|
if (m_table.m_sessionsTable.ContainsKey(sessionID))
|
|
{
|
|
TraceLog.Error("player session {0} already exist, add failed,please remove it first!", sessionID);
|
|
return;
|
|
}
|
|
|
|
m_table.m_sessionsTable.Add(sessionID, playerSession);
|
|
}
|
|
|
|
public void RemoveSession(long sessionID)
|
|
{
|
|
TraceLog.Trace("delete player session {0} ", sessionID);
|
|
|
|
if (m_table.m_sessionsTable.ContainsKey(sessionID))
|
|
{
|
|
m_table.m_sessionsTable.Remove(sessionID);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|