예제 #1
0
        /// <summary>
        /// 获取客户端远程表达式节点
        /// </summary>
        /// <param name="node">远程表达式节点</param>
        /// <param name="clientNode">客户端远程表达式节点</param>
        /// <returns>返回值类型</returns>
        public TcpServer.ReturnType GetRemoteExpressionClientNode(RemoteExpression.Node node, out RemoteExpression.ClientNode clientNode)
        {
            RemoteExpressionServerNodeIdChecker checker = remoteExpressionServerNodeIdChecker;

            TcpServer.ReturnType returnType = checker.Check(node);
            clientNode = returnType == TcpServer.ReturnType.Success ? new RemoteExpression.ClientNode {
                Node = node, Checker = checker, ClientNodeId = node.ClientNodeId
            } : default(RemoteExpression.ClientNode);
            return(returnType);
        }
예제 #2
0
        /// <summary>
        /// 获取客户端远程表达式参数节点
        /// </summary>
        /// <typeparam name="returnType">返回值类型</typeparam>
        /// <param name="node">远程表达式参数节点</param>
        /// <returns>客户端远程表达式参数节点</returns>
        public RemoteExpression.ClientNode <returnType> GetRemoteExpressionClientNodeParameter <returnType>(RemoteExpression.Node <returnType> node)
        {
            RemoteExpressionServerNodeIdChecker checker = remoteExpressionServerNodeIdChecker;

            if (checker.Check(node) == TcpServer.ReturnType.Success)
            {
                return new RemoteExpression.ClientNode <returnType> {
                           Node = node, Checker = checker
                }
            }
            ;
            throw new InvalidCastException();
        }
예제 #3
0
        /// <summary>
        /// 获取客户端远程表达式节点
        /// </summary>
        /// <param name="node">远程表达式节点</param>
        /// <returns>客户端远程表达式节点</returns>
        public RemoteExpression.ClientNode GetRemoteExpressionClientNode(RemoteExpression.Node node)
        {
            RemoteExpressionServerNodeIdChecker checker = remoteExpressionServerNodeIdChecker;

            if (checker.Check(node) == TcpServer.ReturnType.Success)
            {
                return new RemoteExpression.ClientNode {
                           Node = node, Checker = checker, ClientNodeId = node.ClientNodeId
                }
            }
            ;
            throw new InvalidCastException();
        }
예제 #4
0
        /// <summary>
        /// TCP 服务客户端
        /// </summary>
        /// <param name="attribute">TCP服务调用配置</param>
        /// <param name="log">日志接口</param>
        /// <param name="maxInputSize">最大输入数据字节数</param>
        internal Client(TcpServer.ServerBaseAttribute attribute, ILog log, int maxInputSize)
            : base(attribute, attribute.ClientSendBufferMaxSize, log)
        {
            this.Host = attribute.Host;
            this.Port = attribute.Port;
            IpAddress = HostPort.HostToIPAddress(this.Host, Log);

            this.maxInputSize = maxInputSize <= 0 ? int.MaxValue : maxInputSize;
            outputStream      = (outputSerializer = BinarySerializer.YieldPool.Default.Pop() ?? new BinarySerializer()).SetTcpServer();

            SubBuffer.Pool.GetPool(attribute.GetSendBufferSize).Get(ref Buffer);
            if (attribute.IsRemoteExpression)
            {
                remoteExpressionServerNodeIdChecker = new RemoteExpressionServerNodeIdChecker {
                    Client = this
                }
            }
            ;
        }