本文整理汇总了C#中PacketReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Read方法的具体用法?C# PacketReader.Read怎么用?C# PacketReader.Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequestProposal
public static void ProcessRequestProposal(Client client, PacketReader packetReader)
{
var uid = packetReader.ReadMuid();
var mode = packetReader.ReadInt32();
var request = packetReader.ReadInt32();
var memberCount = packetReader.ReadInt32();
var totalSize = packetReader.ReadInt32();
var blobSize = packetReader.ReadInt32();
var blobCount = packetReader.ReadInt32();
List<byte[]> blob = new List<byte[]>();
if (memberCount == blobCount)
{
for (int i = 0; i < blobCount; ++i)
{
var temp = new byte[blobSize];
packetReader.Read(temp, 0, blobSize);
blob.Add(temp);
}
}
else
{
client.Disconnect();
return;
}
List<Client> requests = new List<Client>();
foreach (byte[] b in blob)
{
string s = System.Text.ASCIIEncoding.ASCII.GetString(b);
s = s.Substring(0, s.IndexOf('\0'));
requests.Add(TcpServer.GetClientFromName(s));
}
if (requests.FindAll(c => c.GetCharacter().ClanId == client.GetCharacter().ClanId).Count == memberCount)
{
List<Pair<Client, bool>> list = new List<Pair<Client, bool>>();
foreach (Client c in requests)
{
list.Add(new Pair<Client, bool>(c, false));
}
list.Add(new Pair<Client, bool>(client, true));
ClanPackets.AskAgreement(requests, client, mode, request);
ClanPackets.ResponseProposal(client, 0, mode, request);
PendingClanWarRequest pc = new PendingClanWarRequest();
pc.RequestId = request;
pc.Players = list;
pc.ClanName = client.GetCharacter().ClanName;
pc.Requester = client;
pc.RequestMode = mode;
lock(Globals.PendingClanWar)
Globals.PendingClanWar.Add(pc);
var responsetimer = new Timer(30000);
responsetimer.Elapsed += (s, o) => CancelClanWarRequest(client, pc, responsetimer);
responsetimer.Start();
}
}
示例2: ReadPacket
public void ReadPacket(PacketReader reader)
{
DecryptedData = new byte[Length];
reader.Read(DecryptedData, 0, Length);
}
示例3: ProcessLoginRequest
public static void ProcessLoginRequest(Client client, PacketReader packetReader)
{
var user = packetReader.ReadString();
var pass = packetReader.ReadString();
var version = packetReader.ReadInt32();
var checksum = packetReader.ReadInt32();
var totalSize = packetReader.ReadInt32();
var blobSize = packetReader.ReadInt32();
var blobCount = packetReader.ReadInt32();
var md5 = new byte[blobSize*blobCount];
packetReader.Read(md5, 0, blobSize);
if (blobSize > 32)
{
client.Disconnect();
return;
}
if (!Globals.AcceptedString.IsMatch(user) || !Globals.AcceptedString.IsMatch(pass))
{
Match.ResponseLogin(client, Results.LoginAuthenticationFailed, user, UGradeId.Guest, PGradeId.Free, new Muid(0,0));
client.Disconnect();
return;
}
if (Globals.Config.Server.AutoRegistration)
{
if (user.StartsWith("!r"))
{
user = user.Substring(2);
if (!Globals.GunzDatabase.AccountExists(user))
Globals.GunzDatabase.CreateAccount(user, pass, ref client.ClientPlayer.PlayerAccount);
else
{
Match.ResponseNotify(client, "That account is already in use!", 1);
client.Disconnect();
return;
}
}
else
Globals.GunzDatabase.GetAccount(user, pass, ref client.ClientPlayer.PlayerAccount);
}
else
Globals.GunzDatabase.GetAccount(user, pass, ref client.ClientPlayer.PlayerAccount);
if (client.ClientPlayer.PlayerAccount.AccountId == 0)
{
Match.ResponseLogin(client, Results.LoginIncorrectPassword, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
client.Disconnect();
return;
}
if (client.ClientPlayer.PlayerAccount.Access == UGradeId.Banned || client.ClientPlayer.PlayerAccount.Access == UGradeId.Criminal)
{
Match.ResponseLogin(client, Results.LoginBannedId, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
client.Disconnect();
return;
}
if (version != Globals.Config.Client.Version)
{
Match.ResponseLogin(client, Results.LoginInvalidVersion, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
return;
}
if (Globals.Config.Client.UseCrc)
{
if ((checksum^0) != Globals.Config.Client.FileList)
{
Match.ResponseLogin(client, Results.LoginInvalidVersion, user, UGradeId.Guest, PGradeId.Free, new Muid(0, 0));
client.Disconnect();
return;
}
}
var inuse = TcpServer.GetClientFromAid(client.ClientPlayer.PlayerAccount.AccountId);
if (inuse != null && inuse != client)
{
inuse.Disconnect();
}
client.ClientFlags = PacketFlags.Login;
Match.ResponseLogin(client, Results.Accepted, user, client.ClientPlayer.PlayerAccount.Access, PGradeId.Free, client.GetMuid());
}