Last active
February 29, 2016 04:42
-
-
Save mechamogera/41aa6b386040aae08c0f to your computer and use it in GitHub Desktop.
Pepperのイベントをjavascriptで受け取る(localサーバーからだとできなくてS3に配置するとできた)
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
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Pepper event catch test</title> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="libs/qimessaging/1.0/jquery.min.js"></script> | |
<script src="libs/qimessaging/1.0/qimessaging.js"></script> | |
<script> | |
var session = new QiSession("10.247.85.167"); | |
session.socket().on('connect', function() { | |
console.log("connected!"); | |
$('#result_text').val("connected!\n"); | |
var svc = session.service("ALMemory"); | |
svc.done(function(ins) { | |
ins.subscriber("PeoplePerception/PeopleList").done(function(subscriber) { | |
subscriber.signal.connect(peopleHandler); | |
}); | |
ins.subscriber("PeoplePerception/JustArrived").done(function(subscriber) { | |
subscriber.signal.connect(peopleArrivedHandler); | |
}); | |
}); | |
function peopleHandler(value) { | |
console.log("イベント発生:" + value); | |
$('#result_text').val($('#result_text').val() + "イベント発生" + value + "\n"); | |
}; | |
function peopleArrivedHandler(value) { | |
console.log("人追加:" + value); | |
$('#result_text').val($('#result_text').val() + "人追加:" + value + "\n"); | |
}; | |
}).on('disconnect', function() { | |
console.log("切断"); | |
}); | |
</script> | |
</head> | |
<body> | |
<textarea id="result_text" cols="100" rows="10"> | |
</textarea> | |
<br /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment