RemoteCmd Class Reference

The RemoteCmd JavaScript class. Send one sided commands to a remote host. More...

Public Slots

bool connect (String &machine, int port)
 
bool connectTimeout (String &machine, int port, int timeout)
 
bool send (String &cmd)
 
bool receive (int timeout)
 
bool sendMsg (String &msg)
 
bool receiveMsg (int timeout)
 
void disconnect ()
 
bool connected ()
 
String lastReceived ()
 

Public Member Functions

 RemoteCmd ()
 

Detailed Description

The RemoteCmd JavaScript class. Send one sided commands to a remote host.

RemoteCmd allows user to send one sided commands to a remote host.

// Connect to a Maya server and issue a Maya command remotely.
// Connect to the remote machine running Maya.
var remote = new RemoteCmd();
var machine = "mayaServer"; // Example Maya server machine
var port = 7777; // Example Maya server port
if ( !remote.connect( machine, port ) )
{
MessageBox.critical("Cannot connect to Maya server \"" + machine + "\" at port " + port);
return;
}
// Ask Maya to create a sphere
remote.send("sphere;");
// Wait for response (10 second timeout)
if ( remote.receive(10000) )
{
MessageBox.information( "Maya response: " + remote.lastReceived() );
}
remote.disconnect();

Constructor & Destructor Documentation

◆ RemoteCmd()

RemoteCmd::RemoteCmd ( )

Create a new RemoteCmd remote command object.

Member Function Documentation

◆ connect

bool RemoteCmd::connect ( String &  machine,
int  port 
)
slot

Connect to a remote machine.

Parameters
machineString Machine name
portPort number
Returns
Success/Failure of operation

◆ connected

bool RemoteCmd::connected ( )
slot

Retrieve connection status

Returns
Status

◆ connectTimeout

bool RemoteCmd::connectTimeout ( String &  machine,
int  port,
int  timeout 
)
slot

Connect to a remote machine.

Parameters
machineString Machine name
portPort number
timeoutTimeout value
Returns
Success/Failure of operation

◆ disconnect

void RemoteCmd::disconnect ( )
slot

Disconnect from remote machine.

◆ lastReceived

String RemoteCmd::lastReceived ( )
slot

Retrieve last received response from server.

Returns
Response String

◆ receive

bool RemoteCmd::receive ( int  timeout)
slot

Query response from server.

Parameters
timeoutTime out value in milliseconds. -1 for infinity.
Returns
Success/Failure of operation

◆ receiveMsg

bool RemoteCmd::receiveMsg ( int  timeout)
slot

Query a packaged response from server.

Parameters
timeoutTime out value in milliseconds. -1 for infinity.
Returns
Success/Failure of operation

◆ send

bool RemoteCmd::send ( String &  cmd)
slot

Send a command to remote machine.

Parameters
cmdString command
Returns
Success/Failure of operation

◆ sendMsg

bool RemoteCmd::sendMsg ( String &  msg)
slot

Send a packaged message to remote machine.

Parameters
msgString message
Returns
Success/Failure of operation