Table of Contents

Class FileTransferMessage

Namespace
SteamNetworkLib.Models
Assembly
SteamNetworkLib.dll

Represents a file transfer message for sharing files between players in chunks. Supports chunked file transfer to handle large files that exceed network packet size limits.

public class FileTransferMessage : P2PMessage
Inheritance
FileTransferMessage
Inherited Members

Constructors

FileTransferMessage()

public FileTransferMessage()

Properties

ChunkData

Gets or sets the raw file data for this chunk. Contains the actual bytes of the file segment being transferred.

public byte[] ChunkData { get; set; }

Property Value

byte[]

ChunkIndex

Gets or sets the zero-based index of this chunk in the file transfer sequence. Used to reassemble the file chunks in the correct order.

public int ChunkIndex { get; set; }

Property Value

int

FileName

Gets or sets the name of the file being transferred. Should include the file extension for proper identification.

public string FileName { get; set; }

Property Value

string

FileSize

Gets or sets the total size of the file in bytes. Used by the recipient to validate the complete transfer and allocate storage.

public int FileSize { get; set; }

Property Value

int

IsFileData

Gets or sets a value indicating whether this message contains actual file data. When false, this message may be a file transfer control message (start, end, error, etc.).

public bool IsFileData { get; set; }

Property Value

bool

MessageType

Gets the message type identifier for file transfer messages.

public override string MessageType { get; }

Property Value

string

TotalChunks

Gets or sets the total number of chunks that make up the complete file. Used by the recipient to determine when the file transfer is complete.

public int TotalChunks { get; set; }

Property Value

int

Methods

Deserialize(byte[])

Deserializes the file transfer message from a byte array received over the network. Parses the JSON header and extracts the binary chunk data.

public override void Deserialize(byte[] data)

Parameters

data byte[]

The byte array containing the serialized message data.

Serialize()

Serializes the file transfer message to a byte array for network transmission. Uses a hybrid format with JSON header followed by raw binary data.

public override byte[] Serialize()

Returns

byte[]

A byte array containing the serialized message with header and chunk data.