using System; using System.Collections.Generic; using System.Collections.Concurrent; using System.Linq; using System.Text; using QM.Exchange.Interface; namespace QM.Exchange.Core { /// /// 注册中心 /// public class RegisterCenter { private static ConcurrentDictionary WorkerList = new ConcurrentDictionary(); /// /// 注册工作节点 /// public static void RegisterWorker(string sessionID, string clientHostName,Worker info) { //注册列表 Worker workNode = info; workNode.SessionID = sessionID; workNode.HostName = clientHostName; WorkerList.TryAdd(sessionID, workNode); } /// /// 获取工作节点列表 /// public static List GetWokerList() { List workers = new List(); foreach (Worker w in WorkerList.Values) { workers.Add(w); } return workers; } /// /// 注销工作节点 /// /// 会话ID列表 public static void LogoffWorker(List sessionIDArray) { Worker w = null; foreach (string sessionID in sessionIDArray) { WorkerList.TryRemove(sessionID, out w); } } } }