/// <summary> /// 根据KAE网络资源来构建一个网络宿主信道 /// </summary> /// <param name="network">网络通信类型</param> /// <param name="uri">返回的网络通信资源对象</param> /// <returns>返回构建后的宿主信道</returns> /// <exception cref="NotSupportedException">不支持的网络类型</exception> public static IHostTransportChannel BuildHostChannel(NetworkTypes network, out Uri uri) { IHostTransportChannel channel; switch (network) { case NetworkTypes.TCP: int port = GetDynamicTCPPort(); channel = new TcpHostTransportChannel(port); uri = new TcpUri(string.Format("tcp://{0}:{1}", GetCurrentMachineIP(), port)); break; default: throw new NotSupportedException("#Sadly, current network type wasn't supported yet! #Network Type: " + network); } return(channel); }
/// <summary> /// 将一个业务的通信协议与远程可访问地址注册到服务器上 /// </summary> /// <param name="identity">业务协议编号</param> /// <param name="protocolTypes">通信协议类型</param> /// <param name="level">KAE应用等级</param> /// <param name="resourceUri">远程可访问的资源地址</param> /// <param name="kppUniqueId">KPP全局唯一编号</param> public void Register(MessageIdentity identity, ProtocolTypes protocolTypes, ApplicationLevel level, Uri resourceUri, Guid kppUniqueId) { if (resourceUri == null) { throw new ArgumentNullException(nameof(resourceUri)); } string path = string.Format("{0}/{1}-{2}-{3}-{4}", _protocolPath, identity.ProtocolId, identity.ServiceId, identity.DetailsId, level); AddPath(path, CreateMode.PERSISTENT); path += string.Format("/{0};{1}", resourceUri.Address, kppUniqueId); AddPath(path, CreateMode.PERSISTENT); }