TNet 3  3.0.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
TNet.TcpPlayer Class Reference

Class containing information about connected players. More...

Inheritance diagram for TNet.TcpPlayer:
TNet.TcpProtocol TNet.Player TNet.DataNodeContainer

Public Member Functions

bool IsInChannel (int id)
 Whether the player is in the specified channel. More...
 
Channel GetChannel (int id)
 Return the specified channel if the player is currently within it, null otherwise. More...
 
bool IsKnownTo (Player p, Channel ignoreChannel=null)
 Whether the specified player is already known to this one. More...
 
- Public Member Functions inherited from TNet.TcpProtocol
void Connect (IPEndPoint externalIP, IPEndPoint internalIP=null)
 Try to establish a connection with the specified remote destination. More...
 
void Disconnect (bool notify=false)
 Disconnect the player, freeing all resources. More...
 
void Close (bool notify)
 Close the connection. More...
 
void Release ()
 Release the buffers. More...
 
BinaryWriter BeginSend (Packet type)
 Begin sending a new packet to the server. More...
 
BinaryWriter BeginSend (byte packetID)
 Begin sending a new packet to the server. More...
 
void EndSend ()
 Send the outgoing buffer. More...
 
void SendTcpPacket (Buffer buffer)
 Send the specified packet. Marks the buffer as used. More...
 
void StartReceiving ()
 Start receiving incoming messages on the current socket. More...
 
void StartReceiving (Socket socket)
 Start receiving incoming messages on the specified socket (for example socket accepted via Listen). More...
 
bool ReceivePacket (out Buffer buffer)
 Extract the first incoming packet. More...
 
void LogError (string error, string stack=null, bool logInFile=true)
 Log an error message. More...
 
void Log (string msg, string stack=null, bool logInFile=true)
 Log an error message. More...
 
void RespondWithError (string error)
 Add an error packet to the incoming queue. More...
 
void RespondWithError (Exception ex)
 Add an error packet to the incoming queue. More...
 
bool VerifyRequestID (BinaryReader reader, Buffer buffer, bool uniqueID)
 Verify the connection. Returns 'true' if successful. More...
 
bool VerifyResponseID (Packet packet, BinaryReader reader)
 Verify the connection. Returns 'true' if successful. More...
 
- Public Member Functions inherited from TNet.Player
bool AddAlias (string s)
 Add a new alias to work with. More...
 
bool HasAlias (string s)
 Does the player have this alias? More...
 
 Player ()
 
 Player (string playerName)
 
- Public Member Functions inherited from TNet.DataNodeContainer
DataNode Set (string path, object val)
 Set the specified value. Note that on the client side only the player's owner should be setting the values. More...
 
DataNode Get (string path)
 Get the specified child within the DataNode. More...
 
Get< T > (string path)
 Get the specified value from the DataNode. More...
 
Get< T > (string path, T defaultVal)
 Get the specified value from the DataNode. More...
 

Public Attributes

List< Channelchannels = new List<Channel>()
 Channel that the player is currently in. More...
 
IPEndPoint udpEndPoint
 UDP end point if the player has one open. More...
 
bool udpIsUsable = false
 Whether the UDP has been confirmed as active and usable. More...
 
bool isAdmin = false
 Whether this player has authenticated as an administrator. More...
 
string savePath
 Path where the player's data gets saved, if any. More...
 
bool saveNeeded = false
 Next time the player data will be saved. More...
 
DataNode.SaveType saveType = DataNode.SaveType.Binary
 Type of the saved data. More...
 
long nextBroadcast = 0
 Time of the next possible broadcast, used to catch spammers. More...
 
int broadcastCount = 0
 Count broadcasts done per second. More...
 
- Public Attributes inherited from TNet.TcpProtocol
Stage stage = Stage.NotConnected
 Current connection stage. More...
 
IPEndPoint tcpEndPoint
 IP end point of whomever we're connected to. More...
 
long lastReceivedTime = 0
 Timestamp of when we received the last message. More...
 
