Plugin Tcp

From VoxCommando
Revision as of 12:03, 25 November 2014 by Jitterjames (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Go to the main Plugins page.

Go to the complete Plugin List.

Version 1 (old) documentation.

Plugin Description

Send and Receive packets on TCP sockets

Actions for the TCP plugin

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
Optional Parameters can override target IP and Port

  • Parameters: 1-3
  1. Message : TCP message to send. Encode bytes as \x00\x01...\xFF [string]
  2. IP : blank = use default [string]
  3. Port : blank = use default [integer]

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
Optional Parameters can override target IP and Port

  • Parameters: 1-3
  1. Message : TCP message to send [string]
  2. IP : blank = use default [string]
  3. Port : blank = use default [integer]

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


  • Parameters: 3-5
  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]

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 disconnecter consider using TCP.Single.Write instead

  • Parameters: 1
  1. Name : Name of client to disconnect from [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

  • 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 : [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 ommited 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 payoads 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]

WebServer

Create web servers that can receive message 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 web server running on <Port>
Web server must first have been created using Tcp.WebServer.Start

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