- Overview
- Installation
- Actions
- Tasks
- Middleware
- Satellites
- Cluster
- Cache
- Chat
- Development Mode
- File System
- Events
- WebSocket
- TCP
- HTTP
- Security
- Validation
- Logging
- Commands
- Testing
Models
- Introduction
- Data Types and Attributes
- Instance and Class Methods
- Validations
- Associations
- Model Configuration
- Queries
TCP
Overview
You can also interact with Stellar using a persistent connection through a TCP socket. By default port 5000 is used, but this can be changed by setting the api.config.tcp.port
property. Since this is a persistent connection verbs are used to send commands to the server. The list below shows all available verbs:
quit
: disconnects from the server (the session is destroyed)paramAdd
: saves a single variable to your connection- Example:
paramAdd query=something
- Example:
paramView
: returns the details of a single param- Example:
paramView query
- Example:
paramDelete
: deletes a single param- Example:
paramDelete query
- Example:
paramsView
: returns a JSON object of all the params set in this connectionparamsDelete
: deletes all params set in this sessiondetailsView
: shows you details about your connection, including about the members currently in the roomroomAdd
: connects to a roomroomLeave <room>
: leaves the room you are connected toroomView <room>
: shows you the room you are connected to, and information about the members currently in that roomsay <room,> <message>
: sends a message to a room
Note: the parameters added in previous calls are fixed to the connection; this means that it is necessary to remove the parameters before calling new verbs.
One of the main advantages of using a TCP connection is the possibility to call several actions simultaneously. Stellar keeps a count of the calls, so you can keep track of the different calls in progress.
TLS
The TCP server supports encrypted connections via TLS, if desired. For this you need to configure some settings on the server:
'use strict' |
The secure connection can be tested using the following command:
$ openssl s_client -connect 127.0.0.1:5000 |
Or, you can use another node process:
let fs = require('fs') |
JSON
The default way to execute actions on Stellar via a TCP connection is using the verbs available for persistent connections. However, it is also possible to use JSON to choose the action to execute and pass a list of parameters. For example, {"action": "actionName", "params": {"key": "some_value"}}
.