Created
September 24, 2013 14:37
-
-
Save mattwilliamson/6685713 to your computer and use it in GitHub Desktop.
Webhookr client socket test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | |
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | |
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | |
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<!--[if lt IE 7]> | |
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> | |
<![endif]--> | |
<!-- Add your site or application content here --> | |
<p>Hello world! This is HTML5 Boilerplate.</p> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.2.min.js"><\/script>')</script> | |
<script type="text/javascript" language="javascript" src="http://webhookr.com/static/js/socket.io.js"></script> | |
<script type="text/javascript"> | |
var socket = io.connect('http://webhookr.com/webhooks'); | |
var webhookId = '4rB4dm'; | |
socket.on('connect', function(){ | |
socket.emit('join', webhookId); | |
}); | |
socket.on('reconnect', function () { | |
console.info('Reconnected to the server'); | |
}); | |
socket.on('reconnecting', function () { | |
console.info('Attempting to re-connect to the server'); | |
}); | |
socket.on('error', function (e) { | |
console.error(e ? e : 'A unknown error occurred'); | |
}); | |
socket.on('new_request', function(message) { | |
message.date = new Date(); | |
message.dateNumber = Number(message.date); | |
message.hasInfo = false; | |
message.hasHeaders = false; | |
message.hasPost = message.post != 'null' && message.post != ''; | |
message.hasGet = message.get != 'null' && message.get != ''; | |
message.hasFiles = message.files != 'null' && message.files != ''; | |
console.log(message); | |
}); | |
socket.on('subscriber_joined', function(message){ | |
console.log('subscriber_joined'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment