TNet 3  3.0.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
Package TNet

Classes

class  BinaryExtensions
 BinaryReader and BinaryWriter extension methods. More...
 
class  Buffer
 This class merges BinaryWriter and BinaryReader into one. More...
 
class  CachedFunc
 Functions gathered via reflection get cached along with their object references and expected parameter types. More...
 
class  Channel
 A channel contains one or more players. All information broadcast by players is visible by others in the same channel. More...
 
class  ComponentSerialization
 This class contains DataNode serialization methods for Unity components that make it possible to serialize behaviours and game objects. More...
 
class  Counter
 Counter is a value that automatically changes with time. It's ideal for resources. More...
 
struct  Datagram
 Simple datagram container – contains a data buffer and the address of where it came from (or where it's going). More...
 
class  DataNode
 Data Node is a hierarchical data type containing a name and a value, as well as a variable number of children. Data Nodes can be serialized to and from IO data streams. Think of it as an alternative to having to include a huge 1 MB+ XML parsing library in your project. More...
 
class  DataNodeContainer
 Simple container class holding a dataNode with convenient Get and Set functions. More...
 
class  FieldOrProperty
 Convenient wrapper for a getter and setter of a field or property on the chosen object. More...
 
class  FieldOrPropertyExtensions
 Convenience extension methods for the TNet.Property. More...
 
class  FileServer
 Base class for Game and Lobby servers capable of saving and loading files. More...
 
class  GameClient
 Client-side logic. More...
 
class  GameServer
 Game server logic. Handles new connections, RFCs, and pretty much everything else. Example usage: GameServer gs = new GameServer(); gs.Start(5127); More...
 
interface  IBinarySerializable
 If custom or simply more efficient serialization is desired, derive your class from IBinarySerializable. Ideal use case would be to reduce the amount of data sent over the network via RFCs. More...
 
interface  IDataNodeSerializable
 Implementing the IDataNodeSerializable interface in your class will make it possible to serialize that class into the Data Node format more efficiently. More...
 
class  IgnoredByTNet
 Can be used to mark fields as ignored by TNet-based serialization. More...
 
class  List< T >
 This improved version of the System.Collections.Generic.List that doesn't release the buffer on Clear(), resulting in better performance and less garbage collection. More...
 
class  LobbyServer
 Abstract class for a lobby server. More...
 
class  LobbyServerLink
 The game server cannot communicate directly with a lobby server because that server can be TCP or UDP based, and may also be hosted either locally or on another computer. And so we use a different class to "link" them together – the LobbyServerLink. This class will link a game server with a local lobby server. More...
 
struct  ObsInt
 Obfuscated type integer. Usable just like any integer, but when it's in memory it's not recognizable. Useful for avoiding CheatEngine lookups. More...
 
class  Player
 Class containing basic information about a remote player. More...
 
class  RCC
 Remote Creation Call attribute. Used to identify functions that are supposed to executed when custom OnCreate packets arrive. More...
 
class  RFC
 Remote Function Call attribute. Used to identify functions that are supposed to be executed remotely. More...
 
class  Serialization
 This class contains various serialization extension methods that make it easy to serialize any object into binary form that's smaller in size than what you would get by simply using the Binary Formatter. If you want more efficient serialization, implement IBinarySerializable. More...
 
class  SerializeProperties
 
class  ServerList
 Server list is a helper class containing a list of servers. More...
 
class  TcpLobbyServer
 Optional TCP-based listener that makes it possible for servers to register themselves with a central location for easy lobby by clients. More...
 
class  TcpLobbyServerLink
 TCP-based lobby server link. Designed to communicate with a remote TcpLobbyServer. You can use this class to register your game server with a remote lobby server. More...
 
class  TcpPlayer
 Class containing information about connected players. More...
 
class  TcpProtocol
 Common network communication-based logic: sending and receiving of data via TCP. More...
 
interface  TList
 Generic interface with an Add function so that it can be used by the Serializer. More...
 
class  TNAutoCreate
 Instantiate the specified prefab at the game object's position. More...
 
class  TNAutoJoin
 Extremely simplified "join a server" functionality. Attaching this script will make it possible to automatically join a remote server when the game starts. It's best to place this script in a clean scene with a message that displays a "Connecting, please wait..." message. More...
 
class  TNAutoSync
 This script makes it really easy to sync some value across all connected clients. Keep in mind that this script should ideally only be used for rapid prototyping. It's still better to create custom to-the-point sync scripts as they will yield better performance. More...
 
class  TNBehaviour
 If your MonoBehaviour will need to use a TNObject, deriving from this class will make it easier. More...
 
class  TNEventReceiver
 Convenience class that you can inherit from that implements all of TNet's common notifications for user convenience. Note that this script should ideally only be used on a manager class that needs to know about all these events. If your class only needs a few of these events, consider simply subscribing to them directly using the same += and -= logic in OnEnable/OnDisable. More...
 
class  TNEvents
 Container class with all the possible notification delegates used by TNet's GameClient. More...
 
class  TNLobbyClient
 Server Lobby Client is an abstract class designed to communicate with the Lobby Server. You should instantiate protocol-specific versions: TNTcpLobbyClient or TNUdpLobbyClient, and you should only have one of them active at a time, not both. More...
 
class  TNManager
 Tasharen Network Manager tailored for Unity. More...
 
class  TNObject
 Tasharen Network Object makes it possible to easily send and receive remote function calls. Unity networking calls this type of object a "Network View". More...
 
class  TNServerInstance
 Tasharen Network server tailored for Unity. More...
 
class  TNSyncRigidbody
 This script makes it easy to sync rigidbodies across the network. Use this script on all the objects in your scene that have a rigidbody and can move as a result of physics-based interaction with other objects. Note that any user-based interaction (such as applying a force of any kind) should still be sync'd via an explicit separate RFC call for optimal results. More...
 
class  TNTcpLobbyClient
 TCP-based lobby client, designed to communicate with the TcpLobbyServer. More...
 
class  TNUdpLobbyClient
 UDP-based lobby client, designed to communicate with the UdpLobbyServer. More...
 
class  Tools
 Generic sets of helper functions used within TNet. More...
 
class  TypeExtensions
 Static helper class containing useful extensions for the System.Type class. More...
 
class  UdpLobbyServer
 Optional UDP-based listener that makes it possible for servers to register themselves with a central location for easy lobby by clients. More...
 
class  UdpLobbyServerLink
 UDP-based lobby server link. Designed to communicate with a remote UdpLobbyServer. You can use this class to register your game server with a remote lobby server. More...
 
class  UdpProtocol
 UDP class makes it possible to broadcast messages to players on the same network prior to establishing a connection. More...
 
class  UnityEditorExtensions
 
class  UnityTools
 Common Tasharen Network-related functionality and helper functions to be used with Unity. More...
 
class  UPnP
 Universal Plug & Play functionality: auto-detect external IP and open external ports. Technically this class would be a fair bit shorter if I had used an XML parser... However I'd rather not, as adding the XML library also adds 1 megabyte to the executable's size in Unity. More...
 
class  WorkerThread
 Worker thread is a convenience class that can execute specified code on a separate thread. The worker thread class takes care of creating multiple threads for concurrent code execution. More...
 

Enumerations

enum  Target {
  Target.All, Target.AllSaved, Target.Others, Target.OthersSaved,
  Target.Host, Target.Broadcast, Target.Admin
}
 Helper enum – the entries should be in the same order as in the Packet enum. More...
 
enum  Packet {
  Packet.Empty, Packet.Error, Packet.Disconnect, Packet.RequestAddServer,
  Packet.RequestRemoveServer, Packet.RequestServerList, Packet.ResponseServerList, Packet.ServerLog,
  Packet.RequestID, Packet.ResponseID, Packet.RequestPing, Packet.ResponsePing,
  Packet.RequestSetUDP, Packet.ResponseSetUDP, Packet.RequestActivateUDP, Packet.RequestJoinChannel,
  Packet.ResponseJoiningChannel, Packet.ResponseJoinChannel, Packet.ResponsePlayerJoined, Packet.RequestLeaveChannel,
  Packet.ResponseLeaveChannel, Packet.ResponsePlayerLeft, Packet.RequestCloseChannel, Packet.RequestSetPlayerLimit,
  Packet.RequestLoadLevel, Packet.ResponseLoadLevel, Packet.RequestSetName, Packet.ResponseRenamePlayer,
  Packet.RequestSetHost, Packet.ResponseSetHost, Packet.RequestRemoveRFC, Packet.RequestCreateObject,
  Packet.ResponseCreateObject, Packet.RequestTransferObject, Packet.ResponseTransferObject, Packet.RequestDestroyObject,
  Packet.ResponseDestroyObject, Packet.RequestGetFileList, Packet.ResponseGetFileList, Packet.RequestSaveFile,
  Packet.RequestLoadFile, Packet.ResponseLoadFile, Packet.RequestDeleteFile, Packet.RequestNoDelay,
  Packet.RequestSetChannelData, Packet.ResponseSetChannelData, Packet.RequestChannelList, Packet.ResponseChannelList,
  Packet.ForwardToAll, Packet.ForwardToAllSaved, Packet.ForwardToOthers, Packet.ForwardToOthersSaved,
  Packet.ForwardToHost, Packet.ForwardToPlayer, Packet.ForwardByName, Packet.ForwardTargetNotFound,
  Packet.Broadcast, Packet.BroadcastAdmin, Packet.RequestSetTimeout, Packet.RequestSetPlayerData,
  Packet.ResponseSetPlayerData, Packet.RequestDeleteChannel, Packet.RequestVerifyAdmin, Packet.RequestCreateAdmin,
  Packet.RequestRemoveAdmin, Packet.RequestKick, Packet.RequestBan, Packet.RequestSetAlias,
  Packet.RequestUnban, Packet.RequestLogPlayers, Packet.RequestSetBanList, Packet.RequestReloadServerConfig,
  Packet.RequestSetServerData, Packet.ResponseSetServerData, Packet.ResponseVerifyAdmin, Packet.RequestLockChannel,
  Packet.ResponseLockChannel, Packet.RequestHTTPGet, Packet.RequestRenameServer, Packet.RequestSetPlayerSave,
  Packet.UserPacket = 128
}
 Clients send requests to the server and receive responses back. Forwarded calls arrive as-is. More...
 

Enumeration Type Documentation

Clients send requests to the server and receive responses back. Forwarded calls arrive as-is.

Enumerator
Empty 

Empty packet. Can be used to keep the connection alive.

Error 

This packet indicates that an error has occurred. string: Description of the error.

Disconnect 

This packet indicates that the connection should be severed.

RequestAddServer 

Add a new entry to the list of known servers. Used by the Lobby Server. ushort: Game ID. string: Server name. ushort: Number of connected players. IPEndPoint: Internal address IPEndPoint: External address

RequestRemoveServer 

Remove an existing server list entry. Used by the Lobby Server. ushort: Game ID. IPEndPoint: Internal address IPEndPoint: External address

RequestServerList 

Request a list of all known servers for the specified game ID. Used by the Lobby Server. ushort: Game ID.

ResponseServerList 

Response sent by the Lobby Server, listing servers. ushort: List size For each entry: string: Server name ushort: Player count IPEndPoint: Internal address IPEndPoint: External address

ServerLog 

Print a message on the server. Used to make verbose output possible. string: text to log.

RequestID 

This should be the very first packet sent by the client. int32: Protocol version. string: Player Name. object: Player data.

ResponseID 

Always the first packet to arrive from the server. If the protocol version didn't match the client, a disconnect may follow. int32: Protocol ID. int32: Player ID (only if the protocol ID matched). int64: Server time in milliseconds (only if the protocol ID matched). int64: Server's start time in milliseconds (only if the protocol ID matched).

RequestPing 

Clients should send a ping request periodically.

ResponsePing 

Response to a ping request.

RequestSetUDP 

Set the remote UDP port for unreliable packets. ushort: port.

ResponseSetUDP 

Set a UDP port used for communication. ushort: port. (0 means disabled)

RequestActivateUDP 

Activate UDP functionality on the server for this client. This must be sent via UDP and it has no response. int32: Player ID.

RequestJoinChannel 

Join the specified channel. int32: Channel ID (-1 = new random, -2 = existing random) string: Channel password. bool: Whether the channel should be persistent (left open even when the last player leaves). ushort: Player limit.

ResponseJoiningChannel 

Start of the channel joining process. Sent to the player who is joining the channel.

Parameters: int32: Channel ID. int16: Number of players.

Then for each player: int32: Player ID. bool: Whether player name and data follows. If a player is already known, it won't be sent. string: Player Name. DataNode: Player data.

ResponseJoinChannel 

Inform the player that they have successfully joined a channel. int32: Channel ID. bool: Success or failure. string: Error string (if failed).

ResponsePlayerJoined 

Inform the channel that a new player has joined. int32: Channel ID. int32: Player ID. bool: Whether player name and data follows. If a player is already known, it won't be sent. string: Player name. DataNode: Player data.

RequestLeaveChannel 

Leave the channel the player is in. int32: Channel ID.

ResponseLeaveChannel 

Inform the player that they have left the channel they were in. int: Channel ID.

ResponsePlayerLeft 

Inform everyone of this player leaving the channel. int32: Channel ID. int32: Player ID.

RequestCloseChannel 

Mark the channel as closed. No further players will be able to join and saved data will be deleted. int32: Channel ID.

RequestSetPlayerLimit 

Change the number of players that can be in this channel at the same time. int32: Channel ID; ushort: Player limit.

RequestLoadLevel 

Load the specified level. int32: Channel ID; string: Level Name.

ResponseLoadLevel 

Load the specified level. Should happen before all buffered calls. int32: Channel ID. string: Name of the level.

RequestSetName 

Player name change. string: Player name.

ResponseRenamePlayer 

Change the specified player's name. int32: Player ID, string: Player name.

RequestSetHost 

Transfer the host status to the specified player. Only works if the sender is currently hosting. int32: Channel ID. int32: Player ID.

ResponseSetHost 

Inform the player of who is hosting. int32: Channel ID. int32: Player ID.

RequestRemoveRFC 

Delete the specified buffered function. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function Name (only if RFC ID is 0).

RequestCreateObject 

Instantiate a new object with the specified identifier. int32: ID of the player that sent the packet. int32: Channel ID. byte: 0 = Local-only object. Only echoed to other clients. 1 = Saved on the server, assigned a new owner when the existing owner leaves. 2 = Saved on the server, destroyed when the owner leaves.

byte: RCC ID. string: Function name (only if RCC ID is 0). string: Path to the object in the Resources folder. Arbitrary amount of data follows. All of it will be passed along with the response call.

ResponseCreateObject 

Create a new persistent entry. int32: ID of the player that requested this object to be created. int32: Channel ID. uint32: Unique Identifier (aka Object ID) if requested, 0 otherwise. 0-16777215 range.

byte: RCC ID. string: Function name (only if RCC ID is 0). string: Path to the object in the Resources folder. Arbitrary amount of data follows, same data that was passed along with the Create Request.

RequestTransferObject 

Transfer the specified object (and all of is RFCs) to another channel. The player must be present in the 'from' channel in order for this to work. This command will only work on objects that have been created dynamically via TNManager.Create. int32: Channel ID where the object resides. int32: Channel ID where to transfer the object. uint32: Object ID.

ResponseTransferObject 

Notification that the specified object has been transferred to another channel. This notification is only sent to players that are in both channels. int32: Old channel ID. int32: New channel ID. uint32: Old object ID. uint32: New object ID.

RequestDestroyObject 

Delete the specified Network Object. int32: Channel ID. uint32: Object ID.

ResponseDestroyObject 

Delete the specified Unique Identifier and its associated entry. int32: Channel ID. ushort: Number of objects that will follow. uint32[] Unique Identifiers (aka Object IDs).

RequestGetFileList 

Get the list of files in the specified folder. string: Path.

ResponseGetFileList 

Server returning a list of files from RequestGetFileList. string: Path. int32: Number of filenames that follow. string[] files.

RequestSaveFile 

Save the specified data. string: Filename. int32: Size of the data in bytes. Arbitrary amount of data follows.

RequestLoadFile 

Load the requested data that was saved previously. string: Filename.

ResponseLoadFile 

Loaded file response. string: Filename. int32: Number of bytes to follow. byte[]: Data.

RequestDeleteFile 

Delete the specified file. string: Filename.

RequestNoDelay 

Improve latency of the established connection at the expense of network traffic. bool: Whether to improve it (enable NO_DELAY)

RequestSetChannelData 

Set the channel's data field. int32: Channel ID. string: Path, such as "Unlocks/something". Can be an empty string to set the root node. object: Custom value. Can also be a DataNode to set that node.

ResponseSetChannelData 

The channel's data has been changed. int32: Channel ID. string: Path, such as "Unlocks/something". Can be an empty string to set the root node. object: Custom value. Can also be a DataNode to set that node.

RequestChannelList 

Request the list of open channels from the server.

ResponseChannelList 

List open channels on the server. int32: number of channels to follow For each channel: int32: ID ushort: Number of players ushort: Player limit bool: Has a password bool: Is persistent string: Level DataNode: Custom data

ForwardToAll 

Echo the packet to everyone in the room. Interpreting the packet is up to the client. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardToAllSaved 

Echo the packet to everyone in the room and everyone who joins later. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardToOthers 

Echo the packet to everyone in the room except the sender. Interpreting the packet is up to the client. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardToOthersSaved 

Echo the packet to everyone in the room (except the sender) and everyone who joins later. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardToHost 

Echo the packet to the room's host. Interpreting the packet is up to the client. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardToPlayer 

Echo the packet to the specified player. int32: ID of the player that sent the packet. int32: Player ID. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardByName 

Echo the packet to the specified player. int32: ID of the player that sent the packet. string: Player name. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

ForwardTargetNotFound 

Server notification sent when the target requested by ForwardByName was not found. string: Player name.

Broadcast 

Echo this message to everyone connected to the server. Note that TNet 3 supports multiple channels, so broadcasts are no longer needed. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

BroadcastAdmin 

Echo this message to administrators connected to the server. Same as Broadcast, but only goes to admins. int32: ID of the player that sent the packet. int32: Channel ID. uint32: Object ID (24 bits), RFC ID (8 bits). string: Function name (only if RFC ID is 0). Arbitrary amount of data follows.

RequestSetTimeout 

By default, the player gets disconnected after 10 seconds of inactivity. You can change this on a per-player basis. Setting this value to '0' will turn off this functionality altogether – however it's a good idea to keep it at some valid non-zero value. If you know the player is going to be loading a level for up to a minute, set it to 2 minutes (120). int32: timeout delay in seconds

RequestSetPlayerData 

Set the player's 'data' property. When a client sends this packet to the server, the same packet will be echoed to everyone except the sender. int32: Player ID who's data should be synchronized. Must match the player that sent the request. string: Path, such as "Unlocks/something". Can be an empty string to set the root node. object: Custom value. Can also be a DataNode to set that node.

ResponseSetPlayerData 

Set the player data associated with the specified player. int32: Player ID who's data should be synchronized. string: Path, such as "Unlocks/something". Can be an empty string to set the root node. object: Custom value. Can also be a DataNode to set that node.

RequestDeleteChannel 

Mark the channel as closed and kick out all the players. int32: channel ID. bool: whether to disconnect the players, or just make them leave the channel.

RequestVerifyAdmin 

Request to be made an administrator. string: password.

RequestCreateAdmin 

Request to add a new admin. string: admin keyword to add.

RequestRemoveAdmin 

Remove this admin from the list. string: admin keyword to remove.

RequestKick 

Kick the specified player. int32: Channel ID. int32: Player ID. string: player name or address

RequestBan 

Ban this player. int32: Player ID. string: player name or address (if ID is '0')

RequestSetAlias 

Assigns the specified alias to the player. If this alias fails to pass the ban list, the player get disconnected. string: alias to add.

RequestUnban 

Remove ban from this keyword. string: data to remove.

RequestLogPlayers 

No longer used.

RequestSetBanList 

Change the ban list to the specified one. Only administrators can do this. string: ban list's contents.

RequestReloadServerConfig 

Reload configuration, admin and ban list data. Only administrators can use this command.

RequestSetServerData 

Sets a server option. Only administrators can do this. string: Path, such as "Unlocks/something". Can be an empty string to set the root node. object: Custom value. Can also be a DataNode to set that node.

ResponseSetServerData 

Server option sent back from the server to all connected clients in response to RequestSetServerOption. string: Path, such as "Unlocks/something". Can be an empty string to set the root node. object: Custom value. Can also be a DataNode to set that node.

ResponseVerifyAdmin 

Response coming from the server for authenticated administrators. int32: ID of the player.

RequestLockChannel 

Lock the current channel, preventing all forms of create, delete and saved RFCs. Anyone trying to call create, delete or saved RFCs will be logged and ignored. Only administrators can lock channels. int32: channel ID. bool: whether it should be locked.

ResponseLockChannel 

Response coming from the server that sets the local locked channel flag. int32: channel ID. bool: whether it's locked.

RequestHTTPGet 

Special message indicates that the connected player was actually a web browser. string: Path of the HTTP GET request.

RequestRenameServer 

Change the server's name without restarting it. Admin-only. string: Server's new name.

RequestSetPlayerSave 

Request to set the specified filename to be associated with player saves. The data within the file will be loaded and a ResponseSetPlayerData will be sent back. TNet will automatically save the player's data into this file from this moment onward. string: Filename to use for player saves. byte: Save type. 0 = Text. 1 = Binary. 2 = Compressed.

UserPacket 

Begin custom packets here.

Helper enum – the entries should be in the same order as in the Packet enum.

Enumerator
All 

Echo the packet to everyone in the room.

AllSaved 

Echo the packet to everyone in the room and everyone who joins later.

Others 

Echo the packet to everyone in the room except the sender.

OthersSaved 

Echo the packet to everyone in the room (except the sender) and everyone who joins later.

Host 

Echo the packet to the room's host.

Broadcast 

Broadcast is the same as "All", but it has a built-in spam checker. Ideal for global chat.

Admin 

Send this packet to administrators.