Kbase 17513: Server driven client data exchange - timer
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Server driven client data exchange - timer
You can communicate from the server to the client, by using the client
notification events. Below is an example of a timer routine that
can be used.
/*
* Timer.java: A custom user module, This is an example. Progress
* accepts no responsibility for errors in the code below.
*/
import java.io.PrintStream;
import COM.Apptivity.client.*;
import COM.Apptivity.server.*;
public class Timer extends Thread
{
// The constructor
public Timer(long ms, abServer server)
{
this.m_ms = ms;
this.m_server = server;
}
public void run()
{
try
{
// Get a handle to the broadcast query.
abQuery qBroadcast;
qBroadcast = m_server.getQuery("dsBroadcastFiter");
// Infinite loop
while (true)
{
// Run the broadcast query.
qBroadcast.prepareStatement();
qBroadcast.reQuery();
// Check if the query found any rows.
if (qBroadcast.getRows(1, 1, false, 0).rowCnt() 0);
{
// New message found. Copy message into a string (tempMsg).
// Then make tempMsg streamable.
String tempMsg = (String)qBroadcast.getRows(1, 1, false,0).
getColValue(0);
abString msg = (abString)abTypeCvt.makeStreamable(tempMsg);
// Create title of type abString (as that type is streamable)
abString title = new abString("News Flash!");
// Send the message to the client, with the special id 9999.
m_server.notifyClient(9999,msg,title);
}
// Wait the specified duration before polling again.
sleep(m_ms);
}
}
catch(Exception e)
{
System.out.println("Timer exception: " + e);
}
}
// m_ms The frequency (in milliseconds) to poll the broadcast table
// m_server This server
long m_ms;
abServer m_server;
}
NBI: 30 Dec 97
Progress Software Technical Support Note # 17513