Fixed compilation issues.

This commit is contained in:
Tristan B. Kildaire 2020-06-17 15:04:29 +02:00
parent d00d4fea19
commit eb88a1a716
3 changed files with 51 additions and 3 deletions

View File

@ -6,9 +6,16 @@ import bmessage;
import std.stdio;
import std.json;
import std.string;
import client.mail;
import server.server;
public final class ButterflyClient : Thread
{
/**
* The associated server
*/
private ButterflyServer server;
/**
* Socket of the client connection
*/
@ -19,10 +26,11 @@ public final class ButterflyClient : Thread
*/
private bool active = true;
this(Socket clientSocket)
this(ButterflyServer server, Socket clientSocket)
{
super(&run);
this.clientSocket = clientSocket;
this.server = server;
}
private void run()
@ -106,4 +114,42 @@ public final class ButterflyClient : Thread
/* Close the socket */
clientSocket.close();
}
/**
* Sends the mail message `mail` to the servers
* listed in the recipients field.
*/
private void sendMail(Mail mail)
{
/* Get a list of the recipients of the mail message */
string[] recipients = mail.getRecipients();
/* Send the mail to each of the recipients */
foreach(string recipient; recipients)
{
writeln("Sending mail message to "~recipient~" ...");
/* Get the mail address */
string[] mailAddress = split(recipient, "@");
/* Get the username */
string username = mailAddress[0];
/* Get the domain */
string domain = mailAddress[1];
/**
* Check if the domain of this recipient is this server
* or if it is a remote server.
*/
if(cmp(domain, ""))
{
}
else
{
}
}
}
}

View File

@ -35,7 +35,6 @@ public final class Mailbox
{
}
}
/**

View File

@ -20,6 +20,9 @@ public final class ButterflyServer
*/
private bool active = true;
/* TODO: Server domain */
private string domain;
this(Address bindAddress)
{
/**
@ -52,7 +55,7 @@ public final class ButterflyServer
* Create a new ButterflyClient to represent the
* client connection.
*/
ButterflyClient client = new ButterflyClient(clientSocket);
ButterflyClient client = new ButterflyClient(this, clientSocket);
/* Start the client thread */
client.start();