@rbxts/tether 1.0.9 → 1.0.10
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/README.md +15 -16
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Tether
|
|
2
2
|
A message-based networking solution for Roblox with automatic binary serialization.
|
|
3
3
|
|
|
4
|
+
> [!CAUTION]
|
|
5
|
+
> Depends on `rbxts-transformer-flamework`!
|
|
6
|
+
|
|
4
7
|
## Usage
|
|
5
8
|
|
|
6
9
|
### In `shared/messaging.ts`
|
|
@@ -49,25 +52,21 @@ Drop or delay requests
|
|
|
49
52
|
|
|
50
53
|
### Creating middleware
|
|
51
54
|
|
|
52
|
-
#### Client
|
|
55
|
+
#### Client, Global
|
|
53
56
|
```ts
|
|
54
|
-
import
|
|
57
|
+
import type { ClientGlobalMiddleware } from "@rbxts/tether";
|
|
55
58
|
|
|
56
|
-
export function logClient():
|
|
57
|
-
return message
|
|
58
|
-
(player, data) =>
|
|
59
|
-
print(`[LOG]: Message ${message} sent to player ${player} with data ${data}`);
|
|
59
|
+
export function logClient(): ClientGlobalMiddleware {
|
|
60
|
+
return (player, data) => print(`[LOG]: Sent message to player ${player} with data:`, data);
|
|
60
61
|
}
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
#### Server
|
|
64
|
+
#### Server, Global
|
|
64
65
|
```ts
|
|
65
|
-
import
|
|
66
|
+
import type { ServerGlobalMiddleware } from "@rbxts/tether";
|
|
66
67
|
|
|
67
|
-
export function logServer():
|
|
68
|
-
return message
|
|
69
|
-
data =>
|
|
70
|
-
print(`[LOG]: Message ${message} sent to server with data ${data}`);
|
|
68
|
+
export function logServer(): ServerGlobalMiddleware {
|
|
69
|
+
return data => print(`[LOG]: Sent message to server with data:`, data);
|
|
71
70
|
}
|
|
72
71
|
```
|
|
73
72
|
|
|
@@ -78,8 +77,8 @@ import { type SharedMiddleware, DropRequest } from "@rbxts/tether";
|
|
|
78
77
|
export function rateLimit(interval: number): SharedMiddleware<MessageData> {
|
|
79
78
|
let lastRequest = 0;
|
|
80
79
|
|
|
81
|
-
return message =>
|
|
82
|
-
() => {
|
|
80
|
+
return message => // message attempting to be sent
|
|
81
|
+
() => { // no data/player - it's a shared middleware
|
|
83
82
|
if (os.clock() - lastRequest < interval)
|
|
84
83
|
return DropRequest;
|
|
85
84
|
|
|
@@ -101,8 +100,8 @@ messaging.middleware
|
|
|
101
100
|
// automatically validates that the data sent through the remote matches
|
|
102
101
|
// the data associated with the message at runtime using type guards
|
|
103
102
|
.useShared(Message.Test, [BuiltinMiddlewares.validateClient()])
|
|
104
|
-
.useClientGlobal([
|
|
105
|
-
.useServerGlobal([
|
|
103
|
+
.useClientGlobal([logClient()]);
|
|
104
|
+
.useServerGlobal([logServer()]);
|
|
106
105
|
|
|
107
106
|
export const enum Message {
|
|
108
107
|
Test
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/tether",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "out/init.lua",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rbxtsc",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
34
34
|
"@rbxts/types": "^1.0.835",
|
|
35
|
-
"rbxts-transformer-flamework": "
|
|
35
|
+
"rbxts-transformer-flamework": "^1.2.4",
|
|
36
36
|
"roblox-ts": "^3.0.0",
|
|
37
37
|
"typescript": "^5.5.3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@flamework/core": "^1.2.
|
|
41
|
-
"@flamework/networking": "^1.2.
|
|
40
|
+
"@flamework/core": "^1.2.4",
|
|
41
|
+
"@flamework/networking": "^1.2.4",
|
|
42
42
|
"@rbxts/destroyable": "^1.0.1",
|
|
43
43
|
"@rbxts/flamework-binary-serializer": "^0.6.0",
|
|
44
44
|
"@rbxts/services": "^1.5.5"
|