branch: externals/websocket
commit 19f9b3b74f1dd980fb2d24c16816755f2428ba06
Merge: 4f8ddb64bc 8d0ca79cd3
Author: Andrew Hyatt <[email protected]>
Commit: Andrew Hyatt <[email protected]>
Merge pull request #44 from chwarr/websocket-server-host
Allow websocket-server's listen host to be set
---
testserver.py | 2 +-
websocket-functional-test.el | 1 +
websocket.el | 6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/testserver.py b/testserver.py
index 5cfcb96156..e75d1d4216 100644
--- a/testserver.py
+++ b/testserver.py
@@ -29,6 +29,6 @@ if __name__ == "__main__":
(r"/", EchoWebSocket),
])
server = httpserver.HTTPServer(application)
- server.listen(9999)
+ server.listen(9999, "127.0.0.1")
logging.info("STARTED: Server start listening")
ioloop.IOLoop.instance().start()
diff --git a/websocket-functional-test.el b/websocket-functional-test.el
index 65d560b0fd..9bab87b399 100644
--- a/websocket-functional-test.el
+++ b/websocket-functional-test.el
@@ -126,6 +126,7 @@
(setq wstest-closed nil)
(setq server-conn (websocket-server
9998
+ :host 'local
:on-message (lambda (ws frame)
(message "Server received text!")
(websocket-send-text ws
diff --git a/websocket.el b/websocket.el
index 1b0b29436a..3b048da95c 100644
--- a/websocket.el
+++ b/websocket.el
@@ -820,6 +820,11 @@ of populating the list of server extensions to WEBSOCKET."
(defun* websocket-server (port &rest plist)
"Open a websocket server on PORT.
+If the plist contains a `:host' HOST pair, this value will be
+used to configure the addresses the socket listens on. The symbol
+`local' specifies the local host. If unspecified or nil, the
+socket will listen on all addresses.
+
This also takes a plist of callbacks: `:on-open', `:on-message',
`:on-close' and `:on-error', which operate exactly as documented
in the websocket client function `websocket-open'. Returns the
@@ -833,6 +838,7 @@ connection, which should be kept in order to pass to
:log 'websocket-server-accept
:filter-multibyte nil
:plist plist
+ :host (plist-get plist :host)
:service port)))
conn))