Plugin TCP

From VoxCommando
Jump to: navigation, search

Go to the main Plugins page.

Go to the complete Plugin List.


Plugin Description

A multipurpose networking plugin that allows the following and more:

  • Send and receive messages on TCP sockets.
  • Host simple web pages and accept API commands
  • Allow Google Speech in Chrome to be used for speech recognition

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]

GS

Actions for using Google speech recognition in a Chrome Browser with VoxCommando.

Both the "Web Server" AND "Google Speech" must be enalbed in the TCP plugin settings to use Google speech recognition in Chrome with VoxCommando.

Close

TCP.GS.Close
( BETA )

Attempts to find and close the first Chrome tab that appears to be hosting the speech web page. May not work if there are multiple Chrome windows open.

It is probably better to leave the Google speech web page open and turn the microphone on and off using TCP.GS.On and TCP.GS.Off

Launch

TCP.GS.Launch
Attempts to launch the Google Speech web page in Chrome.

Both the "Web Server" AND "Google Speech" must be enalbed in the TCP plugin settings to use Google speech recognition in Chrome with VoxCommando.

On

TCP.GS.On
Sends a message to the web page to attempt to turn the microphone on and start listening for speech.

Off

TCP.GS.Off
Sends a message to the web page to attempt to turn the microphone off and stop listening for speech.

Send

TCP.GS.Send
Send any message to the web page via websocket.
(May be useful in later versions of the plugin.)

  • Parameters: 1
  1. Message : Text to send to web page [string]

SetLanguage

TCP.GS.SetLanguage
Sets the speech recognition language.

Language codes can be found in the TCP settings under the Google Speech tab or possibly there are more codes listed here: https://cloud.google.com/speech-to-text/docs/languages

  • Parameters: 1
  1. LanguageCode : Example: en-US, fr-FR, de-DE, af-ZA [string]

SetPrefix

TCP.GS.SetPrefix
If a prefix is used, the webpage will only send recognized text to VoxCommando when the prefix is detected.

Any text recognized AFTER the prefix will be sent to VoxCommando for processing.

If <Prefix> is blank or omitted the prefix will be removed and ALL text will be accepted.

  • Parameters: 1
  1. Prefix : Prefix used to indicate that speech should be sent to VoxCommando [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]

UDP

SendMixed

TCP.UDP.SendMixed
Allows you to send UDP messages to any IP and Port and to embed any ascii or 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]

WebServer

SetResponse

TCP.WebServer.SetResponse


  • Parameters: 1
  1. Response : [string]