long timeoutTime = 20000
 How long to allow this player to go without packets before disconnecting them. This value is in milliseconds, so 1000 means 1 second. More...
 
Queue< BuffersendQueue = null
 If sockets are not used, an outgoing queue can be specified instead. More...
 
- Public Attributes inherited from TNet.Player
const int version = 20160822
 Protocol version. More...
 
int id = 1
 All players have a unique identifier given by the server. More...
 
string name = "Guest"
 All players have a name that they chose for themselves. More...
 
List< string > aliases = null
 Player's known aliases. These will be checked against the ban list. Ideal usage: Steam ID, computer ID, account ID, etc. More...
 
- Public Attributes inherited from TNet.DataNodeContainer
DataNode dataNode
 Custom data easily accessible via Get and Set functions. More...
 

Properties

Channel channel [get]
 
- Properties inherited from TNet.TcpProtocol
bool isConnected [get]
 Whether the connection is currently active. More...
 
Socket socket [get]
 Socket used for communication. More...
 
Queue< BufferreceiveQueue [get]
 Direct access to the incoming buffer to deposit messages in. Don't forget to lock it before using it. More...
 
bool isSocketConnected [get]
 Whether the socket is currently connected. A socket can be connected while verifying the connection. In most cases you should use 'isConnected' instead. More...
 
bool isTryingToConnect [get]
 Whether we are currently trying to establish a new connection. More...
 
bool noDelay [get, set]
 Enable or disable the Nagle's buffering algorithm (aka NO_DELAY flag). Enabling this flag will improve latency at the cost of increased bandwidth. http://en.wikipedia.org/wiki/Nagle's_algorithm More...
 
string address [get]
 Connected target's address. More...
 

Additional Inherited Members

- Public Types inherited from TNet.TcpProtocol
enum  Stage {
  Stage.NotConnected, Stage.Connecting, Stage.Verifying, Stage.Connected,
  Stage.WebBrowser
}
 
- Static Public Member Functions inherited from TNet.Player
static void ResetPlayerCounter ()
 Call after shutting down the server. More...
 
- Static Public Attributes inherited from TNet.TcpProtocol
static bool httpGetSupport = false
 Whether the hosted server will respond to HTTP GET requests. More...
 
static IPAddress defaultListenerInterface = IPAddress.Any
 When you have multiple network interfaces, it's often important to be able to specify which interface will actually be listened to messages. You can change it to IPv6, for example. More...
 
- Static Protected Attributes inherited from TNet.Player
static int mPlayerCounter = 0
 
static object mLock = new int()
 

Detailed Description

Class containing information about connected players.

Member Function Documentation

Channel TNet.TcpPlayer.GetChannel ( int  id)

Return the specified channel if the player is currently within it, null otherwise.

bool TNet.TcpPlayer.IsInChannel ( int  id)

Whether the player is in the specified channel.

bool TNet.TcpPlayer.IsKnownTo ( Player  p,
Channel  ignoreChannel = null 
)

Whether the specified player is already known to this one.

Member Data Documentation

int TNet.TcpPlayer.broadcastCount = 0

Count broadcasts done per second.

List<Channel> TNet.TcpPlayer.channels = new List<Channel>()

Channel that the player is currently in.

bool TNet.TcpPlayer.isAdmin = false

Whether this player has authenticated as an administrator.

long TNet.TcpPlayer.nextBroadcast = 0

Time of the next possible broadcast, used to catch spammers.

bool TNet.TcpPlayer.saveNeeded = false

Next time the player data will be saved.

string TNet.TcpPlayer.savePath

Path where the player's data gets saved, if any.

DataNode.SaveType TNet.TcpPlayer.saveType = DataNode.SaveType.Binary

Type of the saved data.

IPEndPoint TNet.TcpPlayer.udpEndPoint

UDP end point if the player has one open.

bool TNet.TcpPlayer.udpIsUsable = false

Whether the UDP has been confirmed as active and usable.

Property Documentation

Channel TNet.TcpPlayer.channel
get

The documentation for this class was generated from the following file: