Streams data via UDP using map data structure rules
- Subscribe to an pool (map) and start comunicating
- Upserts information from a pool and notifiy the changes to the subscribed clients
- Centralized server architecture
- Lightweightnetworking solution
Subscribe to property changes in the scrit initializatoin...
//Before you send data, connect and join to some pool
void start (){
NetClient.GetPropperty("PLAYER_0_STEER", ((binData) =>{
SetVehicleSteer(binData.TryGetDouble("steer"));
}));
}
//Subscribe to a property change, every time the data is recived the callback function is called
void start (){
NetClient.GetPropperty("PLAYER_0_STEER", ((binData) =>{
SetVehicleSteer(binData.TryGetDouble("steer"));
}));
}
Z Share the corresponding data each 16 ms to the server
public void shareData()
{
NetClient.UppsertProperty('PLAYER_0_STEER', PlayerController.steer());
}
public IEnumerator sendPackets()
{
shareData();
yield return new WaitForSeconds(0.016F);
}
private void Update()
{
StartCoroutine("sendPackets");
}
- Linux and windows for the dedicated server
- Platforms supported by unity for the client
- 3 BYTES MIN
- 256 BYTES MAX
type | byte span |
---|---|
TYPE_CODE (0X09) | 1 byte |
TAG_LENGHT | 1 byte |
CHAR_PAYLOAD | N bytes |
[]
- 2 BYTES WIDE.
type | byte span |
---|---|
TYPE_CODE (0X01) | 1 byte |
ID | 1 byte |
- 3 BYTES MIN
- 512 BYTES MAX
type | byte span |
---|---|
TYPE_CODE (0X02) | 1 byte |
TAG_NAME | N bytes |
STR_LENGHT | 1 byte |
CHAR_PAYLOAD | N bytes |
[0x02,0x04,'s','a','u','l']
- 4 BYTES WIDE
type | byte span |
---|---|
TYPE_CODE(0X03) | 1 byte |
TAG_NAME | N bytes |
| MANTISSA | 23 bits | | EXPONENT | 8 bits | | SIGN | 1 bit |
- 5 BYTES MIN MAX 512 BYTES WIDE
type | byte span |
---|---|
TYPE_CODE(0X04) | 1 byte |
TAG_NAME | N bytes |
| ARRAY_LENGHT | 2 bytes | | ARRAY_TYPE | 1 byte | | ARRAY_PAYLOAD | N bytes |
Array of strings equivalent to
js TEST = ["hello","world]
[0x04,0X01,0X04,'T','E','S','T',0x02,0x05,'h','e','l','l','o',0x05,'w','o','r','l'd']
Array of binary objecst (interpreted by clients):
[0x04,SIZE,0x08,DATA_1_SIZE,DATA_1,DATA_2_SIZE,DATA_2...]
- 2 byte wide
type | byte span |
---|---|
TYPE_CODE(0X05) | 1 byte |
TAG_NAME | N bytes |
VALUE | 1 byte |
- 5 bytes wide
type | byte span |
---|---|
TYPE_CODE(0X06) | 1 byte |
TAG_NAME | N bytes |
| VALUE | 4 byte |
- 5 bytes wide
type | byte span |
---|---|
TYPE_CODE(0X07) | 1 byte |
TAG_NAME | N bytes |
| VALUE | 4 byte |
- MIN 2 bytes
- MAX N bytes wide
type | byte span |
---|---|
TYPE_CODE(0x08) | 1 byte |
TAG_NAME | N bytes |
CODE : 0X01
DESCRIPTION:
SUBSCRIBE {PLAYER_NAME} {PLAYER_ADDRESS} {PORT}
Ej:
[0X02,0X01,STRING,STRING,INT]
RESPONSE:
{STRING:AccessToken,INT:ClientId}
CODE : 0X02
DESCRIPTION:
UNSUSCRBIE {POOL_ID}
ej:
[0X02,0X02,INT]
RESPONSE:
{INT:Status}
CODE : 0X03
DESCRIPTION:
START_POOL {POOL_NAME}
ej:
[0X02,0X03,STRING]
RESPONSE:
{INT:Status}
CODE : 0X04
DESCRIPTION:
END_POOL {INT}
ej:
[0X02,0X04,POOL_ID]
RESPONSE:
{INT:Status}
CODE : 0x05
DESCRIPTION:
UPSERT {INT} {TYPE_HEADER} {DATA}
ej:
[0X02,0X05,ID,TYPE,DATA]
RESPONSE:
CODE : 0x06
DESCRIPTION:
UPSERT {ID}
ej:
[0X02,0X05,INT]
RESPONSE:
{INT:Status}
CODE : 0x08
DESCRIPTION:
SPAWN {PREFAB_ID,FLOAT_VECTOR_3,FLOAT_QUATERNIION}
ej:
[0X02,0X05,INT,OBJECT,OBJECT]
RESPONSE:
{INT:Status}
CODE : 0x9
DESCRIPTION:
GET_ACTIVE_POOLS
ej:
[0X02,0X09]
RESPONSE:
{INT:Status,ARRAY:ActivePools}
SPEC DRAFT 1.0 (NO SECURITY FEATURES)
CODE | NAME | PAYLOAD | RESPONSE | BROADCAST |
---|---|---|---|---|
0x00 | SUBSCRIBE | {PlayerName,HostName,IpAddress,port} | {playerId} | false |
0X01 | UNSUBSCRIBE | {PoolId} | NONE | false |
0X02 | START_POOL | {} | {PoolId} | false |
0X03 | END_POOL | {PoolId} | {Status} | false |
0x04 | UPSERT | {PROPERTY_ID,VALUE} | {propertyName,newValue} | true |
0x05 | REMOVE | {PROPERTY_ID} | {propertyName} | true |
0x06 | SPAWN | {PREFAB_NAME,TRANSFORM} | {propertyName} | true |
0X07 | GET_ACTIVE_POOLS | {} | {pools[]} | false |
https://docs.microsoft.com/en-us/dotnet/api/system.bitconverter?view=net-5.0