New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

swim-proto-js

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swim-proto-js

Swim Protocol JavaScript Implementation

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
Maintainers
2
Weekly downloads
 
Created
Source

Swim Protocol JavaScript Implementation

JavaScript Library

The Swim protocol library can be used in any standard JavaScript environment. Use npm to incorporate the library into Node.js projects.

npm install --save swim-proto-js
var proto = require('swim-proto-js');

var envelope = proto.parse('@event(node: "house#kitchen", lane: "light/on")');
proto.stringify(envelope);

Protocol Envelopes

The Swim protocol defines a set of RECON datatypes used for URI-linked multiplexed structural messaging.

@event

Send an event message to a node on some lane, or receive an event message that propagated through a linked node on a subscribed lane. node_uri and lane_uri always refer to origin node and lane to which the event was published. link_uris enumerates all links the event passed through prior to reaching the receiver.

<< @event([node:] <node_uri>, [lane:] <lane_uri>[, via: <link_uris>]) <body>
Examples
<< @event(node: "swim://iot.example.com/L01FE", lane: "light/off", via: "house#kitchen/light) {
  time: @date("2015-02-03T07:53:31-0800")
}

<< @event(node: "swim://iot.example.com/SD02FD", lane: "alarm/smoke", via: "house#garage/smoke_detector") {
  time: @data("2015-02-03T11:17:12-0800")
  concentration: 330 @ppm
  duration: 10 @seconds
}

@command

Send a command message to a node on some lane, or receive a command message that propagated through a linked node on a subscribed lane. node_uri and lane_uri always refer to origin node and lane to which the command was published. link_uris enumerates all links the command passed through prior to reaching the receiver.

<< @command([node:] <node_uri>, [lane:] <lane_uri>[, via: <link_uris>]) <body>
Examples
<< @command(node: "house#kitchen", lane: "light/on")

<< @command(node: "swim://town.example.com/fire_dept", lane: "alarm/silence", via: "house") {
  reason: "homeowner reported false alarm"
}

@sync

Request a replay of events that have propagated through a node on some lane. The receiver should respond with the minimum set of events necessary to reconstruct the receiver's current state, as it pertains to the requested message lane.

A @sync request establishes a corresponding link, if one doesn't already exist.

>> @sync([node:] <node_uri>, [lane:] <lane_uri>[, prio: <priority>])
<< @synced([node:] <node_uri>, [lane:] <lane_uri>)
Examples
>> @sync(node: "house", lane: "light/level", prio: 0.5)
<< @event(node: "house#kitchen", lane: "light/level") { level: 100 }
<< @event(node: "house#hallway", lane: "light/level") { level: 0 }
<< @synced(node: "house", lane: "light/level")

Subscribe to messages that flow through some node on some lane.

>> @link([node:] <node_uri>, [lane:] <lane_uri>[, prio: <priority>])
<< @linked([node:] <node_uri>, [lane:] <lane_uri>[, prio: <priority>])
Examples
>> @link("house#kitchen", "light")
<< @linked(node: "house#kitchen", lane: "light")

>> @link(node: "house", lane: "alarm", prio: 0.5)
<< @linked(node: "house", lane: "alarm", prio: 0.5)

Remove an existing message subscription identified by a (node_uri, lane_uri) pair.

>> @unlink([node:] <node_uri>, [lane:] <lane_uri>)
<< @unlinked([node:] <node_uri>, [lane:] <lane_uri>)

@auth

Authorizes the connection with credentials contained in <body>.

Examples
>> @auth <body>
<< @authed <body>

@deauth

De-authorizes the connection.

Examples
>> @deauth <body>
<< @deauthed <body>

Keywords

FAQs

Package last updated on 11 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc