Esc

receive

procedureextensionsince 0.36.1Source
  • macOS: receive works on macOS
  • Linux: receive works on Linux
  • Windows: receive works on Windows
  • Wasm: receive works on Wasm

Decodes into owned Protobuf storage. Release a MESSAGE with Proto.free. .

Signature

receive :: (call: *Call, $T: Type) -> (value: T, kind: Receive_Kind)
Example
P :: #import "Extensions/Protobuf";
Api :: #import "Extensions/Protobuf/Schema"(GRPC = true, TEXT = "syntax='proto3'; package echo; message Say { string text = 1; }");

main :: () {
    channel: Channel;
    call, status := open_call(*channel, Method.{ path = "/echo.Echo/Say" });
    defer close(*call);
    reply, kind := receive(*call, Api.echo.Say);
    if kind == .MESSAGE {
        print("%\n", reply.text);
        P.free(*reply);
    }
}

See also