@netifyjs/protocol 1.0.0-alpha.2 → 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 +82 -157
- package/src/dispatch/dispatcher/index.ts +116 -33
- package/src/dispatch/session/index.ts +9 -3
- 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/binary/v18/index.ts +26 -1
- package/src/photon/binary/value/index.ts +52 -3
- 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/binary/index.ts +35 -1
- package/src/photon/message/client/index.ts +14 -11
- package/src/photon/message/format/index.ts +9 -0
- package/src/photon/message/handler/index.ts +48 -63
- 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 +127 -15
- package/src/photon/server/config/index.ts +5 -0
- package/src/photon/server/deferral/index.ts +57 -0
- package/src/photon/server/host/index.ts +36 -10
- package/src/photon/server/index.ts +1 -0
- package/src/photon/server/listeners/index.ts +11 -0
- package/src/photon/tcp/client/index.ts +1 -1
- package/src/photon/tcp/codec/index.ts +41 -38
- package/src/photon/tcp/framing/index.ts +24 -4
- 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/batch/index.ts +14 -6
- 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 +24 -16
- package/src/scale/sink/index.ts +6 -11
- package/src/scale/transport/index.ts +27 -44
- package/src/scale/tunnel/index.ts +56 -86
- 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 +34 -40
- 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
|
@@ -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 ChangeGroupsRequestFormat implements BalancingFormat<ChangeGroupsRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* Groups to leave
|
|
25
|
+
*/
|
|
26
|
+
remove: Parameter.bytes(ParameterCode.REMOVE),
|
|
27
|
+
/**
|
|
28
|
+
* Groups to join
|
|
29
|
+
*/
|
|
30
|
+
add: Parameter.bytes(ParameterCode.ADD),
|
|
31
|
+
})
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
34
|
* Always a request
|
|
20
35
|
*/
|
|
@@ -35,10 +50,11 @@ export class ChangeGroupsRequestFormat implements BalancingFormat<ChangeGroupsRe
|
|
|
35
50
|
* @param reader the request's parameters
|
|
36
51
|
*/
|
|
37
52
|
public read(reader: ParameterReader): ChangeGroupsRequest {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
reader.bytes(ParameterCode.ADD),
|
|
53
|
+
const values = reader.read<typeof ChangeGroupsRequestFormat.table>(
|
|
54
|
+
ChangeGroupsRequestFormat.table,
|
|
41
55
|
)
|
|
56
|
+
|
|
57
|
+
return ChangeGroupsRequest.of(values.remove, values.add)
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
/**
|
|
@@ -85,4 +85,11 @@ export {
|
|
|
85
85
|
RoomEntryFormat,
|
|
86
86
|
RoomOptionsFormat,
|
|
87
87
|
} from './shared/index.ts'
|
|
88
|
+
export { OperationTable, Parameter, ParameterKind } from './table/index.ts'
|
|
89
|
+
export type {
|
|
90
|
+
OperationShape,
|
|
91
|
+
OperationValues,
|
|
92
|
+
ParameterKindId,
|
|
93
|
+
ParameterTypes,
|
|
94
|
+
} from './table/index.ts'
|
|
88
95
|
export { ParameterWriter } from './writer/index.ts'
|
|
@@ -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 LeaveRequestFormat implements BalancingFormat<LeaveRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* Whether the seat is kept
|
|
25
|
+
*/
|
|
26
|
+
isInactive: Parameter.flag(ParameterCode.IS_INACTIVE),
|
|
27
|
+
/**
|
|
28
|
+
* Web flags for forwarding to a web service
|
|
29
|
+
*/
|
|
30
|
+
webFlags: Parameter.convertible(ParameterCode.EVENT_FORWARD),
|
|
31
|
+
})
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
34
|
* Always a request
|
|
20
35
|
*/
|
|
@@ -35,10 +50,11 @@ export class LeaveRequestFormat implements BalancingFormat<LeaveRequest> {
|
|
|
35
50
|
* @param reader the request's parameters
|
|
36
51
|
*/
|
|
37
52
|
public read(reader: ParameterReader): LeaveRequest {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
reader.convertible(ParameterCode.EVENT_FORWARD),
|
|
53
|
+
const values = reader.read<typeof LeaveRequestFormat.table>(
|
|
54
|
+
LeaveRequestFormat.table,
|
|
41
55
|
)
|
|
56
|
+
|
|
57
|
+
return LeaveRequest.of(values.isInactive ?? false, values.webFlags)
|
|
42
58
|
}
|
|
43
59
|
|
|
44
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 type { ParameterWriter } from '../../../writer/index.ts'
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -16,6 +17,21 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
16
17
|
* @class
|
|
17
18
|
*/
|
|
18
19
|
export class JoinLobbyRequestFormat implements BalancingFormat<JoinLobbyRequest> {
|
|
20
|
+
/**
|
|
21
|
+
* Every parameter the request reads
|
|
22
|
+
*/
|
|
23
|
+
private static readonly table = OperationTable.of({
|
|
24
|
+
...LobbyFormat.table,
|
|
25
|
+
/**
|
|
26
|
+
* How many games the first list holds
|
|
27
|
+
*/
|
|
28
|
+
gameListCount: Parameter.int(ParameterCode.GAME_LIST_COUNT),
|
|
29
|
+
/**
|
|
30
|
+
* Properties listed games must have
|
|
31
|
+
*/
|
|
32
|
+
gameProperties: Parameter.table(ParameterCode.GAME_PROPERTIES),
|
|
33
|
+
})
|
|
34
|
+
|
|
19
35
|
/**
|
|
20
36
|
* Always a request
|
|
21
37
|
*/
|
|
@@ -41,10 +57,14 @@ export class JoinLobbyRequestFormat implements BalancingFormat<JoinLobbyRequest>
|
|
|
41
57
|
* @param reader the request's parameters
|
|
42
58
|
*/
|
|
43
59
|
public read(reader: ParameterReader): JoinLobbyRequest {
|
|
60
|
+
const values = reader.read<typeof JoinLobbyRequestFormat.table>(
|
|
61
|
+
JoinLobbyRequestFormat.table,
|
|
62
|
+
)
|
|
63
|
+
|
|
44
64
|
return JoinLobbyRequest.of(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
LobbyFormat.from(values),
|
|
66
|
+
values.gameListCount,
|
|
67
|
+
values.gameProperties,
|
|
48
68
|
)
|
|
49
69
|
}
|
|
50
70
|
|
|
@@ -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 GetLobbyStatsRequestFormat implements BalancingFormat<GetLobbyStatsRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* Names of the lobbies asked about
|
|
25
|
+
*/
|
|
26
|
+
names: Parameter.texts(ParameterCode.LOBBY_NAME),
|
|
27
|
+
/**
|
|
28
|
+
* Types of the lobbies asked about
|
|
29
|
+
*/
|
|
30
|
+
types: Parameter.bytes(ParameterCode.LOBBY_TYPE),
|
|
31
|
+
})
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
34
|
* Always a request
|
|
20
35
|
*/
|
|
@@ -35,10 +50,11 @@ export class GetLobbyStatsRequestFormat implements BalancingFormat<GetLobbyStats
|
|
|
35
50
|
* @param reader the request's parameters
|
|
36
51
|
*/
|
|
37
52
|
public read(reader: ParameterReader): GetLobbyStatsRequest {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
reader.bytes(ParameterCode.LOBBY_TYPE),
|
|
53
|
+
const values = reader.read<typeof GetLobbyStatsRequestFormat.table>(
|
|
54
|
+
GetLobbyStatsRequestFormat.table,
|
|
41
55
|
)
|
|
56
|
+
|
|
57
|
+
return GetLobbyStatsRequest.of(values.names, values.types)
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
/**
|
|
@@ -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,29 @@ import type { ParameterWriter } from '../../writer/index.ts'
|
|
|
18
19
|
* @class
|
|
19
20
|
*/
|
|
20
21
|
export class AuthenticateOnceRequestFormat implements BalancingFormat<AuthenticateOnceRequest> {
|
|
22
|
+
/**
|
|
23
|
+
* Every parameter the request reads
|
|
24
|
+
*/
|
|
25
|
+
private static readonly table = OperationTable.of({
|
|
26
|
+
/**
|
|
27
|
+
* Transport the Game Server connection uses
|
|
28
|
+
*/
|
|
29
|
+
protocol: Parameter.byte(ParameterCode.EXPECTED_PROTOCOL).required(),
|
|
30
|
+
/**
|
|
31
|
+
* How the traffic is encrypted
|
|
32
|
+
*/
|
|
33
|
+
encryption: Parameter.byte(ParameterCode.ENCRYPTION_MODE).required(),
|
|
34
|
+
...CredentialsFormat.table,
|
|
35
|
+
/**
|
|
36
|
+
* Region the client wants
|
|
37
|
+
*/
|
|
38
|
+
region: CredentialsFormat.table.region.required(),
|
|
39
|
+
/**
|
|
40
|
+
* Token from an earlier login
|
|
41
|
+
*/
|
|
42
|
+
token: Parameter.value(ParameterCode.TOKEN),
|
|
43
|
+
})
|
|
44
|
+
|
|
21
45
|
/**
|
|
22
46
|
* Always a request
|
|
23
47
|
*/
|
|
@@ -44,16 +68,15 @@ export class AuthenticateOnceRequestFormat implements BalancingFormat<Authentica
|
|
|
44
68
|
* @param reader the request's parameters
|
|
45
69
|
*/
|
|
46
70
|
public read(reader: ParameterReader): AuthenticateOnceRequest {
|
|
47
|
-
reader
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
.require(ParameterCode.REGION)
|
|
71
|
+
const values = reader.read<typeof AuthenticateOnceRequestFormat.table>(
|
|
72
|
+
AuthenticateOnceRequestFormat.table,
|
|
73
|
+
)
|
|
51
74
|
|
|
52
75
|
return AuthenticateOnceRequest.of(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
values.protocol ?? ConnectionProtocol.UDP,
|
|
77
|
+
values.encryption ?? EncryptionMode.PAYLOAD,
|
|
78
|
+
CredentialsFormat.from(reader, values),
|
|
79
|
+
values.token,
|
|
57
80
|
)
|
|
58
81
|
}
|
|
59
82
|
|
|
@@ -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,28 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
15
16
|
* @class
|
|
16
17
|
*/
|
|
17
18
|
export class GetPropertiesRequestFormat implements BalancingFormat<GetPropertiesRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* Which properties the client wants
|
|
25
|
+
*/
|
|
26
|
+
kinds: Parameter.byte(ParameterCode.PROPERTIES),
|
|
27
|
+
/**
|
|
28
|
+
* Actors to answer for
|
|
29
|
+
*/
|
|
30
|
+
actors: Parameter.ints(ParameterCode.ACTOR_LIST),
|
|
31
|
+
/**
|
|
32
|
+
* Actor property keys to answer with
|
|
33
|
+
*/
|
|
34
|
+
actorProperties: Parameter.values(ParameterCode.PLAYER_PROPERTIES),
|
|
35
|
+
/**
|
|
36
|
+
* Room property keys to answer with
|
|
37
|
+
*/
|
|
38
|
+
gameProperties: Parameter.values(ParameterCode.GAME_PROPERTIES),
|
|
39
|
+
})
|
|
40
|
+
|
|
18
41
|
/**
|
|
19
42
|
* Always a request
|
|
20
43
|
*/
|
|
@@ -35,11 +58,15 @@ export class GetPropertiesRequestFormat implements BalancingFormat<GetProperties
|
|
|
35
58
|
* @param reader the request's parameters
|
|
36
59
|
*/
|
|
37
60
|
public read(reader: ParameterReader): GetPropertiesRequest {
|
|
61
|
+
const values = reader.read<typeof GetPropertiesRequestFormat.table>(
|
|
62
|
+
GetPropertiesRequestFormat.table,
|
|
63
|
+
)
|
|
64
|
+
|
|
38
65
|
return GetPropertiesRequest.of(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
66
|
+
values.kinds,
|
|
67
|
+
values.actors,
|
|
68
|
+
values.actorProperties,
|
|
69
|
+
values.gameProperties,
|
|
43
70
|
)
|
|
44
71
|
}
|
|
45
72
|
|
|
@@ -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 type { ParameterWriter } from '../../../writer/index.ts'
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -16,6 +17,32 @@ import type { ParameterWriter } from '../../../writer/index.ts'
|
|
|
16
17
|
* @class
|
|
17
18
|
*/
|
|
18
19
|
export class SetPropertiesRequestFormat implements BalancingFormat<SetPropertiesRequest> {
|
|
20
|
+
/**
|
|
21
|
+
* Every parameter the request reads
|
|
22
|
+
*/
|
|
23
|
+
private static readonly table = OperationTable.of({
|
|
24
|
+
/**
|
|
25
|
+
* Properties to write
|
|
26
|
+
*/
|
|
27
|
+
properties: Parameter.table(ParameterCode.PROPERTIES).required(),
|
|
28
|
+
/**
|
|
29
|
+
* Actor whose properties change, 0 for the room
|
|
30
|
+
*/
|
|
31
|
+
actorNumber: Parameter.int(ParameterCode.ACTOR_NUMBER),
|
|
32
|
+
/**
|
|
33
|
+
* Whether others hear about the change
|
|
34
|
+
*/
|
|
35
|
+
broadcast: Parameter.flag(ParameterCode.BROADCAST),
|
|
36
|
+
/**
|
|
37
|
+
* Values that have to hold first
|
|
38
|
+
*/
|
|
39
|
+
expectedValues: Parameter.table(ParameterCode.EXPECTED_VALUES),
|
|
40
|
+
/**
|
|
41
|
+
* Web flags for forwarding to a web service
|
|
42
|
+
*/
|
|
43
|
+
webFlags: Parameter.convertible(ParameterCode.EVENT_FORWARD),
|
|
44
|
+
})
|
|
45
|
+
|
|
19
46
|
/**
|
|
20
47
|
* Always a request
|
|
21
48
|
*/
|
|
@@ -36,14 +63,16 @@ export class SetPropertiesRequestFormat implements BalancingFormat<SetProperties
|
|
|
36
63
|
* @param reader the request's parameters
|
|
37
64
|
*/
|
|
38
65
|
public read(reader: ParameterReader): SetPropertiesRequest {
|
|
66
|
+
const values = reader.read<typeof SetPropertiesRequestFormat.table>(
|
|
67
|
+
SetPropertiesRequestFormat.table,
|
|
68
|
+
)
|
|
69
|
+
|
|
39
70
|
return SetPropertiesRequest.of(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
reader.table(ParameterCode.EXPECTED_VALUES),
|
|
46
|
-
reader.convertible(ParameterCode.EVENT_FORWARD),
|
|
71
|
+
values.properties ?? PhotonHashtable.of(),
|
|
72
|
+
values.actorNumber ?? 0,
|
|
73
|
+
values.broadcast ?? false,
|
|
74
|
+
values.expectedValues,
|
|
75
|
+
values.webFlags,
|
|
47
76
|
)
|
|
48
77
|
}
|
|
49
78
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PacketType } from '../../../../../dispatch/route/index.ts'
|
|
2
2
|
import { EventCaching } from '../../../code/caching/index.ts'
|
|
3
|
+
import { EventRange } from '../../../code/event/index.ts'
|
|
4
|
+
import { ErrorMessage, ErrorMessages } from '../../../code/message/index.ts'
|
|
3
5
|
import { OperationCode } from '../../../code/operation/index.ts'
|
|
4
6
|
import { ParameterCode } from '../../../code/parameter/index.ts'
|
|
5
7
|
import { ReceiverGroup } from '../../../code/receiver/index.ts'
|
|
@@ -10,6 +12,7 @@ import {
|
|
|
10
12
|
type MessageKindId,
|
|
11
13
|
} from '../../contract/index.ts'
|
|
12
14
|
import type { ParameterReader } from '../../reader/index.ts'
|
|
15
|
+
import { OperationTable, Parameter } from '../../table/index.ts'
|
|
13
16
|
import type { ParameterWriter } from '../../writer/index.ts'
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -17,6 +20,52 @@ import type { ParameterWriter } from '../../writer/index.ts'
|
|
|
17
20
|
* @class
|
|
18
21
|
*/
|
|
19
22
|
export class RaiseEventRequestFormat implements BalancingFormat<RaiseEventRequest> {
|
|
23
|
+
/**
|
|
24
|
+
* Every parameter the request reads
|
|
25
|
+
*/
|
|
26
|
+
private static readonly table = OperationTable.of({
|
|
27
|
+
/**
|
|
28
|
+
* Event code
|
|
29
|
+
*/
|
|
30
|
+
eventCode: Parameter.byte(ParameterCode.CODE),
|
|
31
|
+
/**
|
|
32
|
+
* Content
|
|
33
|
+
*/
|
|
34
|
+
data: Parameter.value(ParameterCode.DATA),
|
|
35
|
+
/**
|
|
36
|
+
* One of the caching options
|
|
37
|
+
*/
|
|
38
|
+
caching: Parameter.byte(ParameterCode.CACHE),
|
|
39
|
+
/**
|
|
40
|
+
* One of the receiver groups
|
|
41
|
+
*/
|
|
42
|
+
receiverGroup: Parameter.byte(ParameterCode.RECEIVER_GROUP),
|
|
43
|
+
/**
|
|
44
|
+
* Actor numbers to send to
|
|
45
|
+
*/
|
|
46
|
+
actors: Parameter.ints(ParameterCode.ACTOR_LIST),
|
|
47
|
+
/**
|
|
48
|
+
* Interest group to send to
|
|
49
|
+
*/
|
|
50
|
+
group: Parameter.byte(ParameterCode.GROUP),
|
|
51
|
+
/**
|
|
52
|
+
* Web flags for forwarding to a web service
|
|
53
|
+
*/
|
|
54
|
+
webFlags: Parameter.convertible(ParameterCode.EVENT_FORWARD),
|
|
55
|
+
/**
|
|
56
|
+
* Cache slice to work on
|
|
57
|
+
*/
|
|
58
|
+
cacheSliceIndex: Parameter.int(ParameterCode.CACHE_SLICE_INDEX),
|
|
59
|
+
/**
|
|
60
|
+
* Whether the event goes out right away
|
|
61
|
+
*/
|
|
62
|
+
flush: Parameter.flag(ParameterCode.FLUSH),
|
|
63
|
+
/**
|
|
64
|
+
* Room the event is for
|
|
65
|
+
*/
|
|
66
|
+
roomName: Parameter.text(ParameterCode.ROOM_NAME),
|
|
67
|
+
})
|
|
68
|
+
|
|
20
69
|
/**
|
|
21
70
|
* Always a request
|
|
22
71
|
*/
|
|
@@ -48,17 +97,34 @@ export class RaiseEventRequestFormat implements BalancingFormat<RaiseEventReques
|
|
|
48
97
|
* @param reader the request's parameters
|
|
49
98
|
*/
|
|
50
99
|
public read(reader: ParameterReader): RaiseEventRequest {
|
|
100
|
+
const values = reader.read<typeof RaiseEventRequestFormat.table>(
|
|
101
|
+
RaiseEventRequestFormat.table,
|
|
102
|
+
)
|
|
103
|
+
|
|
51
104
|
return RaiseEventRequest.of(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
105
|
+
values.eventCode ?? 0,
|
|
106
|
+
values.data,
|
|
107
|
+
values.caching ?? EventCaching.DO_NOT_CACHE,
|
|
108
|
+
values.receiverGroup ?? ReceiverGroup.OTHERS,
|
|
109
|
+
values.actors,
|
|
110
|
+
values.group ?? 0,
|
|
111
|
+
values.webFlags,
|
|
112
|
+
values.cacheSliceIndex,
|
|
113
|
+
values.flush ?? false,
|
|
114
|
+
values.roomName,
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Why a client may not raise an event with this code, or null
|
|
120
|
+
* @param packet what the client sent
|
|
121
|
+
*/
|
|
122
|
+
public static refusal(packet: RaiseEventRequest): string | null {
|
|
123
|
+
if (packet.eventCode <= EventRange.LAST_RAISABLE) return null
|
|
124
|
+
|
|
125
|
+
return ErrorMessages.format(
|
|
126
|
+
ErrorMessage.SIMULATES_PHOTON_EVENT,
|
|
127
|
+
EventRange.LAST_RAISABLE,
|
|
62
128
|
)
|
|
63
129
|
}
|
|
64
130
|
|
|
@@ -10,6 +10,12 @@ import { type PhotonData, PhotonValue } from '../../../binary/value/index.ts'
|
|
|
10
10
|
import { ErrorCode } from '../../code/error/index.ts'
|
|
11
11
|
import { ErrorMessage, ErrorMessages } from '../../code/message/index.ts'
|
|
12
12
|
import { DotNetType } from '../../dotnet/index.ts'
|
|
13
|
+
import {
|
|
14
|
+
type OperationTable,
|
|
15
|
+
type OperationValues,
|
|
16
|
+
type Parameter,
|
|
17
|
+
ParameterKind,
|
|
18
|
+
} from '../table/index.ts'
|
|
13
19
|
|
|
14
20
|
/**
|
|
15
21
|
* Reads typed parameters and remembers what was wrong with them
|
|
@@ -37,9 +43,9 @@ export class ParameterReader {
|
|
|
37
43
|
private readonly parameters: ParameterTable
|
|
38
44
|
|
|
39
45
|
/**
|
|
40
|
-
* One line per missing or mistyped parameter
|
|
46
|
+
* One line per missing or mistyped parameter, or null
|
|
41
47
|
*/
|
|
42
|
-
private
|
|
48
|
+
private faults: string[] | null
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* @param code operation or event code of the message
|
|
@@ -57,7 +63,7 @@ export class ParameterReader {
|
|
|
57
63
|
this.parameters = parameters
|
|
58
64
|
this.returnCode = returnCode
|
|
59
65
|
this.debugMessage = debugMessage
|
|
60
|
-
this.faults =
|
|
66
|
+
this.faults = null
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
/**
|
|
@@ -98,7 +104,7 @@ export class ParameterReader {
|
|
|
98
104
|
* Everything wrong with the parameters read so far, or null
|
|
99
105
|
*/
|
|
100
106
|
public get fault(): string | null {
|
|
101
|
-
return this.faults
|
|
107
|
+
return this.faults?.join('; ') ?? null
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
/**
|
|
@@ -108,6 +114,27 @@ export class ParameterReader {
|
|
|
108
114
|
return this.returnCode !== ErrorCode.OK
|
|
109
115
|
}
|
|
110
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Every parameter a table lists
|
|
119
|
+
* @param table the operation's parameters by name
|
|
120
|
+
*/
|
|
121
|
+
public read<T extends OperationTable>(table: T): OperationValues<T['shape']> {
|
|
122
|
+
const values: Record<string, unknown> = { ...table.blank }
|
|
123
|
+
|
|
124
|
+
for (const code of table.required) {
|
|
125
|
+
this.require(code)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const [name, parameter] of table.entries) {
|
|
129
|
+
const gate = parameter.gate
|
|
130
|
+
const shut = gate !== null && values[gate] === null
|
|
131
|
+
|
|
132
|
+
values[name] = shut ? null : this.parameter(parameter)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return values as OperationValues<T['shape']>
|
|
136
|
+
}
|
|
137
|
+
|
|
111
138
|
/**
|
|
112
139
|
* Notes a parameter that has to be there
|
|
113
140
|
* @param code parameter code
|
|
@@ -115,7 +142,7 @@ export class ParameterReader {
|
|
|
115
142
|
public require(code: number): this {
|
|
116
143
|
if (this.value(code) !== null) return this
|
|
117
144
|
|
|
118
|
-
this.
|
|
145
|
+
this.fail(ErrorMessages.format(ErrorMessage.MISSING_VALUE, code))
|
|
119
146
|
|
|
120
147
|
return this
|
|
121
148
|
}
|
|
@@ -294,6 +321,39 @@ export class ParameterReader {
|
|
|
294
321
|
)
|
|
295
322
|
}
|
|
296
323
|
|
|
324
|
+
/**
|
|
325
|
+
* One parameter of a table, or null
|
|
326
|
+
* @param parameter what the table says about it
|
|
327
|
+
*/
|
|
328
|
+
private parameter(parameter: Parameter): unknown {
|
|
329
|
+
const code = parameter.code
|
|
330
|
+
|
|
331
|
+
switch (parameter.kind) {
|
|
332
|
+
case ParameterKind.VALUE:
|
|
333
|
+
return this.value(code)
|
|
334
|
+
case ParameterKind.TEXT:
|
|
335
|
+
return this.text(code)
|
|
336
|
+
case ParameterKind.FLAG:
|
|
337
|
+
return this.flag(code)
|
|
338
|
+
case ParameterKind.BYTE:
|
|
339
|
+
return this.byte(code)
|
|
340
|
+
case ParameterKind.INT:
|
|
341
|
+
return this.int(code)
|
|
342
|
+
case ParameterKind.CONVERTIBLE:
|
|
343
|
+
return this.convertible(code)
|
|
344
|
+
case ParameterKind.BYTES:
|
|
345
|
+
return this.bytes(code)
|
|
346
|
+
case ParameterKind.TABLE:
|
|
347
|
+
return this.table(code)
|
|
348
|
+
case ParameterKind.TEXTS:
|
|
349
|
+
return this.texts(code)
|
|
350
|
+
case ParameterKind.INTS:
|
|
351
|
+
return this.ints(code)
|
|
352
|
+
case ParameterKind.VALUES:
|
|
353
|
+
return this.values(code)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
297
357
|
/**
|
|
298
358
|
* A parameter of one plain type, or null
|
|
299
359
|
* @param code parameter code
|
|
@@ -341,6 +401,15 @@ export class ParameterReader {
|
|
|
341
401
|
return typed.map<T>((item: PhotonValue): T => item.data as T)
|
|
342
402
|
}
|
|
343
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Notes something wrong with the parameters
|
|
406
|
+
* @param fault what went wrong
|
|
407
|
+
*/
|
|
408
|
+
private fail(fault: string): void {
|
|
409
|
+
this.faults ??= []
|
|
410
|
+
this.faults.push(fault)
|
|
411
|
+
}
|
|
412
|
+
|
|
344
413
|
/**
|
|
345
414
|
* Notes a parameter of the wrong type
|
|
346
415
|
* @param code parameter code
|
|
@@ -348,7 +417,7 @@ export class ParameterReader {
|
|
|
348
417
|
* @param value what arrived
|
|
349
418
|
*/
|
|
350
419
|
private mismatch(code: number, expected: string, value: PhotonValue): null {
|
|
351
|
-
this.
|
|
420
|
+
this.fail(
|
|
352
421
|
ErrorMessages.format(
|
|
353
422
|
ErrorMessage.WRONG_PARAMETER_TYPE,
|
|
354
423
|
code,
|
|
@@ -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,16 @@ import type { ParameterWriter } from '../../writer/index.ts'
|
|
|
15
16
|
* @class
|
|
16
17
|
*/
|
|
17
18
|
export class GetRegionsRequestFormat implements BalancingFormat<GetRegionsRequest> {
|
|
19
|
+
/**
|
|
20
|
+
* Every parameter the request reads
|
|
21
|
+
*/
|
|
22
|
+
private static readonly table = OperationTable.of({
|
|
23
|
+
/**
|
|
24
|
+
* Application id
|
|
25
|
+
*/
|
|
26
|
+
applicationId: Parameter.text(ParameterCode.APPLICATION_ID),
|
|
27
|
+
})
|
|
28
|
+
|
|
18
29
|
/**
|
|
19
30
|
* Always a request
|
|
20
31
|
*/
|
|
@@ -35,7 +46,11 @@ export class GetRegionsRequestFormat implements BalancingFormat<GetRegionsReques
|
|
|
35
46
|
* @param reader the request's parameters
|
|
36
47
|
*/
|
|
37
48
|
public read(reader: ParameterReader): GetRegionsRequest {
|
|
38
|
-
|
|
49
|
+
const values = reader.read<typeof GetRegionsRequestFormat.table>(
|
|
50
|
+
GetRegionsRequestFormat.table,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return GetRegionsRequest.of(values.applicationId)
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
/**
|