first commit
This commit is contained in:
35
Yapper/Net/IO/PacketBuilder.cs
Normal file
35
Yapper/Net/IO/PacketBuilder.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace YapperClient.Net.IO
|
||||
{
|
||||
class PacketBuilder
|
||||
{
|
||||
MemoryStream _ms;
|
||||
public PacketBuilder()
|
||||
{
|
||||
_ms = new MemoryStream();
|
||||
}
|
||||
|
||||
public void WriteOpCode(byte opcode)
|
||||
{
|
||||
_ms.WriteByte(opcode);
|
||||
}
|
||||
|
||||
public void WriteString(string msg)
|
||||
{
|
||||
var msgLength = msg.Length;
|
||||
_ms.Write(BitConverter.GetBytes(msgLength));
|
||||
_ms.Write(Encoding.ASCII.GetBytes(msg));
|
||||
}
|
||||
|
||||
public byte[] GetPacketBytes()
|
||||
{
|
||||
return _ms.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user