36 lines
732 B
C#
36 lines
732 B
C#
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();
|
|
}
|
|
}
|
|
}
|