public static void BodyParseSerializeTest(string[] args) { BodyParser parser = new BodyParser(); BodySerializer serial = new BodySerializer(); serial.Pipe(parser); serial.OnFail += () => Console.WriteLine("serializer failed"); parser.OnData += (data) => Console.WriteLine(UTF8.GetString(data)); parser.OnFinish += () => Console.WriteLine("parser finished"); parser.Excess.Pipe(VoidWritable.Default); BodyType bodyType = new BodyType(null, TransferEncoding.Chunked, TransferCompression.Deflate); if (!parser.TrySetFor(bodyType)) { Console.WriteLine("parser failed to set"); } if (!serial.TrySetFor(bodyType)) { Console.WriteLine("serializer failed to set"); } serial.Write(UTF8.GetBytes("I am a body\r\nxd\r\n")); serial.Write(UTF8.GetBytes("I am a body\r\nasfjaskfd\r\nasdfa")); serial.Finish(); Console.ReadKey(); }
public Connection(TcpSocket socket, HeadParser <Incoming> headParser, HeadSerializer <Outgoing> headSerializer, HttpMessageHandler <Incoming, Outgoing> messageHandler) { Base = socket; HeadParser = headParser; HeadSerializer = headSerializer; BodyParser = new BodyParser(); BodySerializer = new BodySerializer(); OnMessage = messageHandler; new Thread(ProcessorThread) { Name = "HTTP pipeline thread" }.Start(); Base.OnClose += End; }
private void BodyFrameReader_FramedArrived(object sender, BodyFrameArrivedEventArgs e) { var reference = e.FrameReference.AcquireFrame(); using (BodyFrame frame = e.FrameReference.AcquireFrame()) { if (frame != null) { canvas.Children.Clear(); _bodies = new Body[frame.BodyFrameSource.BodyCount]; frame.GetAndRefreshBodyData(_bodies); IList <Body> trackedBodies = new List <Body>(); foreach (var body in _bodies) { if (body != null) { if (body.IsTracked) { trackedBodies.Add(body); // Draw skeleton. if (_displayBody) { canvas.DrawSkeleton(body); } } } } if (trackedBodies.Count > 0) { var bodyEventModel = new BodyEventModel(trackedBodies); wsClient.SendData(BodySerializer.SerializeBodies(bodyEventModel)); } } } }
public RestResponseToHttpResponseConverter() { _bodySerializer = new BodySerializer(); }
public RestControllerMethodWithBodyExecutor() { _bodySerializer = new BodySerializer(); _responseFactory = new RestResponseFactory(); }