Contents Hide
var server = "10.0.0.111" ;
var pusher = new Push(server, 8090) ;
var vect = new Vector() ;
var startIndex ;
var maxRecordCount = 10 ;
var base = 0 ;
try
{
ScriptSession.logInfo("Creating data for CUSTOMER table ...") ;
rs = new RecordSet("CUSTOMER") ;
vectFieldInfo = new Vector() ;
vectFieldInfo.add(new FieldInfo("ID", FieldInfo.INTEGER, true, 0, false)) ;
vectFieldInfo.add(new FieldInfo("NAME", FieldInfo.STRING, false, 100, true)) ;
vectFieldInfo.add(new FieldInfo("ADDRESS", FieldInfo.STRING, false, 100, true)) ;
rs.setFieldInfo(vectFieldInfo) ;
// Get the variable for starting point
startIndex = ScriptSession.getVariable("StartIndex") ;
if (startIndex == null)
{
base = 0 ;
}
else
{
base = startIndex.intValue() ;
}
for (i=base; i<(base+maxRecordCount); i++)
{
record = new Record() ;
record.add(new Integer(i)) ; // ID
record.add("COMPANY " + i) ; // NAME
record.add("ADDRESS " + i) ; // ADDRESS
rs.addRecord(record) ;
}
vect.add(rs) ;
ScriptSession.logInfo("Sending data to " + server + " ...") ;
pusher.sendData(vect) ;
ScriptSession.logInfo("Data sent successfully.") ;
// Move to next block
ScriptSession.persistVariable("StartIndex", new Integer(i)) ;
}
catch(error)
{
ScriptSession.logInfo("Error sending data : " + error) ;
}
Note:
The remote client device is assumed to have been configured to listen to push messages on port 8090.
Creates new 10 records in a CUSTOMER table and send the data to the remote device
Customer ID generation is controlled by using a script variable via ScriptSession methods.
var server = "10.0.0.111" ;
var pusher = new Push(server, 8090) ;
try
{
// Forcing remote client to sync
ScriptSession.logInfo("Forcing remote client to sync ...") ;
pusher.forceRemoteSync("SyncRuleGetTable4") ;
ScriptSession.logInfo("Forced remote client to sync successfully.") ;
}
catch(error)
{
ScriptSession.logInfo("Error forcing remote device to sync : " + error) ;
}
Note:
The remote client device is assumed to have been configured to listen to push messages on port 8090.
Force the remote device to execute the sync rule name "SyncRuleGetTable4" to get new data from TABLE4.