Skip to content

Instantly share code, notes, and snippets.

@kotobuki
Created December 14, 2015 01:14
Show Gist options
  • Save kotobuki/c253171f4e6e902503f7 to your computer and use it in GitHub Desktop.
Save kotobuki/c253171f4e6e902503f7 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Meshblu Subscriber</title>
<script src="http://meshblu.octoblu.com/js/meshblu.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
var conn = meshblu.createConnection({
"uuid": "********-****-****-****-************",
"token": "********",
"server": "***.***.***.***",
"port": 443
});
conn.on('ready', function(data){
console.log('UUID AUTHENTICATED!');
console.log(data);
conn.on('message', function (message) {
console.log('message received', message);
var now = new Date();
var nowInString = ("0" + now.getHours()).slice(-2) + ":" + ("0" + now.getMinutes()).slice(-2) + ":" + ("0" + now.getSeconds()).slice(-2);
$(".activity").prepend(nowInString + " " + JSON.stringify(message) + '<br />');
});
});
</script>
</head>
<body>
<p>Subscribed Messages</p>
<div class="activity"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment