Plugin TCP

From VoxCommando
Jump to: navigation, search

Go to the main Plugins page.

Go to the complete Plugin List.


Plugin Description

Send and receive messages on TCP sockets.

Actions for the TCP plugin

Client

Create a named client, and connect to a server.
Write to the server.
Receive messages back from the server as events.

Connect

TCP.Client.Connect
Connects to a server and keeps the connection open, after which messages from the server will generate events.

Events will use the client name unless the <EventName> parameter is specified. The message from the server will be attached to the event as a payload. If the server uses a standard terminator at the end of every message (e.g., \x0d) this can be specified in the <Terminator> parameter to ensure that each message generates exactly one event.

  • Parameters: 3-6
  1. Name : Name of client to create [string]
  2. Ip : Address of server to connect to [string]
  3. Port : Port of server to connect to [integer]
  4. Terminator : Server terminates messages with this byte [string]
  5. EventName : Generate events with this name when message received from server [string]
  6. EventFilter : Only generate events if they match this Regular Expression [string]

Disconnect

TCP.Client.Disconnect
Client will disconnect and be destroyed.
You can reconnect using the name afterwards.
If you only want to send a single command and then disconnect. consider using TCP.Single.Write instead.

  • Parameters: 1
  1. Name : Name of client to disconnect from [string]

Query

TCP.Client.Query
Query server, similar to TCP.Client.Write. Response will be stored in {LastResult}.

ClientName must be the name of a client that was previously created using TCP.Client.Connect
To include bytes in the <message>, you can encode bytes as follows
0: \x00
1: \x01
255: \xFF

Note: You must first use the Client.Connect action.

  • Parameters: 3-4
  1. ClientName : Name of client to use [string]
  2. Message : Message to send [string]
  3. Delay : Milliseconds to wait for a response of the server [integer]
  4. Notes : [string]

Write

TCP.Client.Write
ClientName must be the name of a client that was previously created using TCP.Client.Connect.
To include bytes in the <message>, you can encode bytes as follows
0: \x00
1: \x01
255: \xFF

Note: You must first use the Client.Connect action.

  • Parameters: 2-4
  1. ClientName : Name of client to use [string]
  2. Message : Message to send [string]
  3. Delay : Milliseconds to wait after sending the message (default is 10) [integer]
  4. Notes : [string]

WriteLn

TCP.Client.WriteLn
ClientName must be the name of a client that was previously created using TCP.Client.Connect.
To include bytes in the <message>, you can encode bytes as follows
0: \x00
1: \x01
255: \xFF
Message will automatically have a carriage return added to it ( \x0D ).

  • Parameters: 2-4
  1. ClientName : [string]
  2. Message : [string]
  3. Delay : Milliseconds to wait after sending the message (default is 10) [integer]
  4. Notes : You can write anything here. VC will not use it. [string]

Server

Create TCP servers that can listen for connections, and receive messages.
Messages can trigger VC actions or be used to create events.

Start

TCP.Server.Start
If <GenEvent> parameter is omitted or blank, all incoming client messages will be treated as commands intended for VC. Example: incoming message "VC.On" will turn VC green.
If <GenEvent> is specified, then all incoming requests will generate an event and the message from the client will be passed as a payload(s).
If <GenEvent> is used, and the message contains '&&' multiple payloads will be created.

  • Parameters: 1-2
  1. Port : TCP port to listen on [integer]
  2. GenEvent : Generate an event instead of sending command to VC [string]

Stop

TCP.Server.Stop
Stops the server running on <Port>.
Server must first have been created using TCP.StartServer.

  • Parameters: 1
  1. Port : Port of server to close [integer]

Single

These commands will:
-open a new connection
-send a string
-close the connection immediately

Write

TCP.Single.Write
Will send the string <Message> without adding a carriage-return to the IP and port specified in plugin settings.
To include bytes in the <message>, you can encode bytes as follows
0: \x00
1: \x01
255: \xFF

If Query is set to true then will wait for a response for the server and store it in {LastResult}.

  • Parameters: 3-4
  1. Message : TCP message to send. Encode bytes as \x00\x01...\xFF [string]
  2. IP : [string]
  3. Port : [integer]
  4. Query : Default = false. If true will wait for a response from the server [boolean]

WriteLn

TCP.Single.WriteLn
Will send the string <Message> followed by a carriage-return (\x0D) to the IP and port specified in plugin settings.
To include bytes in the <Message>, you can encode bytes as follows:
0: \x00
1: \x01
255: \xFF

If Query is set to true then will wait for a response for the server and store it in {LastResult}.

  • Parameters: 3-4
  1. Message : TCP message to send [string]
  2. IP : [string]
  3. Port : [integer]
  4. Query : Default = false. If true will wait for a response from the server [boolean]

WebServer

Create webservers that can receive messages via HTTP protocol.
Messages can trigger VC actions or be used to create events.

Start

TCP.WebServer.Start
If <genEvent> parameter is omitted or blank, all incoming client messages will be treated as commands intended for VC. Example: incoming message "VC.On" will turn VC green.
If <genEvent> is specified, then all incoming requests will generate an event and the message from the client will be passed as a payload(s).
If <genEvent> is used, and the message contains '&&' multiple payloads will be created.

  • Parameters: 1-2
  1. Port : TCP port to listen on [integer]
  2. GenEvent : Generate an event instead of sending command to VC [string]

Stop

TCP.WebServer.Stop
Stops the WebServer running on <Port>
WebServer must first have been created using TCP.WebServer.Start

  • Parameters: 1
  1. Port : Port of server to close [integer]

UDP

SendMixed

TCP.UDP.SendMixed
Allows you to send UDP messages to any IP and Port and to embed non ascii characters using the hex format \x00-\xFF.

  • Parameters: 2-3
  1. Message : string with hex encoded elements [string]
  2. Port : UDP port to send on [integer]
  3. Target IP : Defaults to broadcast IP: 255.255.255.255 [string]