Compare commits
4 Commits
f578c5a00d
...
0ff10c3e47
Author | SHA1 | Date |
---|---|---|
Tristan B. Velloza Kildaire | 0ff10c3e47 | |
Tristan B. Velloza Kildaire | 398dae480b | |
Tristan B. Velloza Kildaire | 2b95cc3410 | |
Tristan B. Velloza Kildaire | 6841da02ea |
|
@ -111,6 +111,8 @@ public class Connection : Thread
|
|||
logger.dbg("There was no response, not sending anything.");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Call cleanup+notify server
|
||||
}
|
||||
|
||||
// FIXME: These should be part of the auth details
|
||||
|
@ -396,9 +398,9 @@ public class Connection : Thread
|
|||
import renaissance.server.messagemanager : Message;
|
||||
public bool incomingMessage(Message message)
|
||||
{
|
||||
// TODO: Implement message
|
||||
logger.info("Delivering message '", message, "' to this link (", this, ")");
|
||||
|
||||
// TODO: Implement message
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import renaissance.connection.connection : Connection;
|
|||
import renaissance.server.users : User;
|
||||
import core.sync.mutex : Mutex;
|
||||
import renaissance.logging;
|
||||
|
||||
import std.conv : to;
|
||||
|
||||
// TODO: One of these should be opened as soon as auth is
|
||||
// ... done and stored in server so as to be able to map to it
|
||||
|
@ -87,6 +87,22 @@ public struct Session
|
|||
|
||||
return this.links.dup;
|
||||
}
|
||||
|
||||
public string toString()
|
||||
{
|
||||
// Lock the session
|
||||
this.lock.lock();
|
||||
|
||||
// On exit
|
||||
scope(exit)
|
||||
{
|
||||
// Unlock the session
|
||||
this.lock.unlock();
|
||||
}
|
||||
|
||||
// TODO: Use getLinks() rather and getUser() (both should be MT sfae, make the latter exist+MTSafe)
|
||||
return "Session [user: "~to!(string)(this.user)~", links: "~to!(string)(this.links.length)~"]";
|
||||
}
|
||||
}
|
||||
|
||||
public class SessionManager
|
||||
|
|
|
@ -342,16 +342,27 @@ public class Server : MessageDeliveryTransport
|
|||
// Obtain the session of the destination user
|
||||
Session* toSession = this.sessionManager.getSession(curDest);
|
||||
|
||||
// TODO: Handle case where user is offline (no Connection[]s)
|
||||
// ... the message manager must do this if false is returned
|
||||
foreach(Connection toLink; toSession.getLinks())
|
||||
// If such a session exists (TODO (Case?): In case all links went off line? - not yet implemented)
|
||||
if(toSession != null)
|
||||
{
|
||||
logger.dbg("Delivering message '", latest, "' to link ", toLink, " of user '", curDest, "'");
|
||||
if(!toLink.incomingMessage(latest))
|
||||
logger.dbg("Mapped user ", *curDest, " to session ", *toSession);
|
||||
|
||||
// TODO: Handle case where user is offline (no Connection[]s)
|
||||
// ... the message manager must do this if false is returned
|
||||
foreach(Connection toLink; toSession.getLinks())
|
||||
{
|
||||
// TODO: Handle failed message?
|
||||
logger.dbg("Delivering message '", latest, "' to link ", toLink, " of user '", curDest, "'");
|
||||
if(!toLink.incomingMessage(latest))
|
||||
{
|
||||
// TODO: Handle failed message?
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the suer could not be mapped to a session
|
||||
else
|
||||
{
|
||||
logger.error("Could not map user ", *curDest, " to a session");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue