using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace POSV.WindowsService { public static class SessionManager { public static Dictionary SessionDic = new Dictionary(); //public static List Session = new List(); /// /// 增加连接 /// /// /// /// public static Tuple AddSession(string name, WebSocketSessionEx session) { if(string.IsNullOrEmpty(name)) { return new Tuple(false, "注册名称非法"); } if (SessionDic.ContainsKey(name)) { return new Tuple(false, "注册名称已存在"); } else { SessionDic.Add(name, session); return new Tuple(true, "注册成功"); } } /// /// 移除session /// /// /// public static Tuple RemoveSession(string name) { if (name == null) { return new Tuple(false, "注册名称非法"); } SessionDic.Remove(name); return new Tuple(true, "移除成功"); } } }