Adding hello example/test.

This commit is contained in:
Thomas Hintz 2014-10-18 09:58:16 -07:00
parent 29561c4b71
commit 91396e71e0
2 changed files with 25 additions and 0 deletions

12
test/hello.scm Normal file
View File

@ -0,0 +1,12 @@
(import chicken scheme)
(use spiffy websockets)
(handle-not-found
(lambda (path)
(when (string= path "/web-socket")
(with-websocket
(lambda ()
(send-message (string-append "you said: " (receive-message))))))))
(root-path ".")
(start-server port: 8080)

13
test/index.html Normal file
View File

@ -0,0 +1,13 @@
<html>
<body>
<script type="text/javascript">
var ws = new WebSocket("ws://localhost:8080/web-socket");
ws.onmessage = function(evt) {
alert(evt.data);
};
ws.onopen = function() {
ws.send('Hello!');
}
</script>
</body>
</html>