| Home Page | Recent Changes | Preferences

SessionMaster

UT2003 :: Object >> SessionMaster (Ladder1.46)
00001  //-----------------------------------------------------------
00002  // Ladder.SessionMaster
00003  // Sessions concept by El_Muerte[TDS]
00004  // http://wiki.beyondunreal.com/wiki/Sessions
00005  //
00006  // Controls and tracks all Session objects for use by webadmin
00007  //-----------------------------------------------------------
00008  class SessionMaster extends Object transient;
00009  
00010  var array<Session> Sessions;
00011  
00012  // get a session by it's hash
00013  function Session getSession(string hash, optional bool bCreateNew)
00014  {
00015      local int i;
00016  
00017      for (i = 0; i < sessions.length; i++) if (Sessions[i].GetHash() == hash) return Sessions[i];
00018      if (bCreateNew) return createSession();
00019      return none;
00020  }
00021  
00022  // destroy an existing session
00023  function bool destroySession(Session session)
00024  {
00025      local int i;
00026      local string Hash;
00027  
00028      Hash = Session.GetHash();
00029      for (i = 0; i < sessions.length; i++)
00030          if (Sessions[i].GetHash() == Hash)
00031          {
00032  
00033              Sessions.Remove(i, 1);
00034              return true;
00035          }
00036  
00037      return false;
00038  }
00039  
00040  // create a new session
00041  private function Session createSession()
00042  {
00043      local Session TempS;
00044  
00045      TempS = new class'Session';
00046      if (TempS.SetHash(CreateSessionHash())) Sessions[Sessions.Length] = TempS;
00047  
00048      return TempS;
00049  }
00050  
00051  // create a unique session hash
00052  function string createSessionHash()
00053  {
00054      local int i;
00055      local string temphash;
00056  
00057      do {
00058          temphash = Right("00000"$string(Rand(65536)), 5)$Right("00000"$string(Rand(65536)), 5);
00059          for (i = 0; i < sessions.length; i++)
00060              if (Sessions[i].GetHash() == temphash) break;
00061      } until (i == sessions.length);
00062    return temphash;
00063  }

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In