Hey again
I don’t have a problem accessing the session variables in the services, but I have some classes outside of the services that needs to access the session variables.
From there I’m trying to get current sessions from the memorysessionmanager. As I wrote above I’m trying to find a session that has Session[“Login”] similar to a username i’m getting from an .xml
The problem with this is that, even though the clients catch OnLoginNeeded and logs in, saves variables to session and all, the session doesn’t appear on the memorysessionmanagers list untill the clients have made a second call to a method in a service.
I have since tried this code in a SessionService:
public virtual Guid[] GetAllSessionIDs()
{
Guid[] result;
result = new Guid[SessionManager.GetAllSessions().Count];
SessionManager.GetAllSessions().CopyTo(result, 0);
return result;
}
And I’ve tried these two versions on the server (not in a service):
private void GetAllSessions_Click(object sender, EventArgs e)
{
string output = "";
var sessionService = CoSessionService.Create(message, new IpSuperHttpClientChannel() { TargetUrl = "superhttp://10.78.20.15:80/bin" } );
foreach (var sessionID in sessionService.GetAllSessionIDs())
{
output += sessionID.ToString() + "\n";
}
MessageBox.Show(output);
}
private void GetAllSessions_Click(object sender, EventArgs e)
{
string output = "";
using (var sessionService = new SessionService())
{
foreach (var sessionID in sessionService.GetAllSessionIDs())
{
output += sessionID.ToString() + "\n";
if (sessionID != null)
{
var session = sessionService.GetSession(sessionID);
var sessionNames = session.Names;
for (int i = 0; i < sessionNames.Count; i++)
{
output += sessionNames[i] + "\n";
output += session[sessionNames[i]] + "\n\n";
}
output += session.SessionEmployee.Name;
output += session.SessionDevice.GUID;
}
}
}
MessageBox.Show(output);
}
The first one gives “session could not be found” (the targeturl points back at the server’s own ip), and the second one just gives a blank list (i’m assuming because i’m starting a new SessionService, with new empty sessionmanager and all…)
By the way, how can i format my code like yours?