first commit
This commit is contained in:
30
Yapper/Net/IO/PacketReader.cs
Normal file
30
Yapper/Net/IO/PacketReader.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YapperClient.Net.IO
|
||||
{
|
||||
class PacketReader : BinaryReader
|
||||
{
|
||||
private NetworkStream _ns;
|
||||
public PacketReader(NetworkStream ns) : base(ns)
|
||||
{
|
||||
_ns = ns;
|
||||
}
|
||||
|
||||
public string ReadMessage()
|
||||
{
|
||||
byte[] msgBuffer;
|
||||
var length = ReadInt32();
|
||||
msgBuffer = new byte[length];
|
||||
_ns.Read(msgBuffer, 0, length);
|
||||
|
||||
var msg = Encoding.ASCII.GetString(msgBuffer);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user