public async Task <IChannel> GetChannel(string serverName, string messageName) { ServerAddressWrap serverAddressWrap = GetServerAddressWrap(serverName, messageName); string serverAdderss = serverAddressWrap != null?serverAddressWrap.GetNext() : null; if (serverAdderss == null) { throw new Exception($"{serverName}.{messageName}服务不存在,请检查配置"); } IChannel channel = await _clientConnectManage.GetChannel(serverAdderss); return(channel); }
public void RegisterService(string serverName, string messageName, string serverAdderss) { string key = string.Format("{0}_{1}", serverName, messageName); lock (SyncObj) { if (Hash.ContainsKey(key)) { Hash[key].AddServerAddress(serverAdderss); } else { var container = new ServerAddressWrap(); container.AddServerAddress(serverAdderss); Hash.TryAdd(key, container); //请把返回值改为async ClientConnectManage.Instance.CreateConnect(serverAdderss); //不要调用wait,请把返回值改为async Task,然后使用await } } }
public bool IsLocalService(string serverName, string messageName) { ServerAddressWrap serverAddressWrap = GetServerAddressWrap(serverName, messageName); return(serverAddressWrap == null); }