Class RawStringSyncSerializer
- Namespace
- SteamNetworkLib.Sync
- Assembly
- SteamNetworkLib.dll
Sync serializer that passes string values through without JSON encoding.
public sealed class RawStringSyncSerializer : ISyncSerializer
- Inheritance
-
RawStringSyncSerializer
- Implements
- Inherited Members
Remarks
Use this for pre-serialized payloads, pipe-delimited state, compact protocol strings, or compatibility data that must match another mod's existing lobby-data format. Non-empty strings are stored verbatim. Steam lobby and member data use an empty string for missing keys, so an empty or null value follows the SyncVar's missing-value behavior and resolves to its configured default on other peers. It only supports string values; use JsonSyncSerializer for typed objects, primitives, collections, and general-purpose SyncVars.
Constructors
RawStringSyncSerializer()
public RawStringSyncSerializer()
Methods
CanSerialize(Type)
Checks if a type can be serialized by this serializer.
public bool CanSerialize(Type type)
Parameters
typeTypeThe type to check.
Returns
- bool
True if the type can be serialized; otherwise, false.
Remarks
This method is called during HostSyncVar<T> and ClientSyncVar<T> creation to validate that the type parameter is serializable.
Deserialize<T>(string)
Deserializes a string back to the original value type.
public T Deserialize<T>(string data)
Parameters
datastringThe serialized string data.
Returns
- T
The deserialized value.
Type Parameters
TThe type to deserialize to.
Exceptions
- SyncSerializationException
Thrown when deserialization fails.
Serialize<T>(T)
Serializes a value to a string for network transmission.
public string Serialize<T>(T value)
Parameters
valueTThe value to serialize.
Returns
- string
A string representation of the value.
Type Parameters
TThe type of value to serialize.
Exceptions
- SyncSerializationException
Thrown when serialization fails.