Description: The Seek method in the PacketReader class of C# Server.Network helps to set the pointer at a specific position in the packet buffer.
Code Example 1:
byte[] packet = { 0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F }; PacketReader pr = new PacketReader(packet); pr.Seek(2); byte b = pr.ReadByte(); // b = 0x3C
In this example, we create a byte array representing a packet and initialize the PacketReader with it. We then use the Seek method to set the pointer at position 2 in the packet buffer. Finally, we use the ReadByte method to read a byte from the packet buffer at the current pointer position and store it in the b variable.
Package library: Server.Network
Code Example 2:
MemoryStream buffer = new MemoryStream(); BinaryWriter bw = new BinaryWriter(buffer); bw.Write("Hello, world!"); PacketWriter pw = new PacketWriter(); pw.Write(buffer.ToArray()); PacketReader pr = new PacketReader(pw.ToArray()); pr.Seek(6); string s = pr.ReadString(); // s = "world!"
In this example, we create a MemoryStream and write a string to it using the BinaryWriter. We then initialize a PacketWriter and write the byte array representation of the MemoryStream to it. We then initialize a PacketReader with the byte array representation of the PacketWriter, use the Seek method to set the pointer at position 6 in the packet buffer, and read a string from the packet buffer at the current pointer position using the ReadString method and store it in the s variable.
Package library: Server.Network
C# (CSharp) Server.Network PacketReader.Seek - 30 examples found. These are the top rated real world C# (CSharp) examples of Server.Network.PacketReader.Seek extracted from open source projects. You can rate examples to help us improve the quality of examples.