Refactored ProtocolBuffers into their own modules

This commit is contained in:
Tristan B. Velloza Kildaire 2021-08-27 15:27:20 +02:00
parent 66e2a5cde2
commit 75394c6da6
15 changed files with 250 additions and 163 deletions

View File

@ -12,6 +12,7 @@
"name": "libdnet",
"targetPath": "bin",
"targetType": "library",
"preBuildCommands": ["protoc --plugin=\"$HOME/.dub/packages/protobuf-0.6.2/protobuf/protoc_gen_d/../build/protoc-gen-d\" source/libdnet/protobuf/core.proto --d_out=source/libdnet/protobuf/."
"preBuildCommands": ["protoc --plugin=\"$HOME/.dub/packages/protobuf-0.6.2/protobuf/protoc_gen_d/../build/protoc-gen-d\" source/libdnet/protobuf/dnet.proto --d_out=source/libdnet/protobuf/."
]
}

View File

@ -1,4 +1,4 @@
module libdnet.client;
module libdnet.api.client;
import tristanable.manager : Manager;
import tristanable.queue : Queue;

View File

@ -1,4 +1,4 @@
module libdnet.exceptions;
module libdnet.api.exceptions;
public class DClientException : Exception
{

View File

@ -0,0 +1,26 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: source/libdnet/protobuf/account.proto
module account;
import google.protobuf;
enum protocVersion = 3014000;
class AccountMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) string name = protoDefaultValue!string;
@Proto(3) bytes additionalData = protoDefaultValue!bytes;
enum MessageType
{
AUTH = 0,
REGISTRATION = 1,
DEREG = 2,
GET_PROFILE_PROPS = 3,
SET_PROFILE_PROP = 4,
GET_PROFILE_PROP = 5,
LOGOUT = 6,
}
}

View File

@ -0,0 +1,29 @@
syntax="proto3";
// AccountMessage
//
// These represents account control messages for things
// such as account management, authentication, profile
// manipulation etc.
message AccountMessage
{
enum MessageType
{
AUTH = 0;
REGISTRATION = 1;
DEREG = 2;
GET_PROFILE_PROPS = 3;
SET_PROFILE_PROP = 4;
GET_PROFILE_PROP = 5;
LOGOUT = 6;
}
// The type of the account command
MessageType type = 1;
// The user to which the command applies
string name = 2;
// Additional data (dependent on command)
bytes additionalData = 3;
}

View File

@ -0,0 +1,28 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: source/libdnet/protobuf/channel.proto
module channel;
import google.protobuf;
enum protocVersion = 3014000;
class ChannelMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) string name = protoDefaultValue!string;
@Proto(3) bytes additionalData = protoDefaultValue!bytes;
enum MessageType
{
CREATE = 0,
DESTROY = 1,
JOIN = 2,
LEAVE = 3,
SET_PROP = 4,
GET_PROPS = 5,
GET_MEMBERS = 6,
GET_PROP = 7,
NEW_MESSAGE_ALERT = 8,
}
}

View File

@ -0,0 +1,29 @@
syntax="proto3";
// ChannelMessage
//
// These represent channel commands
message ChannelMessage
{
enum MessageType
{
CREATE = 0;
DESTROY = 1;
JOIN = 2;
LEAVE = 3;
SET_PROP = 4;
GET_PROPS = 5;
GET_MEMBERS = 6;
GET_PROP = 7;
NEW_MESSAGE_ALERT = 8;
}
// The type of channel command
MessageType type = 1;
// The channel to which the command applies
string name = 2;
// Additional data (dependent on command)
bytes additionalData = 3;
}

View File

@ -1,65 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: source/libdnet/protobuf/core.proto
module core;
import google.protobuf;
enum protocVersion = 3014000;
class DNETMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) bytes content = protoDefaultValue!bytes;
enum MessageType
{
ACCOUNT = 0,
CHANNEL = 1,
SERVER = 2,
}
}
class AccountMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) string name = protoDefaultValue!string;
@Proto(3) bytes additionalData = protoDefaultValue!bytes;
enum MessageType
{
AUTH = 0,
REGISTRATION = 1,
DEREG = 2,
GET_PROFILE_PROPS = 3,
SET_PROFILE_PROP = 4,
GET_PROFILE_PROP = 5,
LOGOUT = 6,
}
}
class ChannelMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) string name = protoDefaultValue!string;
@Proto(3) bytes additionalData = protoDefaultValue!bytes;
enum MessageType
{
CREATE = 0,
DESTROY = 1,
JOIN = 2,
LEAVE = 3,
SET_PROP = 4,
GET_PROPS = 5,
GET_MEMBERS = 6,
GET_PROP = 7,
NEW_MESSAGE_ALERT = 8,
}
}
class Property
{
@Proto(1) string name = protoDefaultValue!string;
@Proto(2) bytes data = protoDefaultValue!bytes;
}

