C# 클래스 GarrysModLuaShared.net

The net library is one of a number of ways to send data between the client and server. The major advantages of the net library are the large size limit(64kb/message) and the ability to send data backwards - from the client to the server.
파일 보기 프로젝트 열기: OmegaExtern/gmod-csharp-binary-module

공개 메소드들

메소드 설명
Broadcast ( LuaState luaState ) : void

Sends the currently built net message to all connected players.

BytesWritten ( LuaState luaState ) : double

Returns the size of the current message in bytes.

ReadBit ( LuaState luaState ) : double

Reads a bit from the received net message. Warning! You must read information in same order as you write it.

ReadBool ( LuaState luaState ) : bool

Reads a boolean from the received net message. Warning! You must read information in same order as you write it.

ReadData ( LuaState luaState, double length ) : string

Reads pure binary data from the message. Warning! You must read information in same order as you write it.

ReadDouble ( LuaState luaState ) : double

Reads a double-precision number from the received net message. Warning! You must read information in same order as you write it.

ReadFloat ( LuaState luaState ) : float

Reads a floating-point number from the received net message. Warning! You must read information in same order as you write it.

ReadHeader ( LuaState luaState ) : double

Returns the "header" of the message which contains a short which can be converted to the corresponding message name via util.NetworkIDToString.

ReadInt ( LuaState luaState, double bitCount = 32.0D ) : int

Reads an integer from the received net message. Warning! You must read information in same order as you write it.

ReadString ( LuaState luaState ) : string

Reads a null terminated string from the net stream. The size of the string is 8 bits plus 8 bits for every ASCII character in the string. Warning! You must read information in same order as you write it.

ReadUInt ( LuaState luaState, double bitCount = 32.0D ) : uint

Reads an unsigned integer with the specified number of bits from the received net message. Warning! You must read information in same order as you write it.

SendToServer ( LuaState luaState ) : void

Sends the current message to the server.

Start ( LuaState luaState, string messageName, bool unreliable = false ) : bool

Begins a new net message. Don't forget to pool the messageName with util.AddNetworkString!

WriteBit ( LuaState luaState, bool boolean ) : void

Appends a boolean (as 0 or 1) to the current net message.

WriteData ( LuaState luaState, string binaryData, double length ) : void

Writes a chunk of binary data to the message.

WriteDouble ( LuaState luaState, double @double ) : void

Appends a double-precision number to the current net message.

WriteFloat ( LuaState luaState, float @float ) : void

Appends a float (number with decimals) to the current net message.

WriteInt ( LuaState luaState, int integer, double bitCount = 32.0D ) : void

Appends an integer (number without decimals) to the current net message.

WriteString ( LuaState luaState, string @string ) : void

Appends a string to the current net message. The size of the string is 8 bits plus 8 bits for every ASCII character in the string. The maximum allowed length of a single written string is 1024 characters.

WriteUInt ( LuaState luaState, uint unsignedInteger, double numberOfBits = 32.0D ) : void

Appends an unsigned integer with the specified number of bits to the current net message.

메소드 상세

Broadcast() 공개 정적인 메소드

Sends the currently built net message to all connected players.
public static Broadcast ( LuaState luaState ) : void
luaState LuaState Pointer to lua_State struct.
리턴 void

BytesWritten() 공개 정적인 메소드

Returns the size of the current message in bytes.
public static BytesWritten ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
리턴 double

ReadBit() 공개 정적인 메소드

Reads a bit from the received net message. Warning! You must read information in same order as you write it.
public static ReadBit ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
리턴 double

ReadBool() 공개 정적인 메소드

Reads a boolean from the received net message. Warning! You must read information in same order as you write it.
public static ReadBool ( LuaState luaState ) : bool
luaState LuaState Pointer to lua_State struct.
리턴 bool

ReadData() 공개 정적인 메소드

Reads pure binary data from the message. Warning! You must read information in same order as you write it.
public static ReadData ( LuaState luaState, double length ) : string
luaState LuaState Pointer to lua_State struct.
length double /// The length of the data to be read, in bytes. /// /// When this is 0, does not return an empty string as you would expect, but random junk /// instead. ///
리턴 string

ReadDouble() 공개 정적인 메소드

Reads a double-precision number from the received net message. Warning! You must read information in same order as you write it.
public static ReadDouble ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
리턴 double

ReadFloat() 공개 정적인 메소드

Reads a floating-point number from the received net message. Warning! You must read information in same order as you write it.
public static ReadFloat ( LuaState luaState ) : float
luaState LuaState Pointer to lua_State struct.
리턴 float

ReadHeader() 공개 정적인 메소드

Returns the "header" of the message which contains a short which can be converted to the corresponding message name via util.NetworkIDToString.
public static ReadHeader ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
리턴 double

