本文整理汇总了C#中GameClient.SetFsm方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.SetFsm方法的具体用法?C# GameClient.SetFsm怎么用?C# GameClient.SetFsm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameClient
的用法示例。
在下文中一共展示了GameClient.SetFsm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
try
{
GSPacketIn pkg = new GSPacketIn((byte)ePackageType.LOGIN);
pkg.ClientID = packet.ClientID;
if (client.Player == null)
{
int version = packet.ReadInt();
int clientType = packet.ReadInt();
byte[] src = packet.ReadBytes();
//解密
try
{
src = WorldMgr.RsaCryptor.Decrypt(src, false);
}
catch (ExecutionEngineException e)
{
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
client.Disconnect();
GameServer.log.Error("ExecutionEngineException", e);
return 0;
}
catch (Exception ex)
{
//防止攻击,如果解密出错,直接断开连接
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
client.Disconnect();
GameServer.log.Error("RsaCryptor", ex);
return 0;
}
//DateTime date = new DateTime(src[0] * 256 + src[1], src[2], src[3], src[4], src[5], src[6]);
int fms_key = (src[7] << 8) + src[8];
client.SetFsm(fms_key, version);
//string edition = GameServer.Instance.Configuration.Edition;
string edition = GameServer.Edition;
//if (version.ToString() != edition && edition != "0")
//{
// client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
// //client.Out.SendEditionError(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
// client.Disconnect();
// return 0;
//}
string[] temp = Encoding.UTF8.GetString(src, 9, src.Length - 9).Split(',');
if (temp.Length == 2)
{
string user = temp[0];
string pass = temp[1];
//TimeSpan span = date - DateTime.UtcNow;
//if (Math.Abs(span.TotalMinutes) < 5)
//{
if (!LoginMgr.ContainsUser(user))
{
bool isFirst = false;
BaseInterface inter = BaseInterface.CreateInterface();
PlayerInfo cha = inter.LoginGame(user, pass, ref isFirst);
if (cha != null && cha.ID != 0)
{
if (cha.ID == -2)
{
//帐号被禁用
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid"));
client.Disconnect();
return 0;
}
if (!isFirst)
{
client.Player = new GamePlayer(cha.ID, user, client, cha);
LoginMgr.Add(cha.ID, client);
client.Server.LoginServer.SendAllowUserLogin(cha.ID);
client.Out.SendLoginSuccess2();
client.Version = version;
}
else
{
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register"));
client.Disconnect();
}
}
else
{
//client.Out.SendLoginFailed("用户名密码错误");
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime"));
client.Disconnect();
}
}
else
{
//避免攻击,有另外的客户端在登陆,则断掉次客户端。
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError"));
client.Disconnect();
}
}
else
{
//.........这里部分代码省略.........