The real-time web is a set of technologies and practices that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodically for updates.
Source: Wikipedia: Realtime web
- var ws =
- new WebSocket('ws://mywebsocketserver.com:80');
- ws.onopen = new() {
- // connection established
- };
- ws.onmessage = function(ev) { // receive a message
- ws.send("Yep, got: " + ev.data); // send a message
- ws.close();
- };
- ws.onerror = function(ev) {}
- ws.onclose = function(ev) {};
var ws = new WebSocket("ws://mywebsocketserver.com:80"); ws.onopen = function() { // connection established }; ws.onmessage = function(ev) { // receive a message ws.send("Yep, got: " + ev.data); // send a message ws.close(); }; ws.onerror = function(ev) {} ws.onclose = function(ev) {};
- var pusher = new Pusher('YOUR_APP_KEY');
- var channel = pusher.subscribe('channel-name');
- channel.bind('event_name', function(eventData) {
- // do stuff
- });
var pusher = new Pusher('YOUR_APP_KEY'); var channel = pusher.subscribe('channel-name'); channel.bind('event_name', function(eventData) { // do stuff });
- require('Pusher.php');
- require('config.php');
- $pusher = new Pusher($key, $secret, $app_id);
- $pusher->trigger('channel-name',
- 'event_name',
- array('msg' => 'Hello world!') );
require('Pusher.php'); require('config.php'); $pusher = new Pusher($key, $secret, $app_id); $pusher->trigger('channel-name', 'event_name', array('msg' => 'Hello world!') );
- var triggerPusher = new Pusher('a71b8d8b7eef0ef6d98c');
- var triggerChannel = triggerPusher.subscribe('example-channel');
- function publish() {
- if(triggerPusher.connection.state !== 'connected') {
- triggerChannel.trigger('client-new_trigger',
- {
- name: $('#name').val(),
- text: $('#text').val()
- });
- }
- }
var triggerPusher = new Pusher('a71b8d8b7eef0ef6d98c'); var triggerChannel = triggerPusher.subscribe('example-channel'); function publish() { if(triggerPusher.connection.state !== 'connected') { triggerChannel.trigger('client-new_trigger', { name: $('#name').val(), text: $('#text').val() }); } }
(Never do a live demo...)
1 / 11
#