Exemplo n.º 1
0
        /// <summary>
        /// Send a request output data to the output or error stream
        /// </summary>
        /// <param name="request">Request</param>
        /// <param name="streamType"></param>
        /// <param name="data"></param>
        protected virtual void SendRequestOutput(Request request, MessageType streamType, ByteArray data)
        {
            if (streamType != MessageType.StandardError &&
                streamType != MessageType.StandardOutput)
                    throw new ArgumentException("streamType");

            while (data.Count > 0)
            {
                ushort length = (ushort)Math.Min(data.Count, Consts.MaxMessageBodySize);
                this.SendMessage(new Message(streamType, request.Id, data.SubArray(0, length)));
                data = data.SubArray(length, true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Ends a request
        /// </summary>
        /// <param name="request"><typeparamref name="Request"/> to end</param>
        protected virtual void EndRequest(Request request)
        {
            EndRequestMessageBody body = new EndRequestMessageBody(request.ExitCode, ProtocolStatus.RequestComplete);

            this.SendMessage(new Message(MessageType.StandardError, request.Id, ByteArray.Empty));
            this.SendMessage(new Message(MessageType.StandardOutput, request.Id, ByteArray.Empty));
            this.SendMessage(new Message(MessageType.EndRequest, request.Id, body.ToArray()));

            this.RemoveRequest(request);
        }
Exemplo n.º 3
0
 protected abstract void RemoveRequest(Request request);
Exemplo n.º 4
0
 protected abstract void AddRequest(Request request);