mirror of https://github.com/deavminet/libdnet.git
Added some message types, removed protocolbuffer dependency and added msgpack dependency
This commit is contained in:
parent
7d096ce8f2
commit
1cf64931ff
5
dub.json
5
dub.json
|
@ -3,8 +3,11 @@
|
||||||
"Tristan B. Kildaire"
|
"Tristan B. Kildaire"
|
||||||
],
|
],
|
||||||
"copyright": "Copyright © 2021, Tristan B. Kildaire",
|
"copyright": "Copyright © 2021, Tristan B. Kildaire",
|
||||||
|
"dependencies": {
|
||||||
|
"msgpack-d": "~>1.0.3"
|
||||||
|
},
|
||||||
"description": "Client-side DNET API",
|
"description": "Client-side DNET API",
|
||||||
"license": "LGPLv2",
|
"license": "LGPLv2",
|
||||||
"name": "libdnet",
|
"name": "libdnet",
|
||||||
"targetType": "library"
|
"targetType": "library"
|
||||||
}
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* Type declarations
|
||||||
|
*/
|
||||||
|
module libdnet.types;
|
||||||
|
|
||||||
|
import msgpack;
|
||||||
|
|
||||||
|
/* TODO: Add structs here */
|
||||||
|
|
||||||
|
|
||||||
|
public enum HeaderType
|
||||||
|
{
|
||||||
|
CLIENT,
|
||||||
|
SERVER
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Header format
|
||||||
|
*
|
||||||
|
* [ messageType | payload ]
|
||||||
|
*/
|
||||||
|
struct Header
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type of message
|
||||||
|
*
|
||||||
|
* How the `payload` should be
|
||||||
|
* interpreted
|
||||||
|
*/
|
||||||
|
HeaderType type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data of the message
|
||||||
|
*/
|
||||||
|
ubyte[] payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server message
|
||||||
|
*
|
||||||
|
* TODO: Describe message
|
||||||
|
*/
|
||||||
|
struct ServerMessage
|
||||||
|
{
|
||||||
|
/* TODO: Populate */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClientType
|
||||||
|
*
|
||||||
|
* The type of ClientMessage
|
||||||
|
*/
|
||||||
|
public enum ClientType
|
||||||
|
{
|
||||||
|
AUTH
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client message
|
||||||
|
*
|
||||||
|
* TODO: Describe message
|
||||||
|
*/
|
||||||
|
struct ClientMessage
|
||||||
|
{
|
||||||
|
/* TODO: Populate */
|
||||||
|
ClientType type;
|
||||||
|
|
||||||
|
ubyte[] payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AuthenticateMessage
|
||||||
|
{
|
||||||
|
string username;
|
||||||
|
string password;
|
||||||
|
}
|
Loading…
Reference in New Issue