本文整理汇总了C#中GameClient.setKey方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.setKey方法的具体用法?C# GameClient.setKey怎么用?C# GameClient.setKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameClient
的用法示例。
在下文中一共展示了GameClient.setKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacket
//修改: Xiaov
//时间: 2009-11-9
//描述: 登陆请求
public int HandlePacket(GameClient client, GSPacketIn packet)
{
try
{
GSPacketIn pkg = packet.Clone();
pkg.ClearContext();
if (client.Player == null)
{
int version = packet.ReadInt();
int clientType = packet.ReadInt();
byte[] tempKey = new byte[8];
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;
//}
for (int i = 0; i < 8; i++)
{
tempKey[i] = src[i+7];
}
client.setKey(tempKey);
string[] temp = Encoding.UTF8.GetString(src, 15, src.Length - 15).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.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();
//.........这里部分代码省略.........