tart-transport-tcp
Stability: 1 - Experimental
TCP transport implementation for Tiny Actor Run-Time in JavaScript.
Contributors
Overview
An implementation of a TCP transport for Tiny Actor Run-Time in JavaScript.
Usage
To run the below example run:
npm run readme
"use strict"; var net = ;var tart = ;var transport = ; var sponsor = tart; var send = ; var receivedMessageCount = 0;var receptionist = ; var serverCapabilities = transport;var close = ;var listen = ; var fail = ; var listenAck = ; ;
Tests
npm test
Documentation
Public API
- transport.sendBeh
- transport.server(receptionist)
- serverCapabilities.closeBeh
- serverCapabilities.listenBeh
transport.sendBeh
Actor behavior that will attempt to send messages over TCP.
Message format:
address
: String TCP address in URI format scheme, host, port required, and optional but usually necessary fragment. For example:tcp://localhost:7847/#t5YM5nxnJ/xkPTo...
.content
: String JSON content to be sent.fail
: Actorfunction (error) {}
(Default: undefined) Optional actor to reporterror
(if any).ok
: Actorfunction () {}
(Default: undefined) Optional actor to report successful send to the destination.
var send = ;;
transport.server(receptionist)
receptionist
: Actorfunction (message) {}
Actor to forward traffic received by this server in {address: , contents: } format.- Return: Object An object containing behaviors for listen and close capabilities.
closeBeh
: serverCapabilities.closeBehlistenBeh
: serverCapabilities.listenBeh
Creates an entangled pair of capabilities that will control a single TCP server.
serverCapabilities.closeBeh
Actor behavior that will close a listening server.
Message is an ack
Actor function () {}
, an actor that will be sent an empty message once the server closes.
var serverCapabilities = transport;var close = ;
serverCapabilities.listenBeh
Actor behavior that will create a new listening TCP server.
Message format:
customer
: Actorfunction (message) {}
Actor to receive acknowledgment once the server is listening.host
: String TCP host to listen on.port
: Number TCP port to listen on.
var serverCapabilities = transport;var listen = ;;