1
1
diff --git a/src/client/chat.js b/src/client/chat.js
2
- index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648303628c7 100644
2
+ index 0021870994fc59a82f0ac8aba0a65a8be43ef2f4..a53fceb843105ea2a1d88722b3fc7c3b43cb102a 100644
3
3
--- a/src/client/chat.js
4
4
+++ b/src/client/chat.js
5
- @@ -110 ,7 +110 ,7 @@ module.exports = function (client, options) {
5
+ @@ -116 ,7 +116 ,7 @@ module.exports = function (client, options) {
6
6
for (const player of packet.data) {
7
7
if (player.chatSession) {
8
8
client._players[player.uuid] = {
@@ -11,16 +11,16 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
11
11
publicKeyDER: player.chatSession.publicKey.keyBytes,
12
12
sessionUuid: player.chatSession.uuid
13
13
}
14
- @@ -120 ,7 +120 ,7 @@ module.exports = function (client, options) {
15
-
14
+ @@ -126 ,7 +126 ,7 @@ module.exports = function (client, options) {
15
+
16
16
if (player.crypto) {
17
17
client._players[player.uuid] = {
18
18
- publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
19
19
+ // publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
20
20
publicKeyDER: player.crypto.publicKey,
21
21
signature: player.crypto.signature,
22
22
displayName: player.displayName || player.name
23
- @@ -190 ,7 +190 ,7 @@ module.exports = function (client, options) {
23
+ @@ -196 ,7 +196 ,7 @@ module.exports = function (client, options) {
24
24
if (mcData.supportFeature('useChatSessions')) {
25
25
const tsDelta = BigInt(Date.now()) - packet.timestamp
26
26
const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0
@@ -29,16 +29,16 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
29
29
if (verified) client._signatureCache.push(packet.signature)
30
30
client.emit('playerChat', {
31
31
globalIndex: packet.globalIndex,
32
- @@ -356 ,7 +356 ,7 @@ module.exports = function (client, options) {
32
+ @@ -362 ,7 +362 ,7 @@ module.exports = function (client, options) {
33
33
}
34
34
}
35
-
35
+
36
36
- client._signedChat = (message, options = {}) => {
37
37
+ client._signedChat = async (message, options = {}) => {
38
38
options.timestamp = options.timestamp || BigInt(Date.now())
39
39
options.salt = options.salt || 1n
40
-
41
- @@ -401 ,7 +401 ,7 @@ module.exports = function (client, options) {
40
+
41
+ @@ -407 ,7 +407 ,7 @@ module.exports = function (client, options) {
42
42
message,
43
43
timestamp: options.timestamp,
44
44
salt: options.salt,
@@ -47,7 +47,7 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
47
47
offset: client._lastSeenMessages.pending,
48
48
checksum: computeChatChecksum(client._lastSeenMessages), // 1.21.5+
49
49
acknowledged
50
- @@ -416 ,7 +416 ,7 @@ module.exports = function (client, options) {
50
+ @@ -422 ,7 +422 ,7 @@ module.exports = function (client, options) {
51
51
message,
52
52
timestamp: options.timestamp,
53
53
salt: options.salt,
@@ -71,10 +71,10 @@ index 63cc2bd9615100bd2fd63dfe14c094aa6b8cd1c9..36df57d1196af9761d920fa285ac48f8
71
71
+ // clearTimeout(loginTimeout)
72
72
+ // })
73
73
}
74
-
74
+
75
75
function onJoinServerResponse (err) {
76
76
diff --git a/src/client.js b/src/client.js
77
- index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c648ab192 100644
77
+ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..54bb9e6644388e9b6bd42b3012951875989cdf0c 100644
78
78
--- a/src/client.js
79
79
+++ b/src/client.js
80
80
@@ -111,7 +111,13 @@ class Client extends EventEmitter {
@@ -94,7 +94,7 @@ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c
94
94
}
95
95
@@ -169,7 +175,10 @@ class Client extends EventEmitter {
96
96
}
97
-
97
+
98
98
const onFatalError = (err) => {
99
99
- this.emit('error', err)
100
100
+ // todo find out what is trying to write after client disconnect
@@ -103,58 +103,23 @@ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c
103
103
+ }
104
104
endSocket()
105
105
}
106
-
107
- @@ -198,6 +207,8 @@ class Client extends EventEmitter {
106
+
107
+ @@ -198,6 +207,10 @@ class Client extends EventEmitter {
108
108
serializer -> framer -> socket -> splitter -> deserializer */
109
109
if (this.serializer) {
110
110
this.serializer.end()
111
- + this.socket?.end()
112
- + this.socket?.emit('end')
111
+ + setTimeout(() => {
112
+ + this.socket?.end()
113
+ + this.socket?.emit('end')
114
+ + }, 2000) // allow the serializer to finish writing
113
115
} else {
114
116
if (this.socket) this.socket.end()
115
117
}
116
- @@ -243,6 +254 ,7 @@ class Client extends EventEmitter {
118
+ @@ -243,6 +256 ,7 @@ class Client extends EventEmitter {
117
119
debug('writing packet ' + this.state + '.' + name)
118
120
debug(params)
119
121
}
120
122
+ this.emit('writePacket', name, params)
121
123
this.serializer.write({ name, params })
122
124
}
123
-
124
- diff --git a/src/client.js.rej b/src/client.js.rej
125
- new file mode 100644
126
- index 0000000000000000000000000000000000000000..1101e2477adfdc004381b78e7d70953dacb7b484
127
- --- /dev/null
128
- +++ b/src/client.js.rej
129
- @@ -0,0 +1,31 @@
130
- + @@ -89,10 +89,12 @@
131
- + parsed.metadata.name = parsed.data.name
132
- + parsed.data = parsed.data.params
133
- + parsed.metadata.state = state
134
- + - debug('read packet ' + state + '.' + parsed.metadata.name)
135
- + - if (debug.enabled) {
136
- + - const s = JSON.stringify(parsed.data, null, 2)
137
- + - debug(s && s.length > 10000 ? parsed.data : s)
138
- + + if (!globalThis.excludeCommunicationDebugEvents?.includes(parsed.metadata.name)) {
139
- + + debug('read packet ' + state + '.' + parsed.metadata.name)
140
- + + if (debug.enabled) {
141
- + + const s = JSON.stringify(parsed.data, null, 2)
142
- + + debug(s && s.length > 10000 ? parsed.data : s)
143
- + + }
144
- + }
145
- + if (this._hasBundlePacket && parsed.metadata.name === 'bundle_delimiter') {
146
- + if (this._mcBundle.length) { // End bundle
147
- + @@ -239,8 +252,11 @@
148
- +
149
- + write (name, params) {
150
- + if (!this.serializer.writable) { return }
151
- + - debug('writing packet ' + this.state + '.' + name)
152
- + - debug(params)
153
- + + if (!globalThis.excludeCommunicationDebugEvents?.includes(name)) {
154
- + + debug(`[${this.state}] from ${this.isServer ? 'server' : 'client'}: ` + name)
155
- + + debug(params)
156
- + + }
157
- + + this.emit('writePacket', name, params)
158
- + this.serializer.write({ name, params })
159
- + }
160
- +
125
+
0 commit comments