public void Destroy() { saveMap_timer.Stop(); saveMap_timer.Tick -= SaveMap_timer_Tick; saveMap_timer = null; checkOnlineUsers_timer.Stop(); checkOnlineUsers_timer.Tick -= CheckOnlineUsers_timer_Tick; checkOnlineUsers_timer = null; waitOnline_timer.Stop(); waitOnline_timer.Tick -= WaitOnline_timer_Tick; waitOnline_timer = null; IP_timer.Stop(); IP_timer.Tick -= IP_timer_Tick; IP_timer = null; lock_timer.Stop(); lock_timer.Tick -= Lock_timer_Tick; lock_timer = null; refreshIndicator_timer.Stop(); refreshIndicator_timer.Tick -= RefreshIndicator_timer_Tick; refreshIndicator_timer = null; doc = null; UsersOnline.Clear(); }
public void GetOnlineUsers() { if (m_Status != "online") { return; } UsersOnline.Clear(); DateTime _utcnow = DateTime.UtcNow; string _currentuser = m_PlacePath + SUtils.currentUserName + ".online"; StreamWriter sw = null; try { if (File.Exists(_currentuser)) { sw = new StreamWriter(_currentuser); } else { sw = new StreamWriter(File.Create(_currentuser)); } sw.Write(_utcnow.ToString(), false); // false = overwrite sw.Close(); } catch { } // TODO string[] files = Directory.GetFiles(m_PlacePath, "*.online"); for (int i = 0; i < files.Count(); i++) { if (files[i] == _currentuser) { continue; } string _user = Path.GetFileNameWithoutExtension(files[i]); try { StreamReader sr = new StreamReader(files[i]); DateTime _time = Convert.ToDateTime(sr.ReadLine()).AddMinutes(10); sr.Close(); if (_time < _utcnow) { File.Delete(files[i]); // user will be removed via Watcher } else { UsersOnline.Add(_user); } } catch { } // TODO } }