diff --git a/ChatRoomServer.Main/ChatRoomServer.Main.csproj b/ChatRoomServer.Main/ChatRoomServer.Main.csproj index ae0dfcd..9c607e5 100644 --- a/ChatRoomServer.Main/ChatRoomServer.Main.csproj +++ b/ChatRoomServer.Main/ChatRoomServer.Main.csproj @@ -60,6 +60,7 @@ + diff --git a/ChatRoomServer.Main/ChatServer.cs b/ChatRoomServer.Main/ChatServer.cs index e88772e..d127656 100644 --- a/ChatRoomServer.Main/ChatServer.cs +++ b/ChatRoomServer.Main/ChatServer.cs @@ -20,6 +20,7 @@ namespace ChatRoomServer.Main { static ILog _log; static readonly object _lockObject = new object(); + internal static HashSet PresetAdministrators = (System.Configuration.ConfigurationManager.AppSettings["chat:admin"] ?? "").Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries).ToHashSet(StringComparer.OrdinalIgnoreCase); static ChatServer() { diff --git a/ChatRoomServer.Main/ChatSession.cs b/ChatRoomServer.Main/ChatSession.cs index 7356035..e97a2b8 100644 --- a/ChatRoomServer.Main/ChatSession.cs +++ b/ChatRoomServer.Main/ChatSession.cs @@ -19,6 +19,7 @@ namespace ChatRoomServer.Main DateTime _connecTime = DateTime.Now; long _connectId; + bool _isAdmin; /// /// 路径分割 @@ -55,6 +56,7 @@ namespace ChatRoomServer.Main NickName = System.Net.WebUtility.UrlDecode(path[3]); } PathSegements = path; + _isAdmin = ChatServer.PresetAdministrators.Contains(UserName); //更新统计 var db = new ChatDb(); diff --git a/Web12306/js/ui/chat/roomsession.js b/Web12306/js/ui/chat/roomsession.js index 3e4d754..7ca9709 100644 --- a/Web12306/js/ui/chat/roomsession.js +++ b/Web12306/js/ui/chat/roomsession.js @@ -17,8 +17,13 @@ }; sessMgr.on("sessionChanged", function () { - user = sessMgr.current; - checkPrivilege(); + + if (!sessMgr.current) { + session.exitRoom(); + } else { + user = sessMgr.current; + checkPrivilege(); + } }); checkPrivilege();