Skip to content

Instantly share code, notes, and snippets.

@latentflip
Created May 1, 2012 20:42
Show Gist options
  • Save latentflip/2571207 to your computer and use it in GitHub Desktop.
Save latentflip/2571207 to your computer and use it in GitHub Desktop.
shakey-blog-1
game_server.html
<script src="http://js.pusher.com/1.12/pusher.min.js">
</script>
<script>
//setup pusher and a presence channel
pusher = new Pusher('pusher-key')
channel = pusher.subscribe('presence-main-channel')
//listen to "client-alert-message" messages on the
//channel, and alert with the message text
channel.on('client-alert-message', function(data) {
alert(data.message_text);
});
</script>
game_client.html
<script src="http://js.pusher.com/1.12/pusher.min.js">
</script>
<script>
//same setup
pusher = new Pusher('secret-pusher-key')
channel = pusher.subscribe('presence-main-channel')
//listen to "client-alert-message" messages on the
//channel, and alert with the message text
channel.trigger('client-alert-message', {
message_text: "Hello, world!"
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment