@rbxts/tether 1.3.24 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -96,12 +96,12 @@ do
|
|
|
96
96
|
local schemaString = if schema ~= nil then " " .. table.concat(string.split(repr(schema[1], {
|
|
97
97
|
pretty = true,
|
|
98
98
|
}), "\n"), "\n ") else "unknown"
|
|
99
|
-
local text = { "\n", horizontalLine, "\n", "Packet sent to ", (if RunService:IsServer() then "client" else "server"), "!\n", " - Message: ", message, "\n", " - Data: ", repr(data, {
|
|
99
|
+
local text = { "\n", horizontalLine, "\n", "Packet sent to ", (if RunService:IsServer() then "client" else "server"), "!\n", " - Message: ", tostring(message), "\n", " - Data: ", repr(data, {
|
|
100
100
|
pretty = true,
|
|
101
101
|
}), "\n", " - Raw data:\n", " - Buffer: ", bufferToString(buf), "\n", " - Blobs: ", repr(blobs, {
|
|
102
102
|
pretty = false,
|
|
103
103
|
robloxClassName = true,
|
|
104
|
-
}), "\n", " - Packet size: ", bufferSize + blobsSize, " bytes\n", " - Buffer: ", bufferSize, " bytes\n", " - Blobs: ", blobsSize, " bytes\n", " - Schema: ", schemaString, "\n", horizontalLine, "\n" }
|
|
104
|
+
}), "\n", " - Packet size: ", tostring(bufferSize + blobsSize), " bytes\n", " - Buffer: ", tostring(bufferSize), " bytes\n", " - Blobs: ", tostring(blobsSize), " bytes\n", " - Schema: ", schemaString, "\n", horizontalLine, "\n" }
|
|
105
105
|
print(table.concat(text, ""))
|
|
106
106
|
end
|
|
107
107
|
end
|
package/out/message-emitter.luau
CHANGED
|
@@ -129,14 +129,17 @@ do
|
|
|
129
129
|
local _returnMessage_1 = returnMessage
|
|
130
130
|
local functions = _clientFunctions_1[_returnMessage_1]
|
|
131
131
|
local returnValue
|
|
132
|
-
|
|
132
|
+
local responseCallback = function(data)
|
|
133
133
|
returnValue = data
|
|
134
134
|
return returnValue
|
|
135
|
-
end
|
|
135
|
+
end
|
|
136
|
+
functions[responseCallback] = true
|
|
136
137
|
self.server.emit(message, data, unreliable)
|
|
137
138
|
while returnValue == nil do
|
|
138
139
|
RunService.Heartbeat:Wait()
|
|
139
140
|
end
|
|
141
|
+
-- Clean up the callback after receiving the response
|
|
142
|
+
functions[responseCallback] = nil
|
|
140
143
|
return returnValue
|
|
141
144
|
end),
|
|
142
145
|
setCallback = function(message, returnMessage, callback)
|
|
@@ -145,7 +148,13 @@ do
|
|
|
145
148
|
end
|
|
146
149
|
return self.server.on(message, function(player, data)
|
|
147
150
|
local returnValue = callback(player, data)
|
|
148
|
-
|
|
151
|
+
-- Defer the response emission to end of frame and swap context to avoid context check issues
|
|
152
|
+
-- task.defer guarantees response is sent by end of current frame, ensuring predictable timing in production
|
|
153
|
+
task.defer(function()
|
|
154
|
+
setLuneContext("server")
|
|
155
|
+
self.client.emit(player, returnMessage, returnValue)
|
|
156
|
+
setLuneContext("both")
|
|
157
|
+
end)
|
|
149
158
|
end)
|
|
150
159
|
end,
|
|
151
160
|
}
|
|
@@ -254,14 +263,17 @@ do
|
|
|
254
263
|
local _returnMessage_1 = returnMessage
|
|
255
264
|
local functions = _serverFunctions_1[_returnMessage_1]
|
|
256
265
|
local returnValue
|
|
257
|
-
|
|
266
|
+
local responseCallback = function(data)
|
|
258
267
|
returnValue = data
|
|
259
268
|
return returnValue
|
|
260
|
-
end
|
|
269
|
+
end
|
|
270
|
+
functions[responseCallback] = true
|
|
261
271
|
self.client.emit(player, message, data, unreliable)
|
|
262
272
|
while returnValue == nil do
|
|
263
273
|
RunService.Heartbeat:Wait()
|
|
264
274
|
end
|
|
275
|
+
-- Clean up the callback after receiving the response
|
|
276
|
+
functions[responseCallback] = nil
|
|
265
277
|
return returnValue
|
|
266
278
|
end),
|
|
267
279
|
setCallback = function(message, returnMessage, callback)
|
|
@@ -270,7 +282,13 @@ do
|
|
|
270
282
|
end
|
|
271
283
|
return self.client.on(message, function(data)
|
|
272
284
|
local returnValue = callback(data)
|
|
273
|
-
|
|
285
|
+
-- Defer the response emission to end of frame and swap context to avoid context check issues
|
|
286
|
+
-- task.defer guarantees response is sent by end of current frame, ensuring predictable timing in production
|
|
287
|
+
task.defer(function()
|
|
288
|
+
setLuneContext("client")
|
|
289
|
+
self.server.emit(returnMessage, returnValue)
|
|
290
|
+
setLuneContext("both")
|
|
291
|
+
end)
|
|
274
292
|
end)
|
|
275
293
|
end,
|
|
276
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/tether",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "out/init.luau",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"setup-rokit": "rokit trust lune-org/lune && rokit trust rojo-rbx/rojo && rokit install",
|
|
@@ -32,20 +32,20 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
35
|
-
"@rbxts/types": "^1.0.
|
|
35
|
+
"@rbxts/types": "^1.0.896",
|
|
36
36
|
"rbxts-transformer-flamework": "^1.3.2",
|
|
37
37
|
"roblox-ts": "^3.0.0",
|
|
38
38
|
"ts-toolbelt": "^9.6.0",
|
|
39
|
-
"typescript": "^5
|
|
39
|
+
"typescript": "^5"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@flamework/core": "^1.3.2",
|
|
43
43
|
"@rbxts/destroyable": "^1.0.9",
|
|
44
|
-
"@rbxts/flamework-meta-utils": "^1.0.
|
|
44
|
+
"@rbxts/flamework-meta-utils": "^1.0.7",
|
|
45
45
|
"@rbxts/object-utils": "^1.0.4",
|
|
46
46
|
"@rbxts/repr": "^1.0.3",
|
|
47
47
|
"@rbxts/serio": "^1.0.19",
|
|
48
|
-
"@rbxts/services": "^1.
|
|
48
|
+
"@rbxts/services": "^1.6.0",
|
|
49
49
|
"@rbxts/trash": "^1.0.8"
|
|
50
50
|
}
|
|
51
51
|
}
|