@rbxts/tether 1.2.1 → 1.2.3
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.
- package/out/builtin-middlewares.d.ts +1 -1
- package/out/message-emitter.d.ts +11 -2
- package/out/message-emitter.luau +30 -0
- package/package.json +49 -49
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Modding } from "@flamework/core";
|
|
2
2
|
import type { SerializerMetadata } from "@rbxts/flamework-binary-serializer";
|
|
3
|
+
import type { Any } from "ts-toolbelt";
|
|
3
4
|
import { type SharedMiddleware } from "./middleware";
|
|
4
5
|
import type { TetherPacket } from "./structs";
|
|
5
|
-
import { Any } from "ts-toolbelt";
|
|
6
6
|
export declare namespace BuiltinMiddlewares {
|
|
7
7
|
/**
|
|
8
8
|
* Creates a shared middleware that will simulate a ping of the given amount when a message is sent
|
package/out/message-emitter.d.ts
CHANGED
|
@@ -61,14 +61,23 @@ export declare class MessageEmitter<MessageData> extends Destroyable {
|
|
|
61
61
|
*/
|
|
62
62
|
once: <Kind extends keyof MessageData>(message: Kind & BaseMessage, callback: ClientMessageCallback<MessageData[Kind]>) => () => void;
|
|
63
63
|
/**
|
|
64
|
-
* Emits a message to a specific client
|
|
64
|
+
* Emits a message to a specific client or multiple clients
|
|
65
65
|
*
|
|
66
|
-
* @param player The player to whom the message is sent
|
|
66
|
+
* @param player The player(s) to whom the message is sent
|
|
67
67
|
* @param message The message kind to be sent
|
|
68
68
|
* @param data The data associated with the message
|
|
69
69
|
* @param unreliable Whether the message should be sent unreliably
|
|
70
70
|
*/
|
|
71
71
|
emit: <Kind extends keyof MessageData>(player: Player | Player[], message: Kind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Emits a message to all clients except the specified client(s)
|
|
74
|
+
*
|
|
75
|
+
* @param player The player(s) to whom the message is not sent
|
|
76
|
+
* @param message The message kind to be sent
|
|
77
|
+
* @param data The data associated with the message
|
|
78
|
+
* @param unreliable Whether the message should be sent unreliably
|
|
79
|
+
*/
|
|
80
|
+
emitExcept: <Kind extends keyof MessageData>(player: Player | Player[], message: Kind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => void;
|
|
72
81
|
/**
|
|
73
82
|
* Emits a message to all connected clients
|
|
74
83
|
*
|
package/out/message-emitter.luau
CHANGED
|
@@ -175,6 +175,36 @@ do
|
|
|
175
175
|
send(player, getPacket())
|
|
176
176
|
end)
|
|
177
177
|
end,
|
|
178
|
+
emitExcept = function(player, message, data, unreliable)
|
|
179
|
+
if unreliable == nil then
|
|
180
|
+
unreliable = false
|
|
181
|
+
end
|
|
182
|
+
local shouldSendTo = function(p)
|
|
183
|
+
local _player = player
|
|
184
|
+
local _result
|
|
185
|
+
if typeof(_player) == "Instance" then
|
|
186
|
+
_result = p ~= player
|
|
187
|
+
else
|
|
188
|
+
local _player_1 = player
|
|
189
|
+
local _p = p
|
|
190
|
+
_result = not (table.find(_player_1, _p) ~= nil)
|
|
191
|
+
end
|
|
192
|
+
return _result
|
|
193
|
+
end
|
|
194
|
+
local _client = self.client
|
|
195
|
+
local _exp = Players:GetPlayers()
|
|
196
|
+
-- ▼ ReadonlyArray.filter ▼
|
|
197
|
+
local _newValue = {}
|
|
198
|
+
local _length = 0
|
|
199
|
+
for _k, _v in _exp do
|
|
200
|
+
if shouldSendTo(_v, _k - 1, _exp) == true then
|
|
201
|
+
_length += 1
|
|
202
|
+
_newValue[_length] = _v
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
-- ▲ ReadonlyArray.filter ▲
|
|
206
|
+
_client.emit(_newValue, message, data, unreliable)
|
|
207
|
+
end,
|
|
178
208
|
emitAll = function(message, data, unreliable)
|
|
179
209
|
if unreliable == nil then
|
|
180
210
|
unreliable = false
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rbxts/tether",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"main": "out/init.lua",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "rbxtsc",
|
|
7
|
-
"watch": "rbxtsc -w",
|
|
8
|
-
"prepublishOnly": "npm run build"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"roblox",
|
|
12
|
-
"tether",
|
|
13
|
-
"networking",
|
|
14
|
-
"message",
|
|
15
|
-
"serialization",
|
|
16
|
-
"middleware"
|
|
17
|
-
],
|
|
18
|
-
"repository": {
|
|
19
|
-
"url": "git+https://github.com/R-unic/tether.git"
|
|
20
|
-
},
|
|
21
|
-
"author": "runicly",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"description": "A message-based networking solution for Roblox with automatic binary serialization and type validation",
|
|
24
|
-
"types": "out/index.d.ts",
|
|
25
|
-
"files": [
|
|
26
|
-
"out",
|
|
27
|
-
"!**/*.tsbuildinfo"
|
|
28
|
-
],
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
34
|
-
"@rbxts/types": "^1.0.835",
|
|
35
|
-
"rbxts-transformer-flamework": "^1.2.4",
|
|
36
|
-
"roblox-ts": "^3.0.0",
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@flamework/
|
|
42
|
-
"@
|
|
43
|
-
"@rbxts/
|
|
44
|
-
"@rbxts/flamework-
|
|
45
|
-
"@rbxts/
|
|
46
|
-
"@rbxts/
|
|
47
|
-
"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@rbxts/tether",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"main": "out/init.lua",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rbxtsc",
|
|
7
|
+
"watch": "rbxtsc -w",
|
|
8
|
+
"prepublishOnly": "npm run build"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"roblox",
|
|
12
|
+
"tether",
|
|
13
|
+
"networking",
|
|
14
|
+
"message",
|
|
15
|
+
"serialization",
|
|
16
|
+
"middleware"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"url": "git+https://github.com/R-unic/tether.git"
|
|
20
|
+
},
|
|
21
|
+
"author": "runicly",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"description": "A message-based networking solution for Roblox with automatic binary serialization and type validation",
|
|
24
|
+
"types": "out/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"out",
|
|
27
|
+
"!**/*.tsbuildinfo"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
34
|
+
"@rbxts/types": "^1.0.835",
|
|
35
|
+
"rbxts-transformer-flamework": "^1.2.4",
|
|
36
|
+
"roblox-ts": "^3.0.0",
|
|
37
|
+
"typescript": "^5.5.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@flamework/core": "^1.2.4",
|
|
41
|
+
"@flamework/networking": "^1.2.4",
|
|
42
|
+
"@rbxts/destroyable": "^1.0.1",
|
|
43
|
+
"@rbxts/flamework-binary-serializer": "^0.6.0",
|
|
44
|
+
"@rbxts/flamework-meta-utils": "^1.0.4",
|
|
45
|
+
"@rbxts/repr": "^1.0.1",
|
|
46
|
+
"@rbxts/services": "^1.5.5",
|
|
47
|
+
"ts-toolbelt": "^9.6.0"
|
|
48
|
+
}
|
|
49
|
+
}
|