/// <summary> /// 获取服务的全部信息 /// </summary> /// <param name="serviceName"></param> /// <returns></returns> public static Dictionary <string, ServiceInfo> GetAll(string serviceName) { lock (_locker) { return(_serviceMap.GetAll(serviceName)); } }
/// <summary> /// 初始化 /// </summary> /// <param name="uri"></param> /// <param name="links"></param> /// <param name="timeOut"></param> ConsumerMultiplexer(Uri uri, int links = 10, int timeOut = 10 * 1000) { _uri = uri; _links = links; _timeOut = timeOut; var dic = _hashMap.GetAll(uri.ToString()); for (int i = 0; i < _links; i++) { var rClient = dic[i]; rClient.OnDisconnected -= RClient_OnDisconnected; rClient.OnError -= RClient_OnError; rClient.OnNoticed -= RClient_OnNoticed; rClient.OnDisconnected += RClient_OnDisconnected; rClient.OnError += RClient_OnError; rClient.OnNoticed += RClient_OnNoticed; _myClients.TryAdd(i, rClient); } }
/// <summary> /// 重连 /// </summary> /// <returns></returns> public bool Reconnect() { var dic = _hashMap.GetAll(_uri.ToString()); if (dic != null && dic.Any()) { foreach (var item in dic) { item.Value.Connect(); } return(true); } return(false); }