Search in sources :

Example 1 with Writable

use of com.ociweb.gl.api.Writable in project GreenLightning by oci-pronghorn.

the class JSONServerBehavior method restRequest.

@Override
public boolean restRequest(HTTPRequestReader request) {
    int f = request.structured().readInt(flagsFieldId);
    request.openPayloadData(reader -> {
        jsonRequest.reset();
        jsonRequest.readFromJSON(jsonReader, reader);
    });
    System.out.println("Server: " + f + " " + jsonRequest);
    if (f == 42)
        assertEquals(42, jsonRequest.getValue());
    if (f == -6)
        assertEquals(43, jsonRequest.getValue());
    channel.publishHTTPResponse(request.getConnectionId(), request.getSequenceCode(), 200, false, HTTPContentTypeDefaults.JSON, new Writable() {

        @Override
        public void write(ChannelWriter writer) {
            // System.err.println("pre "+writer.length());
            response.writeToJSON(writer);
        // System.err.println("post "+writer.length());
        }
    });
    // runtime.shutdownRuntime();
    return true;
}
Also used : Writable(com.ociweb.gl.api.Writable) ChannelWriter(com.ociweb.pronghorn.pipe.ChannelWriter)

Aggregations

Writable (com.ociweb.gl.api.Writable)1 ChannelWriter (com.ociweb.pronghorn.pipe.ChannelWriter)1