Websockets is a technology providing communication channels over TCP. It makes it possible to interact between server and browser, facilitating in live content. The browser doesn't have to contact the webserver (polling) as long as the connection is open. This technology could be used in monitoring applications. Instead of polling the database every x seconds/minutes a message is send to the browser when the content has changed.
Requirements
A provider facilitating a push-service or creating one of your own.
Example
- Create an account with beaconpush.com
- Create a page with the following javascript included
<script type="text/javascript" src="http://cdn.beaconpush.com/clients/client-1.js"></script><script type="text/javascript">Beacon.connect('*****', ['mychannel']);Beacon.listen(function (data) {if (data.message=='REFRESH') {gReport.pull();}else {alert(data.message);}});</script>
**** = Unique userid
This script shows an alert when the message is not 'REFRESH', else it refreshes
the Interactive report.
- At beaconpush generate a message : { "message": "REFRESH" }
- Create a databaseprocedure to trigger the message.
procedure
push
( p_text in varchar2
)
is
l_clob clob;
begin
l_clob := APEX_WEB_SERVICE.MAKE_REST_REQUEST
( p_url =>
'http://api.beaconpush.com/1.0.0/*****/channels/mychannel'
, p_http_method => 'POST'
, p_body =>'{ "message":
"'||p_text||'" }'
);
end;
This procedure accepts an varchar variable and sends it to beaconpush. The example
below will force the page with the javascript to refresh. Use different channels for different
pages
begin
push('REFRESH');
end;
below will force the page with the javascript to refresh. Use different channels for different
pages
begin
push('REFRESH');
end;
In oracle11 you maybe have to authorize the database to send messages to the external provider.
/*Run
these ACL-Setting as SYS when you are in 11G
begin
dbms_network_acl_admin.create_acl
( acl => 'beaconConnectList.xml'
, description => 'Beaconpush ACL'
, principal => 'APEX_040100'
, is_grant => true
, privilege => 'connect'
, start_date => null
, end_date => null
);
commit;
end;
begin
dbms_network_acl_admin.assign_acl
( acl
=> 'beaconConnectList.xml'
, host
=> 'api.beaconpush.com'
, lower_port => null
, upper_port
=> null
);
commit;
end;
*/
Great post!!
ReplyDeletei dont know which date you post this, but my question is have you found any other way to accomplish the above? i mean bypassing the beaconpush.com?
Thank
Idrees.Muhammad@hotmail.com