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
Note that the data returned is as a buffer because that is how tcp sends data, and the packets sent by the client are sent as stacked because they were sent too fast.
62
76
63
77
#### Client:
78
+
64
79
```javascript
65
-
let {TCPClient} =require('./TCPService');
80
+
let {TCPClient} =require('./Limitless-TCP');
66
81
67
82
let tcpClient =newTCPClient('127.0.0.1', 1234, true);
68
83
69
84
tcpClient.connect();
70
85
71
86
tcpClient.on('connect', () => {
72
-
console.log('s')
73
87
tcpClient.emit({type:'test', data:'This is a test packet 1'});
74
88
tcpClient.emit({type:'test', data:'This is a test packet 2'});
This will not work the other way around, meaning you are not able to connect a normal tcp client to a Limitless TCP server.
80
94
81
95
## Server:
82
-
```javascript
83
-
let { TCPServer } =require('TCPService');
84
96
85
-
let tcpServer =newTCPServer(num: port, bool: useHeartbeat)
97
+
```javascript
98
+
let {TCPServer} =require('Limitless-TCP');
99
+
100
+
let tcpServer =newTCPServer(num
101
+
:
102
+
port, bool
103
+
:
104
+
useHeartbeat
105
+
)
86
106
tcpServer.listen();
87
107
88
-
tcpServer.on(str:event, null/socket: socket, (callback) => {}); //If the socket field is null then it listens for tcpServer events instead of socket specific
89
-
tcpServer.emit(data, socket: socket);
108
+
tcpServer.on(str
109
+
:
110
+
event, null/ socket
111
+
:
112
+
socket, (callback) => {
113
+
}
114
+
)
115
+
; //If the socket field is null then it listens for tcpServer events instead of socket specific
116
+
tcpServer.emit(data, socket
117
+
:
118
+
socket
119
+
)
120
+
;
90
121
```
91
122
92
123
### Connected Sockets and All Sockets:
@@ -116,7 +147,7 @@ Refer to tcp docs for callback information
116
147
There is a different error that is thrown when the heartbeats timeout. This error is the same on the server and the client.
117
148
```bash
118
149
TCPServiceError [Heartbeat Error]: The heartbeat counter has timed out
119
-
at Timeout._onTimeout (Path\To\TCPService.js:225:43)
150
+
at Timeout._onTimeout (Path\To\Limitless-TCP.js:225:43)
120
151
at listOnTimeout (node:internal/timers:564:17)
121
152
at process.processTimers (node:internal/timers:507:7) {
122
153
Details: 'This socket has timed out from the server.'
0 commit comments