View File

@ -1,95 +0,0 @@
syntax="proto3";
//DNETMessage
//
//This is the container for all message types
message DNETMessage
{
enum MessageType
{
// For all AccountMessage messages
ACCOUNT = 0;
// For all ChannelMessage messages
CHANNEL = 1;
// For all ServerMessage messages
SERVER = 2;
}
// Type of message
MessageType type = 1;
// Message contents
bytes content = 2;
}
// AccountMessage
//
// These represents account control messages for things
// such as account management, authentication, profile
// manipulation etc.
message AccountMessage
{
enum MessageType
{
AUTH = 0;
REGISTRATION = 1;
DEREG = 2;
GET_PROFILE_PROPS = 3;
SET_PROFILE_PROP = 4;
GET_PROFILE_PROP = 5;
LOGOUT = 6;
}
// The type of the account command
MessageType type = 1;
// The user to which the command applies
string name = 2;
// Additional data (dependent on command)
bytes additionalData = 3;
}
// ChannelMessage
//
// These represent channel commands
message ChannelMessage
{
enum MessageType
{
CREATE = 0;
DESTROY = 1;
JOIN = 2;
LEAVE = 3;
SET_PROP = 4;
GET_PROPS = 5;
GET_MEMBERS = 6;
GET_PROP = 7;
NEW_MESSAGE_ALERT = 8;
}
// The type of channel command
MessageType type = 1;
// The channel to which the command applies
string name = 2;
// Additional data (dependent on command)
bytes additionalData = 3;
}
// Channel/User Property
//
// Represents a channel/user property which is a mapping
// of a key to a value (bytes) of which its interpretation
// is solely up to the user
message Property
{
// Property's name
string name = 1;
// The property's data
bytes data = 2;
}

View File

@ -0,0 +1,25 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: source/libdnet/protobuf/dnet.proto
module dnet;
import google.protobuf;
import source.libdnet.protobuf.account;
import source.libdnet.protobuf.channel;
import source.libdnet.protobuf.server;
import source.libdnet.protobuf.property;
enum protocVersion = 3014000;
class DNETMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) bytes content = protoDefaultValue!bytes;
enum MessageType
{
ACCOUNT = 0,
CHANNEL = 1,
SERVER = 2,
}
}

View File

@ -0,0 +1,33 @@
syntax="proto3";
import "source/libdnet/protobuf/account.proto";
import "source/libdnet/protobuf/channel.proto";
import "source/libdnet/protobuf/server.proto";
import "source/libdnet/protobuf/property.proto";
// DNETMessage
//
// This is the container for all message types
message DNETMessage
{
enum MessageType
{
// For all AccountMessage messages
ACCOUNT = 0;
// For all ChannelMessage messages
CHANNEL = 1;
// For all ServerMessage messages
SERVER = 2;
}
// Type of message
MessageType type = 1;
// Message contents
bytes content = 2;
}

View File

@ -0,0 +1,14 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: source/libdnet/protobuf/property.proto
module property;
import google.protobuf;
enum protocVersion = 3014000;
class Property
{
@Proto(1) string name = protoDefaultValue!string;
@Proto(2) bytes data = protoDefaultValue!bytes;
}

View File

@ -0,0 +1,15 @@
syntax="proto3";
// Channel/User Property
//
// Represents a channel/user property which is a mapping
// of a key to a value (bytes) of which its interpretation
// is solely up to the user
message Property
{
// Property's name
string name = 1;
// The property's data
bytes data = 2;
}

View File

@ -0,0 +1,22 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: source/libdnet/protobuf/server.proto
module server;
import google.protobuf;
enum protocVersion = 3014000;
class ServerMessage
{
@Proto(1) MessageType type = protoDefaultValue!MessageType;
@Proto(2) bytes additionalData = protoDefaultValue!bytes;
enum MessageType
{
LIST_CHANNELS = 0,
LIST_USERS = 1,
GET_SERVER_PROPS = 2,
GET_SERVER_PROP = 3,
}
}

View File

@ -0,0 +1,25 @@
syntax="proto3";
// ServerMessage
//
// These represent things that control the server
// such as listing all channels, getting server
// properties etc.
//
// This is also used for server-to-server communications
message ServerMessage
{
enum MessageType
{
LIST_CHANNELS = 0;
LIST_USERS = 1;
GET_SERVER_PROPS = 2;
GET_SERVER_PROP = 3;
}
// The type of the server command
MessageType type = 1;
// Additional data (dependent on command)
bytes additionalData = 2;
}