@netifyjs/protocol 1.0.0-alpha.3 → 1.0.0-beta.1
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/package.json +2 -2
- package/src/codec/index.ts +51 -221
- package/src/dispatch/dispatcher/index.ts +89 -47
- package/src/dispatch/session/index.ts +6 -24
- package/src/index.ts +2 -4
- package/src/photon/balancing/codec/index.ts +27 -53
- package/src/photon/balancing/format/authenticate/request/index.ts +52 -6
- package/src/photon/balancing/format/friends/request/index.ts +21 -5
- package/src/photon/balancing/format/game/create/request/index.ts +45 -8
- package/src/photon/balancing/format/game/debug/request/index.ts +19 -4
- package/src/photon/balancing/format/game/join/request/index.ts +65 -13
- package/src/photon/balancing/format/game/list/request/index.ts +29 -3
- package/src/photon/balancing/format/game/random/request/index.ts +58 -10
- package/src/photon/balancing/format/groups/request/index.ts +19 -3
- package/src/photon/balancing/format/index.ts +7 -0
- package/src/photon/balancing/format/leave/request/index.ts +19 -3
- package/src/photon/balancing/format/lobby/join/request/index.ts +23 -3
- package/src/photon/balancing/format/lobby/stats/request/index.ts +19 -3
- package/src/photon/balancing/format/once/request/index.ts +31 -8
- package/src/photon/balancing/format/properties/get/request/index.ts +31 -4
- package/src/photon/balancing/format/properties/set/request/index.ts +36 -7
- package/src/photon/balancing/format/raise/request/index.ts +76 -10
- package/src/photon/balancing/format/reader/index.ts +75 -6
- package/src/photon/balancing/format/regions/request/index.ts +16 -1
- package/src/photon/balancing/format/rpc/request/index.ts +26 -3
- package/src/photon/balancing/format/settings/request/index.ts +15 -2
- package/src/photon/balancing/format/shared/credentials/index.ts +77 -33
- package/src/photon/balancing/format/shared/lobby/index.ts +41 -5
- package/src/photon/balancing/format/shared/options/index.ts +56 -24
- package/src/photon/balancing/format/table/index.ts +399 -0
- package/src/photon/balancing/index.ts +11 -1
- package/src/photon/balancing/travel/index.ts +15 -12
- package/src/photon/client/connection/index.ts +6 -6
- package/src/photon/cluster/back/index.ts +32 -45
- package/src/photon/cluster/dresser/index.ts +7 -8
- package/src/photon/cluster/front/index.ts +25 -49
- package/src/photon/cluster/grid/index.ts +1 -1
- package/src/photon/cluster/mover/index.ts +12 -12
- package/src/photon/cluster/press/index.ts +2 -18
- package/src/photon/cluster/route/game/index.ts +9 -11
- package/src/photon/cluster/route/master/index.ts +15 -34
- package/src/photon/cluster/route/name/index.ts +4 -21
- package/src/photon/cluster/seat/game/index.ts +6 -26
- package/src/photon/cluster/seat/master/index.ts +1 -1
- package/src/photon/cluster/sessions/index.ts +5 -6
- package/src/photon/cluster/spread/index.ts +8 -147
- package/src/photon/enet/client/index.ts +1 -8
- package/src/photon/enet/gateway/index.ts +5 -15
- package/src/photon/enet/index.ts +1 -1
- package/src/photon/enet/link/index.ts +34 -15
- package/src/photon/enet/outbound/index.ts +279 -0
- package/src/photon/enet/peer/index.ts +59 -0
- package/src/photon/enet/transport/index.ts +8 -24
- package/src/photon/game/admission/index.ts +353 -0
- package/src/photon/game/bag/index.ts +13 -0
- package/src/photon/game/broadcast/index.ts +79 -0
- package/src/photon/game/editor/index.ts +446 -0
- package/src/photon/game/gate/index.ts +9 -8
- package/src/photon/game/handler/index.ts +30 -3
- package/src/photon/game/history/index.ts +234 -0
- package/src/photon/game/hooked/index.ts +16 -15
- package/src/photon/game/index.ts +12 -1
- package/src/photon/game/lifecycle/index.ts +193 -0
- package/src/photon/game/peer/index.ts +1 -10
- package/src/photon/game/properties/index.ts +342 -0
- package/src/photon/game/room/index.ts +435 -1793
- package/src/photon/game/rooms/index.ts +2 -1
- package/src/photon/game/seats/index.ts +237 -0
- package/src/photon/game/server/index.ts +12 -2
- package/src/photon/game/services/index.ts +41 -0
- package/src/photon/game/settings/index.ts +22 -0
- package/src/photon/game/snapshot/index.ts +133 -0
- package/src/photon/game/throttle/index.ts +60 -0
- package/src/photon/game/touch/index.ts +2 -5
- package/src/photon/game/venue/index.ts +31 -0
- package/src/photon/master/application/index.ts +7 -0
- package/src/photon/master/gate/index.ts +12 -8
- package/src/photon/master/handler/index.ts +36 -748
- package/src/photon/master/index.ts +5 -0
- package/src/photon/master/list/sql/index.ts +37 -3
- package/src/photon/master/listing/index.ts +133 -0
- package/src/photon/master/lobby/index.ts +9 -0
- package/src/photon/master/login/index.ts +424 -0
- package/src/photon/master/matchmaking/index.ts +282 -0
- package/src/photon/master/query/index.ts +45 -0
- package/src/photon/master/redirect/index.ts +8 -7
- package/src/photon/master/services/index.ts +35 -0
- package/src/photon/master/settings/index.ts +44 -0
- package/src/photon/master/sql/cost/index.ts +263 -0
- package/src/photon/master/sql/index.ts +1 -0
- package/src/photon/message/client/index.ts +14 -11
- package/src/photon/message/handler/index.ts +22 -64
- package/src/photon/message/pipeline/index.ts +12 -12
- package/src/photon/message/server/index.ts +87 -43
- package/src/photon/message/watch/index.ts +14 -37
- package/src/photon/server/deferral/index.ts +57 -0
- package/src/photon/server/host/index.ts +32 -10
- package/src/photon/server/index.ts +1 -0
- package/src/photon/tcp/client/index.ts +1 -1
- package/src/photon/tcp/codec/index.ts +13 -42
- package/src/photon/tcp/server/index.ts +4 -4
- package/src/photon/websocket/bridge/index.ts +16 -20
- package/src/photon/websocket/message/index.ts +27 -39
- package/src/photon/websocket/path/index.ts +2 -5
- package/src/scale/fanout/index.ts +6 -6
- package/src/scale/index.ts +2 -4
- package/src/scale/outbound/index.ts +192 -0
- package/src/scale/relay/index.ts +20 -31
- package/src/scale/sink/index.ts +6 -11
- package/src/scale/transport/index.ts +27 -44
- package/src/scale/tunnel/index.ts +37 -91
- package/src/smartfox/common/bluebox/gateway/index.ts +401 -0
- package/src/smartfox/common/bluebox/index.ts +4 -0
- package/src/smartfox/{x2 → common}/bluebox/transport/index.ts +36 -23
- package/src/smartfox/common/index.ts +5 -0
- package/src/smartfox/common/strikes/index.ts +74 -0
- package/src/smartfox/pro/bluebox/index.ts +176 -4
- package/src/smartfox/pro/codec/index.ts +8 -7
- package/src/smartfox/pro/escalation/index.ts +28 -20
- package/src/smartfox/pro/flood/index.ts +2 -2
- package/src/smartfox/pro/format/extension/raw/index.ts +12 -2
- package/src/smartfox/pro/handler/chat/index.ts +11 -8
- package/src/smartfox/pro/handler/login/index.ts +2 -25
- package/src/smartfox/pro/handler/shared/index.ts +4 -3
- package/src/smartfox/pro/index.ts +11 -5
- package/src/smartfox/pro/login/gate/index.ts +166 -0
- package/src/smartfox/pro/login/index.ts +1 -0
- package/src/smartfox/pro/moderation/index.ts +220 -0
- package/src/smartfox/pro/options/index.ts +5 -5
- package/src/smartfox/pro/protocol/index.ts +62 -8
- package/src/smartfox/pro/web/index.ts +33 -26
- package/src/smartfox/pro/zone/index.ts +59 -282
- package/src/smartfox/pro/zones/index.ts +3 -3
- package/src/smartfox/x2/bluebox/index.ts +149 -4
- package/src/smartfox/x2/chat/index.ts +9 -19
- package/src/smartfox/x2/codec/index.ts +31 -39
- package/src/smartfox/x2/config/index.ts +6 -1
- package/src/smartfox/x2/data/array/index.ts +96 -60
- package/src/smartfox/x2/data/object/index.ts +144 -82
- package/src/smartfox/x2/data/serializer/index.ts +41 -23
- package/src/smartfox/x2/flood/gate/index.ts +19 -13
- package/src/smartfox/x2/format/buddy/init/response/index.ts +4 -3
- package/src/smartfox/x2/format/find/rooms/response/index.ts +4 -3
- package/src/smartfox/x2/format/find/users/response/index.ts +4 -3
- package/src/smartfox/x2/format/group/subscribe/response/index.ts +4 -3
- package/src/smartfox/x2/format/login/response/index.ts +4 -3
- package/src/smartfox/x2/format/mmo/position/response/index.ts +8 -6
- package/src/smartfox/x2/format/room/join/response/index.ts +4 -3
- package/src/smartfox/x2/games/index.ts +35 -8
- package/src/smartfox/x2/hall/index.ts +0 -6
- package/src/smartfox/x2/handler/session/index.ts +1 -1
- package/src/smartfox/x2/index.ts +8 -3
- package/src/smartfox/x2/member/index.ts +10 -3
- package/src/smartfox/x2/packet/login/response/index.ts +12 -0
- package/src/smartfox/x2/protocol/index.ts +11 -1
- package/src/smartfox/x2/rooms/index.ts +1 -2
- package/src/smartfox/x2/sessions/index.ts +6 -0
- package/src/smartfox/x2/udp/index.ts +61 -24
- package/src/smartfox/x2/web/index.ts +35 -17
- package/src/smartfox/x2/websocket/index.ts +18 -36
- package/src/smartfox/x2/zone/index.ts +77 -28
- package/src/smartfox/x2/zones/index.ts +17 -5
- package/src/photon/enet/handler/index.ts +0 -65
- package/src/scale/hosted/index.ts +0 -68
- package/src/scale/outlet/index.ts +0 -121
- package/src/smartfox/pro/bluebox/gateway/index.ts +0 -310
- package/src/smartfox/pro/bluebox/session/index.ts +0 -63
- package/src/smartfox/pro/bluebox/transport/index.ts +0 -104
- package/src/smartfox/x2/bluebox/gateway/index.ts +0 -315
- /package/src/smartfox/{x2 → common}/bluebox/session/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/memory/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/offender/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/store/index.ts +0 -0
- /package/src/smartfox/{pro → common}/sequence/index.ts +0 -0
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { PacketCodec } from './codec/index.ts'
|
|
2
|
-
export type { Staging } from './codec/index.ts'
|
|
3
2
|
export {
|
|
4
3
|
Closed,
|
|
5
4
|
Opened,
|
|
@@ -35,7 +34,7 @@ export {
|
|
|
35
34
|
SinkTransport,
|
|
36
35
|
Switchboard,
|
|
37
36
|
Tunnel,
|
|
38
|
-
|
|
37
|
+
TunnelOutbound,
|
|
39
38
|
TunnelRelay,
|
|
40
39
|
TunnelTransport,
|
|
41
40
|
} from './scale/index.ts'
|
|
@@ -54,13 +53,12 @@ export type {
|
|
|
54
53
|
HandoffReturn,
|
|
55
54
|
Hosted,
|
|
56
55
|
MeshOptions,
|
|
57
|
-
OutletSink,
|
|
58
56
|
PendingLoss,
|
|
59
57
|
PlacementRule,
|
|
60
58
|
Portable,
|
|
61
59
|
Reach,
|
|
62
60
|
RelayEvents,
|
|
63
61
|
SwitchboardLocal,
|
|
64
|
-
TransportEvents,
|
|
65
62
|
TunnelOptions,
|
|
63
|
+
TunnelSink,
|
|
66
64
|
} from './scale/index.ts'
|
|
@@ -61,26 +61,24 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
61
61
|
* @param context the connection
|
|
62
62
|
* @param message an envelope from the message layer
|
|
63
63
|
*/
|
|
64
|
-
public override channelRead(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
public override channelRead(context: HandlerContext, message: unknown): void {
|
|
65
|
+
if (!(message instanceof Envelope)) {
|
|
66
|
+
context.fireChannelRead(message)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
69
|
|
|
70
70
|
const envelope = message as Envelope
|
|
71
71
|
const inner = envelope.message
|
|
72
72
|
const travel = Travel.from(envelope)
|
|
73
73
|
if (inner instanceof OperationRequest) {
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (inner instanceof
|
|
78
|
-
|
|
74
|
+
this.request(context, inner, travel)
|
|
75
|
+
} else if (inner instanceof OperationResponse) {
|
|
76
|
+
this.response(context, inner, travel)
|
|
77
|
+
} else if (inner instanceof EventData) {
|
|
78
|
+
this.event(context, inner, travel)
|
|
79
|
+
} else {
|
|
80
|
+
context.fireChannelRead(message)
|
|
79
81
|
}
|
|
80
|
-
|
|
81
|
-
if (inner instanceof EventData) return this.event(context, inner, travel)
|
|
82
|
-
|
|
83
|
-
return context.fireChannelRead(message)
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
/**
|
|
@@ -88,26 +86,7 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
88
86
|
* @param context where the write goes
|
|
89
87
|
* @param message anything heading out
|
|
90
88
|
*/
|
|
91
|
-
public override write(
|
|
92
|
-
context: HandlerContext,
|
|
93
|
-
message: unknown,
|
|
94
|
-
): Promise<void> {
|
|
95
|
-
let envelope: Envelope | null
|
|
96
|
-
try {
|
|
97
|
-
envelope = this.envelope(message)
|
|
98
|
-
} catch (cause) {
|
|
99
|
-
return Promise.reject(new EncoderError('Encoding failed', { cause }))
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return context.write(envelope ?? message)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Sends typed packets as envelopes and the rest untouched, without a promise
|
|
107
|
-
* @param context where the write goes
|
|
108
|
-
* @param message anything heading out
|
|
109
|
-
*/
|
|
110
|
-
public writeSync(context: HandlerContext, message: unknown): boolean {
|
|
89
|
+
public override write(context: HandlerContext, message: unknown): void {
|
|
111
90
|
let envelope: Envelope | null
|
|
112
91
|
try {
|
|
113
92
|
envelope = this.envelope(message)
|
|
@@ -115,9 +94,7 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
115
94
|
throw new EncoderError('Encoding failed', { cause })
|
|
116
95
|
}
|
|
117
96
|
|
|
118
|
-
context.
|
|
119
|
-
|
|
120
|
-
return true
|
|
97
|
+
context.write(envelope ?? message)
|
|
121
98
|
}
|
|
122
99
|
|
|
123
100
|
/**
|
|
@@ -130,7 +107,7 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
130
107
|
context: HandlerContext,
|
|
131
108
|
request: OperationRequest,
|
|
132
109
|
travel: Travel,
|
|
133
|
-
): void
|
|
110
|
+
): void {
|
|
134
111
|
const format = this.catalogue.request(request.code)
|
|
135
112
|
if (format === null) {
|
|
136
113
|
this.refuse(context, request, travel, ErrorMessage.UNKNOWN_OPERATION_CODE)
|
|
@@ -145,7 +122,7 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
145
122
|
return
|
|
146
123
|
}
|
|
147
124
|
|
|
148
|
-
|
|
125
|
+
context.fireChannelRead(packet.via(travel))
|
|
149
126
|
}
|
|
150
127
|
|
|
151
128
|
/**
|
|
@@ -158,10 +135,10 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
158
135
|
context: HandlerContext,
|
|
159
136
|
response: OperationResponse,
|
|
160
137
|
travel: Travel,
|
|
161
|
-
):
|
|
138
|
+
): void {
|
|
162
139
|
const format = this.catalogue.response(response.code)
|
|
163
140
|
if (format === null) {
|
|
164
|
-
|
|
141
|
+
context.fireChannelRead(
|
|
165
142
|
UnknownResponse.of(
|
|
166
143
|
response.code,
|
|
167
144
|
response.returnCode,
|
|
@@ -169,14 +146,10 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
169
146
|
response.parameters,
|
|
170
147
|
).via(travel),
|
|
171
148
|
)
|
|
149
|
+
return
|
|
172
150
|
}
|
|
173
151
|
|
|
174
|
-
|
|
175
|
-
context,
|
|
176
|
-
format,
|
|
177
|
-
ParameterReader.response(response),
|
|
178
|
-
travel,
|
|
179
|
-
)
|
|
152
|
+
this.typed(context, format, ParameterReader.response(response), travel)
|
|
180
153
|
}
|
|
181
154
|
|
|
182
155
|
/**
|
|
@@ -189,8 +162,8 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
189
162
|
context: HandlerContext,
|
|
190
163
|
event: EventData,
|
|
191
164
|
travel: Travel,
|
|
192
|
-
):
|
|
193
|
-
|
|
165
|
+
): void {
|
|
166
|
+
this.typed(
|
|
194
167
|
context,
|
|
195
168
|
this.catalogue.event(event.code),
|
|
196
169
|
ParameterReader.event(event),
|
|
@@ -210,14 +183,15 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
210
183
|
format: BalancingFormat,
|
|
211
184
|
reader: ParameterReader,
|
|
212
185
|
travel: Travel,
|
|
213
|
-
):
|
|
186
|
+
): void {
|
|
214
187
|
const packet = format.read(reader)
|
|
215
188
|
const fault = reader.fault
|
|
216
189
|
if (fault !== null) {
|
|
217
|
-
|
|
190
|
+
context.fireExceptionCaught(new DecoderError(fault))
|
|
191
|
+
return
|
|
218
192
|
}
|
|
219
193
|
|
|
220
|
-
|
|
194
|
+
context.fireChannelRead(packet.via(travel))
|
|
221
195
|
}
|
|
222
196
|
|
|
223
197
|
/**
|
|
@@ -233,7 +207,7 @@ export class BalancingCodec extends DuplexHandlerAdapter {
|
|
|
233
207
|
travel: Travel,
|
|
234
208
|
message: string,
|
|
235
209
|
): void {
|
|
236
|
-
context.
|
|
210
|
+
context.writeAndFlush(
|
|
237
211
|
travel
|
|
238
212
|
.reply()
|
|
239
213
|
.wrap<OperationResponse>(
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type MessageKindId,
|
|
11
11
|
} from '../../contract/index.ts'
|
|
12
12
|
import type { ParameterReader } from '../../reader/index.ts'
|
|
13
|
+
import { OperationTable, Parameter } from '../../table/index.ts'
|
|
13
14
|
import type { ParameterWriter } from '../../writer/index.ts'
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -49,19 +50,64 @@ export class AuthenticateRequestFormat implements BalancingFormat<AuthenticateRe
|
|
|
49
50
|
this.role = role
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Every parameter the request reads
|
|
55
|
+
*/
|
|
56
|
+
private static readonly shape = {
|
|
57
|
+
/**
|
|
58
|
+
* Token from an earlier login
|
|
59
|
+
*/
|
|
60
|
+
token: Parameter.value(ParameterCode.TOKEN),
|
|
61
|
+
...CredentialsFormat.table,
|
|
62
|
+
/**
|
|
63
|
+
* Whether the client wants lobby statistics
|
|
64
|
+
*/
|
|
65
|
+
lobbyStats: Parameter.flag(ParameterCode.LOBBY_STATS),
|
|
66
|
+
/**
|
|
67
|
+
* Bit flags the servers pass along
|
|
68
|
+
*/
|
|
69
|
+
flags: Parameter.int(ParameterCode.FLAGS),
|
|
70
|
+
/**
|
|
71
|
+
* Transport the client means to use next
|
|
72
|
+
*/
|
|
73
|
+
expectedProtocol: Parameter.byte(ParameterCode.EXPECTED_PROTOCOL),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The parameters laid out for reading
|
|
78
|
+
*/
|
|
79
|
+
private static readonly table = OperationTable.of(
|
|
80
|
+
AuthenticateRequestFormat.shape,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Name Server parameters with a required region
|
|
85
|
+
*/
|
|
86
|
+
private static readonly regional = OperationTable.of({
|
|
87
|
+
...AuthenticateRequestFormat.shape,
|
|
88
|
+
/**
|
|
89
|
+
* Region the client wants
|
|
90
|
+
*/
|
|
91
|
+
region: CredentialsFormat.table.region.required(),
|
|
92
|
+
})
|
|
93
|
+
|
|
52
94
|
/**
|
|
53
95
|
* Reads the token form or the full one
|
|
54
96
|
* @param reader the request's parameters
|
|
55
97
|
*/
|
|
56
98
|
public read(reader: ParameterReader): AuthenticateRequest {
|
|
57
|
-
|
|
99
|
+
const table =
|
|
100
|
+
this.role === ServerRole.NAME
|
|
101
|
+
? AuthenticateRequestFormat.regional
|
|
102
|
+
: AuthenticateRequestFormat.table
|
|
103
|
+
const values = reader.read<typeof AuthenticateRequestFormat.table>(table)
|
|
58
104
|
|
|
59
105
|
return AuthenticateRequest.of(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
106
|
+
values.token,
|
|
107
|
+
CredentialsFormat.from(reader, values),
|
|
108
|
+
values.lobbyStats ?? false,
|
|
109
|
+
values.flags,
|
|
110
|
+
values.expectedProtocol,
|
|
65
111
|
)
|
|
66
112
|
}
|
|
67
113
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type MessageKindId,
|
|
9
9
|
} from '../../contract/index.ts'
|
|
10
10
|
import type { ParameterReader } from '../../reader/index.ts'
|
|
11
|
+
import { OperationTable, Parameter } from '../../table/index.ts'
|
|
11
12
|
import type { ParameterWriter } from '../../writer/index.ts'
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -15,6 +16,22 @@ import type { ParameterWriter } from '../../writer/index.ts'
|
|
|
15
16
|
* @class
|
|
16
17
|
*/
|
|
17
18
|
export class FindFriendsRequestFormat implements BalancingFormat<FindFriendsRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* User ids to look for
|
|
25
|
+
*/
|
|
26
|
+
userIds: Parameter.texts(
|
|
27
|
+
ParameterCode.FIND_FRIENDS_REQUEST_LIST,
|
|
28
|
+
).required(),
|
|
29
|
+
/**
|
|
30
|
+
* Option bits
|
|
31
|
+
*/
|
|
32
|
+
options: Parameter.int(ParameterCode.FIND_FRIENDS_OPTIONS),
|
|
33
|
+
})
|
|
34
|
+
|
|
18
35
|
/**
|
|
19
36
|
* Always a request
|
|
20
37
|
*/
|
|
@@ -35,12 +52,11 @@ export class FindFriendsRequestFormat implements BalancingFormat<FindFriendsRequ
|
|
|
35
52
|
* @param reader the request's parameters
|
|
36
53
|
*/
|
|
37
54
|
public read(reader: ParameterReader): FindFriendsRequest {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.require(ParameterCode.FIND_FRIENDS_REQUEST_LIST)
|
|
41
|
-
.texts(ParameterCode.FIND_FRIENDS_REQUEST_LIST) ?? [],
|
|
42
|
-
reader.int(ParameterCode.FIND_FRIENDS_OPTIONS),
|
|
55
|
+
const values = reader.read<typeof FindFriendsRequestFormat.table>(
|
|
56
|
+
FindFriendsRequestFormat.table,
|
|
43
57
|
)
|
|
58
|
+
|
|
59
|
+
return FindFriendsRequest.of(values.userIds ?? [], values.options)
|
|
44
60
|
}
|
|
45
61
|
|
|
46
62
|
/**
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type MessageKindId,
|
|
9
9
|
} from '../../../contract/index.ts'
|
|
10
10
|
import type { ParameterReader } from '../../../reader/index.ts'
|
|
11
|
+
import { OperationTable, Parameter } from '../../../table/index.ts'
|
|
11
12
|
import { LobbyFormat } from '../../../shared/lobby/index.ts'
|
|
12
13
|
import { RoomOptionsFormat } from '../../../shared/options/index.ts'
|
|
13
14
|
import type { ParameterWriter } from '../../../writer/index.ts'
|
|
@@ -17,6 +18,38 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
17
18
|
* @class
|
|
18
19
|
*/
|
|
19
20
|
export class CreateGameRequestFormat implements BalancingFormat<CreateGameRequest> {
|
|
21
|
+
/**
|
|
22
|
+
* Every parameter the request reads
|
|
23
|
+
*/
|
|
24
|
+
private static readonly table = OperationTable.of({
|
|
25
|
+
/**
|
|
26
|
+
* Name of the room, or null for one the server picks
|
|
27
|
+
*/
|
|
28
|
+
roomName: Parameter.text(ParameterCode.ROOM_NAME),
|
|
29
|
+
...LobbyFormat.table,
|
|
30
|
+
/**
|
|
31
|
+
* User ids to keep a slot for
|
|
32
|
+
*/
|
|
33
|
+
expectedUsers: Parameter.texts(ParameterCode.ADD),
|
|
34
|
+
/**
|
|
35
|
+
* Matchmaking ticket
|
|
36
|
+
*/
|
|
37
|
+
ticket: Parameter.value(ParameterCode.TICKET),
|
|
38
|
+
/**
|
|
39
|
+
* Properties of the creator
|
|
40
|
+
*/
|
|
41
|
+
playerProperties: Parameter.table(ParameterCode.PLAYER_PROPERTIES),
|
|
42
|
+
/**
|
|
43
|
+
* Whether others hear about the creator's properties
|
|
44
|
+
*/
|
|
45
|
+
broadcast: Parameter.flag(ParameterCode.BROADCAST),
|
|
46
|
+
...RoomOptionsFormat.table,
|
|
47
|
+
/**
|
|
48
|
+
* Web flags for forwarding to a web service
|
|
49
|
+
*/
|
|
50
|
+
webFlags: Parameter.convertible(ParameterCode.EVENT_FORWARD),
|
|
51
|
+
})
|
|
52
|
+
|
|
20
53
|
/**
|
|
21
54
|
* Always a request
|
|
22
55
|
*/
|
|
@@ -47,15 +80,19 @@ export class CreateGameRequestFormat implements BalancingFormat<CreateGameReques
|
|
|
47
80
|
* @param reader the request's parameters
|
|
48
81
|
*/
|
|
49
82
|
public read(reader: ParameterReader): CreateGameRequest {
|
|
83
|
+
const values = reader.read<typeof CreateGameRequestFormat.table>(
|
|
84
|
+
CreateGameRequestFormat.table,
|
|
85
|
+
)
|
|
86
|
+
|
|
50
87
|
return CreateGameRequest.of(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
88
|
+
values.roomName,
|
|
89
|
+
LobbyFormat.from(values),
|
|
90
|
+
values.expectedUsers,
|
|
91
|
+
values.ticket,
|
|
92
|
+
values.playerProperties,
|
|
93
|
+
values.broadcast ?? false,
|
|
94
|
+
RoomOptionsFormat.from(reader, values),
|
|
95
|
+
values.webFlags,
|
|
59
96
|
)
|
|
60
97
|
}
|
|
61
98
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type MessageKindId,
|
|
9
9
|
} from '../../../contract/index.ts'
|
|
10
10
|
import type { ParameterReader } from '../../../reader/index.ts'
|
|
11
|
+
import { OperationTable, Parameter } from '../../../table/index.ts'
|
|
11
12
|
import type { ParameterWriter } from '../../../writer/index.ts'
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -15,6 +16,20 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
15
16
|
* @class
|
|
16
17
|
*/
|
|
17
18
|
export class DebugGameRequestFormat implements BalancingFormat<DebugGameRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* Name of the room
|
|
25
|
+
*/
|
|
26
|
+
roomName: Parameter.text(ParameterCode.ROOM_NAME).required(),
|
|
27
|
+
/**
|
|
28
|
+
* What the client wants to know
|
|
29
|
+
*/
|
|
30
|
+
info: Parameter.text(ParameterCode.INFO),
|
|
31
|
+
})
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
34
|
* Always a request
|
|
20
35
|
*/
|
|
@@ -35,11 +50,11 @@ export class DebugGameRequestFormat implements BalancingFormat<DebugGameRequest>
|
|
|
35
50
|
* @param reader the request's parameters
|
|
36
51
|
*/
|
|
37
52
|
public read(reader: ParameterReader): DebugGameRequest {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'',
|
|
41
|
-
reader.text(ParameterCode.INFO),
|
|
53
|
+
const values = reader.read<typeof DebugGameRequestFormat.table>(
|
|
54
|
+
DebugGameRequestFormat.table,
|
|
42
55
|
)
|
|
56
|
+
|
|
57
|
+
return DebugGameRequest.of(values.roomName ?? '', values.info)
|
|
43
58
|
}
|
|
44
59
|
|
|
45
60
|
/**
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type MessageKindId,
|
|
10
10
|
} from '../../../contract/index.ts'
|
|
11
11
|
import type { ParameterReader } from '../../../reader/index.ts'
|
|
12
|
+
import { OperationTable, Parameter } from '../../../table/index.ts'
|
|
12
13
|
import { LobbyFormat } from '../../../shared/lobby/index.ts'
|
|
13
14
|
import { RoomOptionsFormat } from '../../../shared/options/index.ts'
|
|
14
15
|
import type { ParameterWriter } from '../../../writer/index.ts'
|
|
@@ -18,6 +19,54 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
18
19
|
* @class
|
|
19
20
|
*/
|
|
20
21
|
export class JoinGameRequestFormat implements BalancingFormat<JoinGameRequest> {
|
|
22
|
+
/**
|
|
23
|
+
* Every parameter the request reads
|
|
24
|
+
*/
|
|
25
|
+
private static readonly table = OperationTable.of({
|
|
26
|
+
/**
|
|
27
|
+
* Name of the room
|
|
28
|
+
*/
|
|
29
|
+
roomName: Parameter.text(ParameterCode.ROOM_NAME).required(),
|
|
30
|
+
/**
|
|
31
|
+
* One of the join modes
|
|
32
|
+
*/
|
|
33
|
+
joinMode: Parameter.convertible(ParameterCode.JOIN_MODE),
|
|
34
|
+
...LobbyFormat.table,
|
|
35
|
+
/**
|
|
36
|
+
* User ids to keep a slot for
|
|
37
|
+
*/
|
|
38
|
+
expectedUsers: Parameter.texts(ParameterCode.ADD),
|
|
39
|
+
/**
|
|
40
|
+
* Matchmaking ticket
|
|
41
|
+
*/
|
|
42
|
+
ticket: Parameter.value(ParameterCode.TICKET),
|
|
43
|
+
/**
|
|
44
|
+
* Properties of the joiner
|
|
45
|
+
*/
|
|
46
|
+
playerProperties: Parameter.table(ParameterCode.PLAYER_PROPERTIES),
|
|
47
|
+
/**
|
|
48
|
+
* Whether others hear about the joiner's properties
|
|
49
|
+
*/
|
|
50
|
+
broadcast: Parameter.flag(ParameterCode.BROADCAST),
|
|
51
|
+
...RoomOptionsFormat.table,
|
|
52
|
+
/**
|
|
53
|
+
* Actor number to come back as
|
|
54
|
+
*/
|
|
55
|
+
actorNumber: Parameter.int(ParameterCode.ACTOR_NUMBER),
|
|
56
|
+
/**
|
|
57
|
+
* Cache slice to replay from
|
|
58
|
+
*/
|
|
59
|
+
cacheSliceIndex: Parameter.int(ParameterCode.CACHE_SLICE_INDEX),
|
|
60
|
+
/**
|
|
61
|
+
* Whether the join replaces an active actor
|
|
62
|
+
*/
|
|
63
|
+
forceRejoin: Parameter.flag(ParameterCode.FORCE_REJOIN),
|
|
64
|
+
/**
|
|
65
|
+
* Web flags for forwarding to a web service
|
|
66
|
+
*/
|
|
67
|
+
webFlags: Parameter.convertible(ParameterCode.EVENT_FORWARD),
|
|
68
|
+
})
|
|
69
|
+
|
|
21
70
|
/**
|
|
22
71
|
* Always a request
|
|
23
72
|
*/
|
|
@@ -48,20 +97,23 @@ export class JoinGameRequestFormat implements BalancingFormat<JoinGameRequest> {
|
|
|
48
97
|
* @param reader the request's parameters
|
|
49
98
|
*/
|
|
50
99
|
public read(reader: ParameterReader): JoinGameRequest {
|
|
100
|
+
const values = reader.read<typeof JoinGameRequestFormat.table>(
|
|
101
|
+
JoinGameRequestFormat.table,
|
|
102
|
+
)
|
|
103
|
+
|
|
51
104
|
return JoinGameRequest.of(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
reader.convertible(ParameterCode.EVENT_FORWARD),
|
|
105
|
+
values.roomName ?? '',
|
|
106
|
+
values.joinMode ?? JoinMode.DEFAULT,
|
|
107
|
+
LobbyFormat.from(values),
|
|
108
|
+
values.expectedUsers,
|
|
109
|
+
values.ticket,
|
|
110
|
+
values.playerProperties,
|
|
111
|
+
values.broadcast ?? false,
|
|
112
|
+
RoomOptionsFormat.from(reader, values),
|
|
113
|
+
values.actorNumber,
|
|
114
|
+
values.cacheSliceIndex,
|
|
115
|
+
values.forceRejoin ?? false,
|
|
116
|
+
values.webFlags,
|
|
65
117
|
)
|
|
66
118
|
}
|
|
67
119
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PacketType } from '../../../../../../dispatch/route/index.ts'
|
|
2
2
|
import { LobbyFormat } from '../../../shared/lobby/index.ts'
|
|
3
|
+
import { LobbyType } from '../../../../code/lobby/index.ts'
|
|
3
4
|
import { OperationCode } from '../../../../code/operation/index.ts'
|
|
4
5
|
import { ParameterCode } from '../../../../code/parameter/index.ts'
|
|
5
6
|
import { GetGameListRequest } from '../../../../packet/game/list/request/index.ts'
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
type MessageKindId,
|
|
10
11
|
} from '../../../contract/index.ts'
|
|
11
12
|
import type { ParameterReader } from '../../../reader/index.ts'
|
|
13
|
+
import { OperationTable, Parameter } from '../../../table/index.ts'
|
|
12
14
|
import type { ParameterWriter } from '../../../writer/index.ts'
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -16,6 +18,17 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
16
18
|
* @class
|
|
17
19
|
*/
|
|
18
20
|
export class GetGameListRequestFormat implements BalancingFormat<GetGameListRequest> {
|
|
21
|
+
/**
|
|
22
|
+
* Every parameter the request reads
|
|
23
|
+
*/
|
|
24
|
+
private static readonly table = OperationTable.of({
|
|
25
|
+
...LobbyFormat.table,
|
|
26
|
+
/**
|
|
27
|
+
* Filter the games have to pass
|
|
28
|
+
*/
|
|
29
|
+
sqlFilter: Parameter.text(ParameterCode.DATA),
|
|
30
|
+
})
|
|
31
|
+
|
|
19
32
|
/**
|
|
20
33
|
* Always a request
|
|
21
34
|
*/
|
|
@@ -41,10 +54,23 @@ export class GetGameListRequestFormat implements BalancingFormat<GetGameListRequ
|
|
|
41
54
|
* @param reader the request's parameters
|
|
42
55
|
*/
|
|
43
56
|
public read(reader: ParameterReader): GetGameListRequest {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
reader.text(ParameterCode.DATA),
|
|
57
|
+
const values = reader.read<typeof GetGameListRequestFormat.table>(
|
|
58
|
+
GetGameListRequestFormat.table,
|
|
47
59
|
)
|
|
60
|
+
|
|
61
|
+
return GetGameListRequest.of(LobbyFormat.from(values), values.sqlFilter)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Why a game list can't come from the lobby a request names, or null
|
|
66
|
+
* @param packet what the client sent
|
|
67
|
+
*/
|
|
68
|
+
public static refusal(packet: GetGameListRequest): string | null {
|
|
69
|
+
const type = packet.lobby?.type ?? LobbyType.DEFAULT
|
|
70
|
+
if (type !== LobbyType.SQL) return LobbyFormat.unknown(type)
|
|
71
|
+
|
|
72
|
+
const name = packet.lobby?.name ?? ''
|
|
73
|
+
return name === '' ? "Invalid lobby name: ''" : null
|
|
48
74
|
}
|
|
49
75
|
|
|
50
76
|
/**
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type MessageKindId,
|
|
12
12
|
} from '../../../contract/index.ts'
|
|
13
13
|
import type { ParameterReader } from '../../../reader/index.ts'
|
|
14
|
+
import { OperationTable, Parameter } from '../../../table/index.ts'
|
|
14
15
|
import type { ParameterWriter } from '../../../writer/index.ts'
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -18,6 +19,49 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
18
19
|
* @class
|
|
19
20
|
*/
|
|
20
21
|
export class JoinRandomGameRequestFormat implements BalancingFormat<JoinRandomGameRequest> {
|
|
22
|
+
/**
|
|
23
|
+
* Every parameter the request reads
|
|
24
|
+
*/
|
|
25
|
+
private static readonly table = OperationTable.of({
|
|
26
|
+
/**
|
|
27
|
+
* Properties a game must have
|
|
28
|
+
*/
|
|
29
|
+
gameProperties: Parameter.table(ParameterCode.GAME_PROPERTIES),
|
|
30
|
+
/**
|
|
31
|
+
* Where the walk through the games starts
|
|
32
|
+
*/
|
|
33
|
+
matchmakingMode: Parameter.byte(ParameterCode.MATCHMAKING_TYPE),
|
|
34
|
+
...LobbyFormat.table,
|
|
35
|
+
/**
|
|
36
|
+
* Filter of a SQL lobby
|
|
37
|
+
*/
|
|
38
|
+
sqlFilter: Parameter.text(ParameterCode.DATA),
|
|
39
|
+
/**
|
|
40
|
+
* User ids to keep a slot for
|
|
41
|
+
*/
|
|
42
|
+
expectedUsers: Parameter.texts(ParameterCode.ADD),
|
|
43
|
+
/**
|
|
44
|
+
* Matchmaking ticket
|
|
45
|
+
*/
|
|
46
|
+
ticket: Parameter.value(ParameterCode.TICKET),
|
|
47
|
+
/**
|
|
48
|
+
* Whether a game may come up twice
|
|
49
|
+
*/
|
|
50
|
+
allowRepeats: Parameter.flag(ParameterCode.ALLOW_REPEATS),
|
|
51
|
+
/**
|
|
52
|
+
* One of the join modes
|
|
53
|
+
*/
|
|
54
|
+
joinMode: Parameter.convertible(ParameterCode.JOIN_MODE),
|
|
55
|
+
/**
|
|
56
|
+
* Name of a game made if nothing fits
|
|
57
|
+
*/
|
|
58
|
+
roomName: Parameter.text(ParameterCode.ROOM_NAME),
|
|
59
|
+
/**
|
|
60
|
+
* Properties of a game made if nothing fits
|
|
61
|
+
*/
|
|
62
|
+
properties: Parameter.table(ParameterCode.PROPERTIES),
|
|
63
|
+
})
|
|
64
|
+
|
|
21
65
|
/**
|
|
22
66
|
* Always a request
|
|
23
67
|
*/
|
|
@@ -44,17 +88,21 @@ export class JoinRandomGameRequestFormat implements BalancingFormat<JoinRandomGa
|
|
|
44
88
|
* @param reader the request's parameters
|
|
45
89
|
*/
|
|
46
90
|
public read(reader: ParameterReader): JoinRandomGameRequest {
|
|
91
|
+
const values = reader.read<typeof JoinRandomGameRequestFormat.table>(
|
|
92
|
+
JoinRandomGameRequestFormat.table,
|
|
93
|
+
)
|
|
94
|
+
|
|
47
95
|
return JoinRandomGameRequest.of(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
96
|
+
values.gameProperties,
|
|
97
|
+
values.matchmakingMode ?? MatchmakingMode.FILL_ROOM,
|
|
98
|
+
LobbyFormat.from(values),
|
|
99
|
+
values.sqlFilter,
|
|
100
|
+
values.expectedUsers,
|
|
101
|
+
values.ticket,
|
|
102
|
+
values.allowRepeats,
|
|
103
|
+
values.joinMode ?? JoinMode.DEFAULT,
|
|
104
|
+
values.roomName,
|
|
105
|
+
values.properties,
|
|
58
106
|
)
|
|
59
107
|
}
|
|
60
108
|
|