本文整理汇总了C#中Game.Base.Packets.GSPacketIn.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# GSPacketIn.ReadBytes方法的具体用法?C# GSPacketIn.ReadBytes怎么用?C# GSPacketIn.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Base.Packets.GSPacketIn
的用法示例。
在下文中一共展示了GSPacketIn.ReadBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRSAKey
protected void HandleRSAKey(GSPacketIn packet)
{
RSAParameters para = new RSAParameters();
para.Modulus = packet.ReadBytes(128);
para.Exponent = packet.ReadBytes();
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.ImportParameters(para);
SendRSALogin(rsa, _loginKey);
}
示例2: HandleLogin
/// <summary>
/// 战斗服务器登陆
/// </summary>
/// <param name="pkg"></param>
public void HandleLogin(GSPacketIn pkg)
{
byte[] rgb = pkg.ReadBytes();
string[] temp = Encoding.UTF8.GetString(_rsa.Decrypt(rgb, false)).Split(',');
if (temp.Length == 2)
{
_rsa = null;
int id = int.Parse(temp[0]);
//Info = ServerMgr.GetServerInfo(id);
Strict = false;
}
else
{
log.ErrorFormat("Error Login Packet from {0}", TcpEndpoint);
Disconnect();
}
}
示例3: HandleRSAKey
protected void HandleRSAKey(GSPacketIn packet)
{
RSAParameters para = new RSAParameters();
// packet.ReadBytes(2);
para.Modulus = packet.ReadBytes(128);
para.Exponent = packet.ReadBytes();
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.ImportParameters(para);
SendRSALogin(rsa, m_loginKey);
SendListenIPPort(IPAddress.Parse(GameServer.Instance.Configuration.Ip), GameServer.Instance.Configuration.Port);
}
示例4: 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();
//.........这里部分代码省略.........