Compare commits

...

7 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire cc74e1a975 Merge branch 'master' into feature/auth 2023-11-26 14:16:50 +02:00
Tristan B. Velloza Kildaire 313ff9b557 Connection
- Removed now-completed TODO
- Use a boolean to supress unreachable errors
- Added a TODO to implement the above
- On exiting loop call the `Server`'s `onConnectionDisconnect(Connection)` method
2023-11-26 14:15:59 +02:00
Tristan B. Velloza Kildaire 416d583658 Connection
- Added TODO (backported)
2023-11-26 14:13:12 +02:00
Tristan B. Velloza Kildaire 145ebf32f8 Connection
- Removed TODO
2023-11-26 14:12:52 +02:00
Tristan B. Velloza Kildaire d44cc03437 Server
- Added initial implementation of `onConnectionDisconnect(Connection connection)`
2023-11-26 14:12:04 +02:00
Tristan B. Velloza Kildaire bbcf9b1413 LinkType
- Added first member (so `LinkType.init`) `UNSET`

Connection

- Added `linkType` and getter
2023-11-26 14:09:25 +02:00
Tristan B. Velloza Kildaire 8df9c09f43 LinkType
- Added new enum
- With members `USER` and `SERVER`
2023-11-26 14:08:05 +02:00
2 changed files with 51 additions and 3 deletions

View File

@ -20,6 +20,13 @@ import renaissance.server.channelmanager : ChannelManager, Channel;
import std.conv : to;
public enum LinkType
{
UNSET,
USER,
SERVER
}
public class Connection : Thread
{
/**
@ -37,6 +44,12 @@ public class Connection : Thread
private Manager tManager;
private Queue incomingQueue;
/**
* Whether this is a user connection
* or a server link
*/
private LinkType linkType;
private this(Server associatedServer, Stream clientStream)
{
this.associatedServer = associatedServer;
@ -66,6 +79,11 @@ public class Connection : Thread
this.tManager.setDefaultQueue(this.incomingQueue);
}
public LinkType getLinkType()
{
return this.linkType;
}
private void worker()
{
// TODO: Start tristanable manager here
@ -78,8 +96,9 @@ public class Connection : Thread
// TODO: Well, we'd tasky I guess so I'd need to use it there I guess
// TODO: Add worker function here
while(true)
// TODO: Imp,ent nthe loop condition status (exit on error)
bool isGood = true;
while(isGood)
{
// TODO: Addn a tasky/tristanable queue managing thing with
// ... socket here (probably just the latter)
@ -112,7 +131,11 @@ public class Connection : Thread
}
}
// TODO: Call cleanup+notify server
// Clean up (TODO: Shutdown the TManager)
// Clean up - notify disconnection
this.associatedServer.onConnectionDisconnect(this);
}
// FIXME: These should be part of the auth details

View File

@ -370,6 +370,31 @@ public class Server : MessageDeliveryTransport
return true;
}
// On connection disconnecting
public void onConnectionDisconnect(Connection connection)
{
// TODO: Decide whether it is a user link or a server de-link
import renaissance.connection.connection : LinkType;
LinkType type = connection.getLinkType();
logger.dbg("Disconnecting link ", connection, " of type ", type);
switch(type)
{
case LinkType.UNSET:
logger.warn("Not doing anything because this link's type was never set");
break;
case LinkType.USER:
// TODO: Implement me
break;
case LinkType.SERVER:
// TODO: Implement me
break;
default:
break;
}
}
}
version(unittest)