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
Now we've got a server running at `localhost:8080` that listen for a `say` text event and send a `id` integer event to every client that connects.
70
70
71
-
_See an [full example of server setup](demo-server.js)._
71
+
_See an [full example of server setup](demo/server.js)._
72
72
73
73
### Write a Client
74
74
75
75
Now we write a client, for the browser, that connects to our running server on `ws://localhost:8080` and use a BinaryEncoder with the same event list as the server.
client.send('greeting','Hello, I\'m client 😊! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut imperdiet molestie libero, ut sollicitudin tortor dignissim quis. Nulla iaculis nisi turpis, a malesuada nibh faucibus a. Nunc tellus lorem, varius sit amet tellus eu, dictum consectetur nulla.');
s.Send(&netcode.Message{"greeting", "Hello, I'm server! 😊 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut imperdiet molestie libero, ut sollicitudin tortor dignissim quis. Nulla iaculis nisi turpis, a malesuada nibh faucibus a. Nunc tellus lorem, varius sit amet tellus eu, dictum consectetur nulla."})
client.send('greeting','Hello, I\'m server! 😊 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut imperdiet molestie libero, ut sollicitudin tortor dignissim quis. Nulla iaculis nisi turpis, a malesuada nibh faucibus a. Nunc tellus lorem, varius sit amet tellus eu, dictum consectetur nulla.');
| autoStart |_Boolean_|`true`| Should the server start listening immediatly? |
15
16
16
17
### Methods
17
18
@@ -27,8 +28,6 @@ Listen for event.
27
28
28
29
Remove listener for this event / callback.
29
30
30
-
_Note: If you're on node `< 10.0.0`, use `removeListener` method instead of `off`_
31
-
32
31
### Events
33
32
34
33
| Name | Callback parameters | Description |
@@ -76,4 +75,4 @@ _Note: If you're on node `< 10.0.0`, use `removeListener` method instead of `off
76
75
|`close`| client _{Client_} | Client connection is closed. |
77
76
| * | - eventData _{Number\|String\|Boolean\|Object}_<br />- client _Client_| Every event sent through the websocket pipe will emit an event on the other end of the socket. |
78
77
79
-
_Note: `open`, `error` and `close` are reserved event names and the Encoder will throw an exeption if you define a custom event with either of these names._
78
+
_Note: `open`, `error` and `close` are reserved event names and the Encoder will throw an exeption if you define a custom event with either of these names._
0 commit comments