diff --git a/index.html b/index.html index 9d1743ce..3e9e2343 100644 --- a/index.html +++ b/index.html @@ -364,7 +364,7 @@

Thing resource

Request
-
GET http://mythingserver.com/things/pi
+          
GET http://mywebthingserver.com/things/pi
 Accept: application/json
@@ -445,7 +445,7 @@

Properties resource

Request
-
GET http://mythingserver.com/things/pi/properties
+        
GET http://mywebthingserver.com/things/pi/properties
 Accept: application/json
@@ -470,7 +470,7 @@

Property resource

Request
-
GET http://mythingserver.com/things/pi/properties/temperature
+        
GET http://mywebthingserver.com/things/pi/properties/temperature
 Accept: application/json
@@ -487,7 +487,7 @@

Property resource

Request
-
PUT http://mythingserver.com/things/pi/properties/led
+        
PUT http://mywebthingserver.com/things/pi/properties/led
 {
   "led": true
 }
@@ -510,7 +510,7 @@ 

Actions resource

Any action supported by the thing can be requested via this top level action queue. If an unsupported action type is requested, the server should respond with a 400 Bad Request response.

Action Request

-POST https://mythingserver.com/things/lamp/actions/
+POST https://mywebthingserver.com/things/lamp/actions/
 Accept: application/json
 
 {
@@ -573,7 +573,7 @@ 

Action resource

If a client tries to request an action of another type via this resource, the server should respond with a 400 Bad Request response.

Action Request

-POST https://mythingserver.com/things/lamp/actions/fade
+POST https://mywebthingserver.com/things/lamp/actions/fade
 Accept: application/json
 
 {
@@ -784,7 +784,7 @@ 

Alternative Protocol Bindings

Web Thing WebSocket API

-

The Web Thing WebSocket API complements the REST API to provide a realtime mechanism to make multiple requests and be notified of events as soon as they happen, by keeping a WebSocket [[!WEBSOCKETS-PROTOCOL]] open on the Web Thing. The "webthing" WebSocket subprotocol defined here has a simple set of message types and a JSON response format consistent with the Web Thing REST API.

+

The Web Thing WebSocket API complements the REST API to provide a realtime mechanism to make multiple requests and be notified of events as soon as they happen, by keeping a WebSocket [[!WEBSOCKETS-PROTOCOL]] open on the Web Thing. The "webthing" WebSocket subprotocol defined here has a simple set of message types and a JSON response format consistent with the Web Thing REST API. Each message may additionally include an id member set to the id of the thing producing the message.

Protocol Handshake

To open a WebSocket on a Thing, an HTTP GET request is upgraded to a WebSocket using a standard WebSocket protocol handshake [[!WEBSOCKETS-PROTOCOL]] and the "webthing" subprotocol. The WebSocket URL for a Web Thing is specified in the links member of the Web Thing Description.

@@ -792,9 +792,9 @@

Protocol Handshake

Request
-
GET wss://mythingserver.com/things/robot
-Host: mythingserver.com
-Origin: https://mythingserver.com
+        
GET wss://mywebthingserver.com/things/robot
+Host: mywebthingserver.com
+Origin: https://mywebthingserver.com
 Upgrade: websocket
 Connection: Upgrade
 Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
@@ -816,7 +816,7 @@ 

Protocol Handshake

Example
-
const socket = new WebSocket('wss://mywebthingserver/things/robot', 'webthing');
+
const socket = new WebSocket('wss://mywebthingserver.com/things/robot', 'webthing');
@@ -827,6 +827,7 @@

setProperty message

Example
{
+  "id": "https://mywebthingserver.com/things/robot",
   "messageType": "setProperty",
   "data": {
     "leftMotor": 100
@@ -842,6 +843,7 @@ 

requestAction message

Example
{
+  "id": "https://mywebthingserver.com/things/robot",
   "messageType": "requestAction",
   "data": {
     "goForward": {},
@@ -857,6 +859,7 @@ 

addEventSubscription message

Example
{
+  "id": "https://mywebthingserver.com/things/robot",
   "messageType": "addEventSubscription",
   "data": {
     "motion": {}
@@ -872,6 +875,7 @@ 

propertyStatus message

Example
{
+  "id": "https://mywebthingserver.com/things/robot",
   "messageType": "propertyStatus",
   "data": {
     "led": true
@@ -887,6 +891,7 @@ 

actionStatus message

Example
{
+  "id": "https://mywebthingserver.com/things/robot",
   "messageType": "actionStatus",
   "data": {
     "grab": {
@@ -907,6 +912,7 @@ 

event message

Example
{
+  "id": "https://mywebthingserver.com/things/robot",
   "messageType": "event",
   "data": {
     "motion": {
@@ -917,6 +923,37 @@ 

event message

+
+

Gateway WebSocket API

+

The Gateway WebSocket API acts as a broader version of the Web Thing WebSocket API by allowing the client to open one WebSocket connection per Gateway instead of per Thing. The connection then acts as a multiplex of all the Gateway's Things' WebSocket connections. The id member is required for this channel to allow both the Gateway and the WebSocket client to determine with which Thing each message is associated. +

+

Protocol Handshake

+

To open a WebSocket on a Gateway, an HTTP GET request is upgraded to a WebSocket using a standard WebSocket protocol handshake and the "webthing" subprotocol. The WebSocket URL for a Gateway is the "/things" endpoint.

+
+
+ Request +
+
GET wss://mywebthingserver.com/things
+Host: mywebthingserver.com
+Origin: https://mywebthingserver.com
+Upgrade: websocket
+Connection: Upgrade
+Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
+Sec-WebSocket-Protocol: webthing
+Sec-WebSocket-Version: 13
+
+
+
+ Response +
+
HTTP 101 Switching Protocols
+Upgrade: websocket
+Connection: Upgrade
+Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
+Sec-WebSocket-Protocol: webthing
+
+
+

Further Information

Web of Things Integration Patterns