You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,14 @@ The API is simply methods and properties of the `WebsocketServer` class.
41
41
42
42
## WebsocketServer
43
43
44
-
The WebsocketServer takes two arguments: a `port` and a `hostname`.
45
-
By default the localhost `127.0.0.1` is used. However if you want to be able and connect
46
-
to the server from the network you need to pass `0.0.0.0` as hostname e.g. `WebsocketServer(13254, host='0.0.0.0')`.
44
+
The WebsocketServer can be initialized with the below parameters.
45
+
46
+
*`port`* - The port clients will need to connect to.
47
+
48
+
*`host`* - By default the `127.0.0.1` is used which allows connections only from the current machine. If you wish to allow all network machines to connect, you need to pass `0.0.0.0` as hostname.
49
+
50
+
*`loglevel`* - logging level to print. By default WARNING is used. You can use `logging.DEBUG` or `logging.INFO` for more verbose output.
51
+
47
52
48
53
###Properties
49
54
@@ -72,18 +77,18 @@ to the server from the network you need to pass `0.0.0.0` as hostname e.g. `Webs
72
77
|`set_fn_message_received()`| Called when a `client` sends a `message`| client, server, message |
73
78
74
79
75
-
The client passed to the callback is the client that left, sent the message, etc. The server might not have any use to use. However it is
76
-
passed in case you want to send messages to clients.
80
+
The client passed to the callback is the client that left, sent the message, etc. The server might not have any use to use. However it is passed in case you want to send messages to clients.
77
81
78
82
79
83
Example:
80
84
````
85
+
import logging
81
86
from websocket_server import WebsocketServer
82
87
83
88
def new_client(client, server):
84
89
server.send_message_to_all("Hey all, a new client has joined us")
85
90
86
-
server = WebsocketServer(13254, host='127.0.0.1')
91
+
server = WebsocketServer(13254, host='127.0.0.1', loglevel=logging.INFO)
0 commit comments