Legacy:SessionMaster - Unreal Wiki

# Legacy:SessionMaster

### From Unreal Wiki, The Unreal Engine Documentation Site

UT2003 :: Object >> SessionMaster (Ladder1.46)

1. //-----------------------------------------------------------
2. // Ladder.SessionMaster
3. // Sessions concept by El_Muerte[TDS]
4. // http://wiki.beyondunreal.com/wiki/Sessions
5. //
6. // Controls and tracks all Session objects for use by webadmin
7. //-----------------------------------------------------------
8. class SessionMaster extends Object transient;
10. var array<Session> Sessions;
12. // get a session by it's hash
13. function Session getSession(string hash, optional bool bCreateNew)
14. {
15. local int i;
17. for (i = 0; i < sessions.length; i++) if (Sessions[i].GetHash() == hash) return Sessions[i];
18. if (bCreateNew) return createSession();
19. return none;
20. }
22. // destroy an existing session
23. function bool destroySession(Session session)
24. {
25. local int i;
26. local string Hash;
28. Hash = Session.GetHash();
29. for (i = 0; i < sessions.length; i++)
30. if (Sessions[i].GetHash() == Hash)
31. {
33. Sessions.Remove(i, 1);
34. return true;
35. }
37. return false;
38. }
40. // create a new session
41. private function Session createSession()
42. {
43. local Session TempS;
45. TempS = new class'Session';
46. if (TempS.SetHash(CreateSessionHash())) Sessions[Sessions.Length] = TempS;
48. return TempS;
49. }
51. // create a unique session hash
52. function string createSessionHash()
53. {
54. local int i;
55. local string temphash;
57. do {
58. temphash = Right("00000"$string(Rand(65536)), 5)$Right("00000"$string(Rand(65536)), 5);
59. for (i = 0; i < sessions.length; i++)
60. if (Sessions[i].GetHash() == temphash) break;
61. } until (i == sessions.length);
62. return temphash;
63. }

##### Views

- Legacy
- Discussion
- Current revision

##### Search