mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 09:43:37 +02:00
Updated dependancies
This commit is contained in:
parent
9ad7a4b313
commit
8890cd3e79
3
dub.json
3
dub.json
@ -3,6 +3,9 @@
|
|||||||
"Tristan B. Kildaire"
|
"Tristan B. Kildaire"
|
||||||
],
|
],
|
||||||
"copyright": "Copyright © 2020, Tristan B. Kildaire",
|
"copyright": "Copyright © 2020, Tristan B. Kildaire",
|
||||||
|
"dependencies": {
|
||||||
|
"tristanable": "~>0.0.27"
|
||||||
|
},
|
||||||
"description": "dnet server",
|
"description": "dnet server",
|
||||||
"license": "AGPLv3",
|
"license": "AGPLv3",
|
||||||
"name": "dnet"
|
"name": "dnet"
|
||||||
|
7
dub.selections.json
Normal file
7
dub.selections.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"fileVersion": 1,
|
||||||
|
"versions": {
|
||||||
|
"bformat": "1.0.8",
|
||||||
|
"tristanable": "0.0.27"
|
||||||
|
}
|
||||||
|
}
|
@ -12,11 +12,20 @@ module dnetd.dconnection;
|
|||||||
|
|
||||||
import core.thread : Thread;
|
import core.thread : Thread;
|
||||||
import std.socket : Socket;
|
import std.socket : Socket;
|
||||||
|
import bmessage;
|
||||||
|
import tristanable.encoding : DataMessage;
|
||||||
|
|
||||||
|
|
||||||
public class DConnection : Thread
|
public class DConnection : Thread
|
||||||
{
|
{
|
||||||
/* The client's socket */
|
/**
|
||||||
|
* Connection information
|
||||||
|
*/
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
private bool hasAuthed;
|
||||||
|
|
||||||
|
/* Reserved tag for push notifications */
|
||||||
|
private long notificationTag = 0;
|
||||||
|
|
||||||
this(Socket socket)
|
this(Socket socket)
|
||||||
{
|
{
|
||||||
@ -26,18 +35,77 @@ public class DConnection : Thread
|
|||||||
/* Set the socket */
|
/* Set the socket */
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
|
|
||||||
|
/* Initialize the tagging facility */
|
||||||
|
initTagger();
|
||||||
|
|
||||||
/* Start the connection handler */
|
/* Start the connection handler */
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes tristanable
|
||||||
|
* TODO: Implemet me (also tristanable needs reserved tags first)
|
||||||
|
*/
|
||||||
|
private void initTagger()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Byte dequeue loop
|
* Byte dequeue loop
|
||||||
*/
|
*/
|
||||||
private void worker()
|
private void worker()
|
||||||
{
|
{
|
||||||
|
/* Received bytes (for bformat) */
|
||||||
|
byte[] receivedBytes;
|
||||||
|
|
||||||
|
/* Received message */
|
||||||
|
DataMessage receivedMessage;
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Block to receive a bformat message
|
||||||
|
*
|
||||||
|
* (Does decoding for bformat too)
|
||||||
|
*/
|
||||||
|
bool status = receiveMessage(socket, receivedBytes);
|
||||||
|
|
||||||
|
/* TODO: Check status */
|
||||||
|
|
||||||
|
/* Decode the tristanable message (tagged message) */
|
||||||
|
receivedMessage = DataMessage.decode(receivedBytes);
|
||||||
|
|
||||||
|
/* TODO: Tristanable needs reserved-tag support (client-side concern) */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the received message
|
||||||
|
*/
|
||||||
|
private void process(DataMessage message)
|
||||||
|
{
|
||||||
|
/* Get the command byte */
|
||||||
|
byte commandByte = message.data[0];
|
||||||
|
|
||||||
|
/* If `auth` command */
|
||||||
|
if(commandByte == 0 && !hasAuthed)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* If `link` command */
|
||||||
|
else if(commandByte == 1 && !hasAuthed)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* TODO: Handle this case */
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user