| <!-- |
| # |
| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| --> |
| |
| ## Using the WebSocket package |
| |
| The `/whisk.system/websocket` package offers a convenient way post messages to a WebSocket. |
| |
| The package includes the following action: |
| |
| | Entity | Type | Parameters | Description | |
| | --- | --- | --- | --- | |
| | `/whisk.system/websocket` | package | uri | Utilities for communicating with WebSockets | |
| | `/whisk.system/websocket/send` | action | uri, payload | Send the payload to the WebSocket URI | |
| |
| If you plan to send many messages to the same WebSocket URI, creating a package binding with the `uri` value is suggested. With binding, you don't need to specify the value each time that you use the `send` action. |
| |
| |
| ### Sending a message to a WebSocket |
| |
| The `/whisk.system/websocket/send` action will send a payload to a WebSocket URI. The parameters are as follows: |
| |
| - `uri`: The URI of the websocket server (e.g. ws://mywebsockethost:80) |
| - `payload`: The message you wish to send to the WebSocket |