2 expectmonitor class – Casio Naurtech CETerm Ver.5.5 Scripting Guide User Manual
Page 103

N
AURTECH
W
EB
B
ROWSER AND
T
ERMINAL
E
MULATION FOR
W
INDOWS
CE
AND
W
INDOWS
M
OBILE
CETerm Scripting Guide
Page 103
//EM.OnDone = function (success) { OS.Alert( "Done." ) };
// Start check
EM.Start();
}
5.1.2 ExpectMonitor Class
The “ExpectMonitor” class illustrates the use of a prototype in JavaScript. This
class also manages all instances of itself to restrict the number of objects that
can be created.
/* ExpectMonitor */
//
// ExpectMonitor class
//
// The ExpectMonitor class manages the expect/action
// sequence for a session.
// Only one ExpectMonitor is allowed per session.
//
function ExpectMonitor ( session, timeout, targetactions )
{
// Validate session
if (session < 1 || session > 4)
{
return null;
}
this.session = session;
this.timeout = timeout;
this.args = targetactions;
this.state = 0;
this.timer = null;
this.checkCount = 0;
this.totalCheckCount = 0;
this.maxCheckCount = this.timeout / this.checkDelta;
// Abort any existing object
if (ExpectMonitor.Instances[this.session] != null)
{
ExpectMonitor.Instances[this.session].Abort();
}
// Record this instance in the global array
ExpectMonitor.Instances[this.session] = this;
}