You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 07:06:30 +09:00
Added missing files
This commit is contained in:
63
Lidgren.Network/NetIncomingMessage.Stream.cs
Normal file
63
Lidgren.Network/NetIncomingMessage.Stream.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetIncomingMessage : Stream
|
||||
{
|
||||
public override bool CanRead { get { return true; } }
|
||||
public override bool CanSeek { get { return true; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length in bytes
|
||||
/// </summary>
|
||||
public override long Length
|
||||
{
|
||||
get { return LengthBytes; }
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
// limit amount to remaining
|
||||
int remainingBytes = NetUtility.BytesToHoldBits(m_bitLength - m_readPosition);
|
||||
if (count > remainingBytes)
|
||||
count = remainingBytes;
|
||||
if (count < 1)
|
||||
return 0;
|
||||
|
||||
ReadBytes(buffer, offset, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position in the stream, in bytes
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
Position = (offset * 8);
|
||||
break;
|
||||
case SeekOrigin.Current:
|
||||
Position = Position + (offset * 8);
|
||||
break;
|
||||
case SeekOrigin.End:
|
||||
Position = (LengthBytes - offset) * 8;
|
||||
break;
|
||||
}
|
||||
throw new NotImplementedException("Bad SeekOrigin");
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NetException("It's not possible to set the length of the NetIncomingMessage");
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Lidgren.Network/NetOutgoingMessage.Stream.cs
Normal file
52
Lidgren.Network/NetOutgoingMessage.Stream.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetOutgoingMessage : Stream
|
||||
{
|
||||
public override bool CanRead { get { return false; } }
|
||||
public override bool CanSeek { get { return false; } }
|
||||
public override bool CanWrite { get { return true; } }
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the stream, in bytes
|
||||
/// </summary>
|
||||
public override long Length
|
||||
{
|
||||
get { return (long)LengthBytes; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NetException("Position in bytes is not relevant since the bit count can vary");
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NetException("It's not possible to seek in this message");
|
||||
}
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NetException("It's not possible to read from this message");
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NetException("It's not possible to seek in this message");
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NetException("It's not possible to set the length of this message");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user