예제 #1
0
        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);
        }
예제 #2
0
        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
                }
            }
        }
예제 #3
0
        public bool IsLocalService(string serverName, string messageName)
        {
            ServerAddressWrap serverAddressWrap = GetServerAddressWrap(serverName, messageName);

            return(serverAddressWrap == null);
        }