Proxy v1.1.3
Introspective Systems, LLC
Proxy is a core module used to create TCP socket connections between two modules in different systems. Proxy can operate as either a Server linked to a specific Module within the same system, or as a Client connected to another Proxy or other TCP connection. Then, modules can send commands to the Proxy as if it were the destination module.
Proxy may also use the Plexus module to route message between modules instead of directly linking to other Proxy modules. In this case set Par.Chan on Proxy in a Proxy pair (Clients, Server). Proxy will need a local Plexus server running. See the Examples in Examples/MultipleSystemsWithPlexus
Roles
Proxy’s role must be assigned in it’s module definition. The Proxy’s
role is set in the Role
parameter of it’s module definition.
Proxy requires different parameters depending on what role it has been assigned.
Role | Required Parameters | Optional Parameters |
---|---|---|
Client | Role, Link, Host, Port | Chan |
Server | Role, Link, Port | Chan |
Here is an example of two systems using the Proxy. The first uses Proxy
as a server module, setting the Port
and the Link
directly. The second
uses Proxy as a client module, setting the Host and the Port directly.
Set both Client and Server in the proxy pair to the same chan, and ensure they
connect to a running Proxy module (Working example located in Examples/MultipleSystemsWithPlexus).
The MultipleSystems/BankAccount
system structure object. Proxy is used
here as a server.
{
"Sources": {
"xGraph": "{xGraph}"
},
"Modules": {
"Bank": {
"Module": "xGraph.BankAccount"
},
"BankServer": {
"Module": "xGraph.Proxy",
"Par": {
"Port": 27002,
"Role": "Server",
"Link": "$Bank"
}
}
}
}
The MultipleSystems/BankPatron
system structure object. Proxy is used
here as a client.
{
"Sources": {
"xGraph": "{xGraph}"
},
"Modules": {
"BankPatron": {
"Module": "xGraph.BankPatron",
"Par":{
"BankAccount":"$BankServer"
}
},
"BankServer": {
"Module": "xGraph.Proxy",
"Par": {
"Host": "127.0.0.1",
"Port": 27002,
"Role": "Client",
"Poll": true
}
}
}
}
Module Definition Parameters
Role: String - Either ‘Client’ or ‘Server’. Determines the Proxy’s operation mode.
Host: String - The URL of the server the Proxy will connect to.
Port: Integer - The port to open as a server, or the port to connect to as a client.
Link: String - Used when proxy is a Server. A reference to the module that incoming commands received over the TCP connection are routed to.
Poll: Boolean - Used to determine if Proxy should attempt to re-connect after failed connection attemps.
Chan: String - Used when managing connections using the Plexus module. Proxies with the same Chan (Channel) name will connect automatically when connected to the same Plexus server.
Timeout Integer - The time in milliseconds to wait before poll attempts. Used only if Poll is set to TRUE.
AutoSave Boolean - Should the Proxy be autoSaved into the cache.
Encrypt Boolean - If false then we will not use encryption defaults to encrypt.
Broadcast Boolean - Default to true. Sends to all sockets when a server receives a message. No callback will be recieved from sender. If false incomming message have a data attribute in the received com called “SocketID” which denotes the id of the given socket connection. This can be specified for directed messages with callbacks. Broadcast == false is currently an untested feature.
Input Commands
Proxy will route any dispatched command other than Start or Setup to the socket connection.
Output Commands
Proxy will route any command received through the socket connection to the module defined in Par.