namespace soholife { using system; using system.data; using system.data.sqlclient; using system.collections ; using system.threading ; using system.web; using system.diagnostics;
//定義了一個結構 public struct user { public string name; public datetime lasttime; public datetime curtime; public string sessionid; public string iswhere; }
//定義在線用戶類 public class onlineuser { private static arraylist _alluser ; //定義用戶
public arraylist alluser { get{return _alluser;} set{_alluser=value;} }
public onlineuser() //構造函數 { if(_alluser==null) { _alluser=new arraylist(); } }
//功能說明:將當前用戶加入在線列表 //如果該用戶的數據當前仍然在在線列表中,則暫時先不讓該用戶登陸,提示用戶存在 public bool addusertoonline(user user) { //需要先判斷用戶是否已經在用戶列表中了 if(_alluser==null) { _alluser.add(user); return (true); } else { for ( int i = 0 ; i < _alluser.count ; i ++) { //循環判斷用戶是否已經存在 soholife.user tempuser = (soholife.user)_alluser[i] ;