Publish to wire
api
The WireAPI.PublishWire API enables clients to publish to a wire.
cli
Use the wire
command.
./volt wire --help
Publish to a wire using the cli wire
command:
./volt wire <wire id>
The wire data is read from STDIN. This enables flows such as:
curl www.google.com | ./volt wire @demo-wirecat somefile | ./volt wire @demo-wire./volt wire @demo-wire < anotherfile
fusebox
Navigate to the wire in the resource explorer and use the ‘publish’ button on the bottom panel, which contains a ‘microphone’ icon.
javascript
Use the PublishWire API write data to the wire.
web
const pub = voltApi.PublishWire({ wire_id: "@demo-wire" });
pub.on("error", (err) => console.error(err.message));
pub.on("data", (response) => console.log(response));
pub.on("end", () => console.log("publication ended"));
pub.send({ chunk: "hello" });pub.send({ chunk: "world" });
C++
volt_client::WirePublishCallbacks publishCallbacks; volt_client::WirePublishClient* publishRpc = nullptr;
publishCallbacks.onEnd = [](bool serverSide) { // Publish call ended. };
publishCallbacks.onResponse = [](tdx::volt_api::volt::v1::PublishResponse const& response) { if (response.has_status() && response.status().message() != error_code::ok) { // Publication ended with an error. } else { // Publication ended OK. } };
publishCallbacks.onDestroyed = [](tdx::grpc::CallClientBase* rpcClient) { // Publication RPC has died. };
// Start the publish RPC. if ((result = volt()->serviceApi()->publishWire( publishCallbacks, &publishRpc)) != error_code::ok) { // Failed to start wire publish RPC return result; }
// Send the initial request containing the wire id. tdx::volt_api::volt::v1::PublishRequest startReq; startReq.set_wire_id("@demo-wire"); publishRpc->send(startReq);