本文整理汇总了C#中System.IO.PacketReader类的典型用法代码示例。如果您正苦于以下问题:C# PacketReader类的具体用法?C# PacketReader怎么用?C# PacketReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketReader类属于System.IO命名空间,在下文中一共展示了PacketReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnCompressedGump
private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e)
{
p.MoveToData();
uint sender = p.ReadUInt32();
uint id = p.ReadUInt32();
if (id == responseID)
_responseSender = sender;
if (id != compressedID)
return;
p.Seek(19, SeekOrigin.Begin);
p.Seek(p.ReadInt32(), SeekOrigin.Current);
int lines = p.ReadInt32(), cLen = p.ReadInt32(), dLen = p.ReadInt32();
if (cLen < 5)
return;
byte[] buffer = new byte[dLen];
ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4);
string afk = string.Empty;
for (int i = 0, pos = 0; i < lines; i++)
{
int strLen = (buffer[pos++] << 8) | buffer[pos++];
string str = Encoding.BigEndianUnicode.GetString(buffer, pos, strLen * 2);
int index = str.IndexOf('>');
if (index != -1 && index < str.Length - 1)
afk += str[index + 1].ToString().ToUpper().Normalize(NormalizationForm.FormD)[0];
pos += strLen * 2;
}
afk = afk.Trim();
if (afk.Length == 5 && _responseSender != 0)
{
/*ClientCommunication.SendToClient(new CloseGump(responseID));
WorldEx.SendToServer(new GumpResponse(responseSender, responseID, 0x310, new int[0], new[] { new GumpTextEntry(0x310, afk) }));
responseSender = 0;*/
WorldEx.OverHeadMessage(afk);
}
}
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:35,代码来源:AFK.cs
示例2: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
if (context.User == null || context.Character == null)
return;
// Looks/Jobs
if (size > 0)
{
var reader = new PacketReader(data);
reader.BaseStream.Seek(0x38, SeekOrigin.Begin);
context.Character.Looks = reader.ReadStruct<Character.LooksParam>();
context.Character.Jobs = reader.ReadStruct<Character.JobParam>();
using(var db = new PolarisEf())
db.ChangeTracker.DetectChanges();
}
Map lobbyMap = ZoneManager.Instance.MapFromInstance("lobby", "lobby");
lobbyMap.SpawnClient(context, lobbyMap.GetDefaultLocation(), "lobby");
// Unlock Controls
context.SendPacket(new NoPayloadPacket(0x03, 0x2B));
//context.SendPacket(File.ReadAllBytes("testbed/237.23-7.210.189.208.30.bin"));
// Give a blank palette
context.SendPacket(new PalettePacket());
// memset packet - Enables menus
// Also holds event items and likely other stuff too
var memSetPacket = File.ReadAllBytes("Resources/setMemoryPacket.bin");
context.SendPacket(memSetPacket);
}
开发者ID:ChowZenki,项目名称:PolarisServer,代码行数:34,代码来源:CharacterSpawn.cs
示例3: GameClient
public GameClient(TcpClient selfClient, Guid onlineId, IClientKiller killer, ChatManager manager, GameLoop game)
{
_self = selfClient;
_self.NoDelay = true;
_self.Client.NoDelay = true;
_reader = new BinaryReader(_self.GetStream());
_writer = new BinaryWriter(_self.GetStream());
_clientKiller = killer;
_game = game;
ChatManager chatManager = manager;
chatManager.Join(this);
_auth = AuthorisationManager.Resolve();
_packetReader = PacketReader.Resolve<ServerPacketReader>();
_packetReader.InitialiseMapping();
OnlineId = onlineId;
_active = true;
_subs = new List<PacketSubscriber>
{
this,
_game,
chatManager
};
Task.Factory.StartNew(Receive);
}
开发者ID:aevv,项目名称:Biscuit,代码行数:28,代码来源:GameClient.cs
示例4: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
var reader = new PacketReader(data);
var id = reader.ReadInt32();
Logger.Write("[CHR] {0} is deleting character with ID {1}", context.User.Username, id);
// Delete Character
using (var db = new PolarisEf())
{
foreach (var character in db.Characters)
if (character.CharacterId == id)
{
db.Characters.Remove(character);
db.ChangeTracker.DetectChanges();
break;
}
// Detect the deletion and save the Database
if (db.ChangeTracker.HasChanges())
db.SaveChanges();
}
// Disconnect for now
// TODO: What do we do after a deletion?
context.Socket.Close();
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:28,代码来源:SimplePackets.cs
示例5: RicePacket
public RicePacket(RiceClient sender, ushort id, byte[] buffer)
{
Sender = sender;
Buffer = buffer;
ID = id;
Reader = new PacketReader(new MemoryStream(Buffer));
}
开发者ID:oxykidz,项目名称:RiceEmu,代码行数:7,代码来源:RicePacket.cs
示例6: Runtime
//private readonly ILog _logger = LogManager.GetLogger("Runtime");
/// <summary>
/// Create the Runtime object to combine all the various components of the livetiming.
/// </summary>
/// <param name="liveStream">A stream used to represent the incoming data of the live stream.</param>
/// <param name="authKeyService">Provider for authorization key requests.</param>
/// <param name="keyFrameService">Provider for keyframes.</param>
/// <param name="messageDispatch">A receiver for messages.</param>
public Runtime(Stream liveStream, IAuthKey authKeyService, IKeyFrame keyFrameService, IMessageDispatch messageDispatch)
{
_decryptor = new DataDecryptor();
_packetReader = new PacketReader(liveStream, new DecryptStreamDecorator(liveStream, _decryptor));
_messageDispatch = messageDispatch;
_authKeyService = authKeyService;
_keyFrameService = keyFrameService;
}
开发者ID:visual14ph,项目名称:f1livetiming,代码行数:16,代码来源:Runtime.cs
示例7: OnServerStop
private static void OnServerStop(Client client, PacketReader reader)
{
MessageBox.Show("服务器关闭");
try
{
client.Close(true);
}
catch { }
client.ServerStop();
}
开发者ID:247321453,项目名称:YgoServer,代码行数:10,代码来源:ClientEvent.cs
示例8: Connection
private Connection(string server, int port)
{
_port = port;
_server = server;
_packetReader = PacketReader.Resolve<ClientPacketReader>();
_packetReader.InitialiseMapping();
_subs = new List<PacketSubscriber>();
AddSubscriber(this);
}
开发者ID:aevv,项目名称:Biscuit,代码行数:10,代码来源:Connection.cs
示例9: ProcessPacket
public static void ProcessPacket( byte[] data )
{
PacketHandler call = m_Table[data[0]] as PacketHandler;
if ( call != null )
{
PacketReader pvSrc = new PacketReader( data, RPVEditor.PacketInfo.IsDyn( data[0] ) );
pvSrc.MoveToData();
call( pvSrc );
}
}
开发者ID:herculesjr,项目名称:razor,代码行数:11,代码来源:Handlers.cs
示例10: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
if (context.Character == null)
return;
var reader = new PacketReader(data, position, size);
reader.BaseStream.Seek(0xC, SeekOrigin.Begin);
var channel = reader.ReadUInt32();
var message = reader.ReadUtf16(0x9D3F, 0x44);
if (message.StartsWith(PolarisApp.Config.CommandPrefix))
{
var valid = false;
// Iterate commands
foreach (var command in PolarisApp.ConsoleSystem.Commands)
{
var full = message.Substring(1); // Strip the command chars
var args = full.Split(' ');
if (command.Names.Any(name => args[0].ToLower() == name.ToLower()))
{
command.Run(args, args.Length, full, context);
valid = true;
Logger.WriteCommand(null, "[CMD] {0} issued command {1}", context.User.Username, full);
}
if (valid)
break;
}
if (!valid)
Logger.WriteClient(context, "[CMD] {0} - Command not found", message.Split(' ')[0].Trim('\r'));
}
else
{
Logger.Write("[CHT] <{0}> <{1}>", context.Character.Name, message);
var writer = new PacketWriter();
writer.WritePlayerHeader((uint) context.User.PlayerId);
writer.Write(channel);
writer.WriteUtf16(message, 0x9D3F, 0x44);
data = writer.ToArray();
foreach (var c in Server.Instance.Clients)
{
if (c.Character == null || c.CurrentZone != context.CurrentZone)
continue;
c.SendPacket(0x07, 0x00, 0x44, data);
}
}
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:54,代码来源:ChatHandler.cs
示例11: OnServerInfo
private static void OnServerInfo(Client client, PacketReader reader){
//服务器信息
Program.Config.ChatPort = reader.ReadInt32();
Program.Config.DuelPort = reader.ReadInt32();
Program.Config.NeedAuth = reader.ReadBoolean();
client.Pwd = reader.ReadUnicode(32);
#if DEBUG
MessageBox.Show(Program.Config.ChatPort+":"+Program.Config.DuelPort+":"+Program.Config.NeedAuth + ":" + client.Pwd);
#endif
client.OnLoginOk();
}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:ClientEvent.cs
示例12: OnError
private static void OnError(Client client, PacketReader reader){
//错误
string err = reader.ReadUnicode(256);
// int code = reader.ReadByte();
MessageBox.Show(err);
//if(!client.IsLogin){
try{
client.Close(client.IsLogin);
}catch{}
//}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:ClientEvent.cs
示例13: ClientDoubleClick
private static void ClientDoubleClick(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
if (items.ContainsKey(serial))
{
args.Block = true;
WorldEx.SendToServer(new DoubleClick(items[serial].List.Last()));
}
else
args.Block = PacketHandler.ProcessViewers(clientDoubleClick, p);
}
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:11,代码来源:PotionStack.cs
示例14: OnCompressedGump
private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e)
{
p.Seek(7, SeekOrigin.Begin);
if (p.ReadUInt32() != 0x1105B263)
return;
p.Seek(19, SeekOrigin.Begin);
p.Seek(p.ReadInt32() + 4, SeekOrigin.Current);
int cLen = p.ReadInt32(), dLen = p.ReadInt32();
byte[] buffer = new byte[dLen];
ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4);
int strLen = (buffer[0] << 8) | buffer[1];
string[] str = Encoding.BigEndianUnicode.GetString(buffer, 2, strLen * 2).Split(',');
string[] lat = str[0].Split('°');
int yLat = int.Parse(lat[0]);
int yMins = int.Parse(lat[1].Split('\'')[0]);
bool ySouth = lat[1][lat[1].Length - 1] == 'S';
string[] lon = str[1].Split('°');
int xLong = int.Parse(lon[0]);
int xMins = int.Parse(lon[1].Split('\'')[0]);
bool xEast = lon[1][lon[1].Length - 1] == 'E';
const int xWidth = 5120;
const int yHeight = 4096;
const int xCenter = 1323;
const int yCenter = 1624;
double absLong = xLong + ((double)xMins / 60);
double absLat = yLat + ((double)yMins / 60);
if (!xEast)
absLong = 360.0 - absLong;
if (!ySouth)
absLat = 360.0 - absLat;
int x = xCenter + (int)((absLong * xWidth) / 360);
int y = yCenter + (int)((absLat * yHeight) / 360);
if (x < 0)
x += xWidth;
else if (x >= xWidth)
x -= xWidth;
if (y < 0)
y += yHeight;
else if (y >= yHeight)
y -= yHeight;
onGump(x, y);
}
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:53,代码来源:SOS.cs
示例15: OnRoomStart
private static void OnRoomStart(DuelServer server, PacketReader packet){
string name = packet.ReadUnicode(20);
Logger.Debug("OnRoomStart:"+server.Port+","+name);
lock(server.Rooms){
GameConfig cfg = null;
if(server.Rooms.TryGetValue(name, out cfg)){
cfg.IsStart = true;
}else{
Logger.Warn("no start room:"+name+" form "+server.Port);
}
}
if(server.Server!=null)
server.Server.server_OnRoomStart(server, name);
}
开发者ID:247321453,项目名称:YgoServer,代码行数:14,代码来源:ServerEvent.cs
示例16: OnHuedEffect
private static void OnHuedEffect(PacketReader p, PacketHandlerEventArgs args)
{
byte type = p.ReadByte();
Serial src = p.ReadUInt32();
Serial dest = p.ReadUInt32();
ItemID itemID = p.ReadUInt16();
p.Seek(10, SeekOrigin.Current);
byte speed = p.ReadByte();
byte count = p.ReadByte();
p.ReadUInt32();
uint hue = p.ReadUInt32();
uint mode = p.ReadUInt32();
Handle(huedEffect, args, type, src, dest, itemID, speed, count, hue, mode);
}
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:14,代码来源:Event.Others.cs
示例17: ReadPacket
public void ReadPacket(PacketReader reader)
{
FailureReason = (LoginFailureReason)reader.ReadInt32();
var fingerprintJson = reader.ReadString();
if (fingerprintJson != null)
Fingerprint = new Fingerprint(fingerprintJson);
HostName = reader.ReadString();
AssetsRootUrl = reader.ReadString();
iTunesUrl = reader.ReadString();
Unknown1 = reader.ReadString();
RemainingTime = reader.ReadInt32();
Unknown2 = reader.ReadByte();
CompressedFingerprintJson = reader.ReadByteArray();
Unknown3 = reader.ReadString();
Unknown4 = reader.ReadString();
}
开发者ID:maithanhtan,项目名称:CoCSharp,代码行数:16,代码来源:LoginFailedPacket.cs
示例18: GetConsumerPacketHeaderTestMethod
public void GetConsumerPacketHeaderTestMethod()
{
using (MemoryStream _stream = new MemoryStream(new ArraySegment<byte>(CommonDefinitions.GetTestBinaryArrayVariant(), 0, 27).ToArray<byte>()))
using (PacketReader _reader = new PacketReader(_stream))
{
PacketHeader _header = PacketHeader.GetConsumerPacketHeader(_reader);
Assert.IsNotNull(_header);
Assert.AreEqual<Guid>(CommonDefinitions.TestGuid, _header.PublisherId);
Assert.AreEqual<Byte>(110, _header.ProtocolVersion);
Assert.AreEqual<Byte>(0, _header.NetworkMessageFlags);
Assert.AreEqual<UInt32>(0, _header.SecurityTokenId);
Assert.AreEqual<Byte>(1, _header.NonceLength);
CollectionAssert.AreEqual(new byte[] { 0xcc }, _header.Nonce);
Assert.AreEqual<Byte>(1, _header.MessageCount);
CollectionAssert.AreEqual(new UInt16[] { CommonDefinitions.DataSetId }, _header.DataSetWriterIds);
}
}
开发者ID:yuriik83,项目名称:OPC-UA-OOI,代码行数:17,代码来源:PacketHeaderUnitTest.cs
示例19: MultiplayerClient
public MultiplayerClient(TrueCraftUser user)
{
User = user;
Client = new TcpClient();
PacketReader = new PacketReader();
PacketReader.RegisterCorePackets();
PacketHandlers = new PacketHandler[0x100];
Handlers.PacketHandlers.RegisterHandlers(this);
World = new ReadOnlyWorld();
var repo = new BlockRepository();
repo.DiscoverBlockProviders();
World.World.BlockRepository = repo;
World.World.ChunkProvider = new EmptyGenerator();
Physics = new PhysicsEngine(World, repo);
SocketPool = new SocketAsyncEventArgsPool(100, 200, 65536);
connected = 0;
cancel = new CancellationTokenSource();
}
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:18,代码来源:MultiplayerClient.cs
示例20: ReadPacket
public void ReadPacket(PacketReader reader)
{
//TODO: Make
var offset = 0x2A;
File.WriteAllBytes("AvatarProfileResponsePacket dump", ((MemoryStream)reader.BaseStream).ToArray());
Unknown1 = reader.ReadInt32();
UserID1 = reader.ReadInt64();
UserID2 = reader.ReadInt64();
if (reader.ReadBoolean())
{
Clan = new Clan();
Clan.ID = reader.ReadInt64();
Clan.Name = reader.ReadString();
Clan.Badge = reader.ReadInt32();
reader.ReadInt32();
Clan.Level = reader.ReadInt32();
offset += 1;
}
if (Unknown2 = reader.ReadBoolean())
{
Unknown3 = reader.ReadInt64();
offset += 1;
}
reader.Seek(offset, SeekOrigin.Current);
Unknown4 = reader.ReadInt32();
AllianceCastleLevel = reader.ReadInt32(); // -1 if not constructed
AllianceCastleUnitCapacity = reader.ReadInt32();
AllianceCastleUnitCount = reader.ReadInt32();
TownHallLevel = reader.ReadInt32();
Username = reader.ReadString();
FacebookID = reader.ReadString();
Level = reader.ReadInt32();
Experience = reader.ReadInt32();
Gems = reader.ReadInt32(); // they seemed randomized or scrambled for non local player
Gems1 = reader.ReadInt32();
Unknown5 = reader.ReadInt32();
Unknown6 = reader.ReadInt32();
Trophies = reader.ReadInt32();
AttackWon = reader.ReadInt32();
AttackLost = reader.ReadInt32(); // randomized
DefenseWon = reader.ReadInt32();
DefenseLost = reader.ReadInt32(); // randomized
}
开发者ID:maithanhtan,项目名称:CoCSharp,代码行数:44,代码来源:AvatarProfileResponsePacket.cs
注:本文中的System.IO.PacketReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论