ReadInt() 공개 정적인 메소드

Reads an integer from the received net message. Warning! You must read information in same order as you write it.
public static ReadInt ( LuaState luaState, double bitCount = 32.0D ) : int
luaState LuaState Pointer to lua_State struct.
bitCount double The amount of bits to be read.
리턴 int

ReadString() 공개 정적인 메소드

Reads a null terminated string from the net stream. The size of the string is 8 bits plus 8 bits for every ASCII character in the string. Warning! You must read information in same order as you write it.
public static ReadString ( LuaState luaState ) : string
luaState LuaState Pointer to lua_State struct.
리턴 string

ReadUInt() 공개 정적인 메소드

Reads an unsigned integer with the specified number of bits from the received net message. Warning! You must read information in same order as you write it.
public static ReadUInt ( LuaState luaState, double bitCount = 32.0D ) : uint
luaState LuaState Pointer to lua_State struct.
bitCount double The size of the integer to be read, in bits.
리턴 uint

SendToServer() 공개 정적인 메소드

Sends the current message to the server.
public static SendToServer ( LuaState luaState ) : void
luaState LuaState Pointer to lua_State struct.
리턴 void

Start() 공개 정적인 메소드

Begins a new net message. Don't forget to pool the messageName with util.AddNetworkString!
public static Start ( LuaState luaState, string messageName, bool unreliable = false ) : bool
luaState LuaState Pointer to lua_State struct.
messageName string The name of the message to send.
unreliable bool If set to true, the message is not guaranteed to reach its destination.
리턴 bool

WriteBit() 공개 정적인 메소드

Appends a boolean (as 0 or 1) to the current net message.
public static WriteBit ( LuaState luaState, bool boolean ) : void
luaState LuaState Pointer to lua_State struct.
boolean bool Bit status (false = 0, true = 1) to be sent.
리턴 void

WriteData() 공개 정적인 메소드

Writes a chunk of binary data to the message.
public static WriteData ( LuaState luaState, string binaryData, double length ) : void
luaState LuaState Pointer to lua_State struct.
binaryData string The binary data to be sent.
length double The length of the binary data to be sent, in bytes.
리턴 void

WriteDouble() 공개 정적인 메소드

Appends a double-precision number to the current net message.
public static WriteDouble ( LuaState luaState, double @double ) : void
luaState LuaState Pointer to lua_State struct.
@double double
리턴 void

WriteFloat() 공개 정적인 메소드

Appends a float (number with decimals) to the current net message.
public static WriteFloat ( LuaState luaState, float @float ) : void
luaState LuaState Pointer to lua_State struct.
@float float
리턴 void

WriteInt() 공개 정적인 메소드

Appends an integer (number without decimals) to the current net message.
public static WriteInt ( LuaState luaState, int integer, double bitCount = 32.0D ) : void
luaState LuaState Pointer to lua_State struct.
integer int The integer to be sent.
bitCount double /// The amount of bits the number consists of. (signed) /// /// This must be 32 or less. If you are unsure what to set, just set it to 32. /// /// To determine just how many bits exactly you're going to need for your integer, you first need to understand what /// those bits actually are. A bit can have two possible states: 0 and 1. For every bit you add, you get an /// exponentially increasing amount of possible combinations. 2 bits allow for 2^2 = 4 possible combinations (namely /// 00, 01, 10 and 11), 3 bits allow for 2^3 = 8 possible combinations, 4 bits allow for 2^4 = 16 possible combinations /// and so on. Since we start counting from 0, a 4-bit integer would thus be able to represent any integer number /// between 0 and 15. /// /// Do note that Garry's Mod is using the first bit for purposes other than storing your integer's value. Just figure /// out how many bits you'd normally need, then increase that number by one (so if you want to send an integer that may /// assume any number between 0 and 15, you don't use a 4 as your bitCount but rather a 5). /// /// Consult this table for a /// quick reference on how many bits you need for a given value. ///
리턴 void

WriteString() 공개 정적인 메소드

Appends a string to the current net message. The size of the string is 8 bits plus 8 bits for every ASCII character in the string. The maximum allowed length of a single written string is 1024 characters.
public static WriteString ( LuaState luaState, string @string ) : void
luaState LuaState Pointer to lua_State struct.
@string string
리턴 void

WriteUInt() 공개 정적인 메소드

Appends an unsigned integer with the specified number of bits to the current net message.
public static WriteUInt ( LuaState luaState, uint unsignedInteger, double numberOfBits = 32.0D ) : void
luaState LuaState Pointer to lua_State struct.
unsignedInteger uint The unsigned integer to be sent.
numberOfBits double /// The size of the integer to be sent, in bits. Acceptable values range from 1 to 32. 1 = bit, /// 4 = nibble, 8 = byte, 16 = short, 32 = long. ///
리턴 void