protected void Session_End(object sender, EventArgs e) { Application.Lock(); Application["count"] = (int)Application["count"] - 1; Application.UnLock(); if (Session["user"] != null) { u = Session["user"] as Dollers.model.User; if (Application[u.room_ID.ToString()] != null) { Application.Lock(); r = Application[u.room_ID.ToString()] as Dollers.model.Room; r.addNewMessage(new Dollers.model.Message(false, "断开连接", u)); r.count--; if (r.count <= 0) { List<string> list = Application["room_list"] as List<string>; list.Remove(r.name); Application["room_list"] = list; Application[u.room_ID.ToString()] = null; Application[u.room_ID.ToString() + "_flag"] = null; } else { Application[u.room_ID.ToString()] = r; Application[u.room_ID.ToString() + "_flag"] = DateTime.Now; } Application.UnLock(); } } }
public Message(bool is_message, string content, User u) { this.is_message = is_message; this.content = content; this.create_time = DateTime.Now.ToString(); if (is_message) { user_name = u.name; user_profile = u.profile; } else { this.content = "—— " + u.name + " " + content; } }
public User createUser(string name) { User u = new User(maxIDInc(maxUserID), name); usersList.Add(u.ID, u); return u; }