StreamWriter
A class in Alta.Serialization.Runtime, Alta.Serialization.
The writing side of the game's bit stream, backed by a BitWriter over a uint buffer. Network messages and saves are written with it.
- Listed in Other Alta assemblies
- Inherits or implements
Stream - Documented in Stream
Constructors
| Member | What it is |
|---|---|
StreamWriter(BitWriter.GetMoreData getMoreData = null) | Creates a StreamWriter from data. |
StreamWriter(uint[] data) | Creates a StreamWriter from data. |
Properties
| Member | What it is |
|---|---|
override uint BitIndex { get; } | How many bits have been written so far. |
uint[] Data { get; } | The underlying uint buffer the bits are written into. |
uint MessageType { get; set; } | A message type number carried alongside the data. Copied by Clone. |
override uint TotalByteCount { get; } | The size of the whole buffer in bytes, not how much has been written. |
BitWriter Writer { get; private set; } | The BitWriter that does the work. Null after Dispose. |
Methods
| Member | What it is |
|---|---|
override void Align() | Pads the write position up to the next byte boundary. |
uint AlignAndFlush() | Aligns, flushes the writer's pending bits into the buffer and returns the writer's result (probably the byte count). |
override void BackTrack(uint bitCount) | Moves the write position back by the given number of bits. |
void Clear() | Resets the writer so the stream can be reused. |
void ClearAndSetData(uint[] data) | Resets the writer and points it at a new uint buffer. |
override object Clone() | Copies the buffer, message type and writer state into a new StreamWriter. |
void CopyTo(byte[] data, int offset, int bytes) | Copies the first bytes of the buffer into a byte array at an offset. |
override void Dispose() | Clears the writer and drops it. The stream can't be used afterwards. |
override void SerializeBits(ref uint value, int bitCount) | Writes the low bits of a value. |
override void SerializeString(ref string value, Stream.StringEncoding encoding = 0) | Writes a string as a 16-bit length then aligned ASCII or UTF-8 bytes. Null is written as empty. |
uint[] ToBits(uint bitCount) | Copies the first bits of the buffer into a uint array, reusing the passed array when it's big enough. |
uint[] ToBits(uint bitCount, uint[] existing) | Copies the first bits of the buffer into a uint array, reusing the passed array when it's big enough. |
byte[] ToBytes(uint byteCount, int preSize) | Copies the first bytes of the buffer into a new byte array, leaving room for a header of the given size at the front. |
protected override void Finalize() | Disposes the stream if it wasn't disposed already. |
protected override void SerializeBytes(byte[] value, int byteCount) | Writes raw bytes. |
Used in
Members of other types that take, return or hold a StreamWriter:
SavedDynamicObject.GetWriter, CustomizationWrapperSerializer.WriteStream, CustomizationWrapperSerializer.WriteStreamRestricted, Connection.Send, EntitySerializer.sharedWriter, EntitySerializer.WriteDataIntoStream, EntitySerializer.WriteFullDataIntoStream, EntitySerializer.WriteIntoStreamInternal, OutgoingPacketManager.lastSceneSerialize, OutgoingPacketManager.queue, OutgoingPacketManager.Send, OutgoingPacketManager.SendWithQueued, OutgoingPacketManager.SerializeToWriter, OutgoingPacketManager.StartSerialize, OutgoingPacketManager.StopSerialize, OutgoingPacketManager.writerMap, OutgoingPacketManager.WriteToCurrent, OutgoingPacketManager.WriteToReliable, OutgoingPacketManager.WriteToUnreliable, Packet.Write, SceneSerializer.SerializeWrite, PlayerStateManager.EnterNewState, PlayerStateManager.GetSyncStreamForLeavingState.