@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.
Files changed (175) hide show
  1. package/package.json +2 -2
  2. package/src/codec/index.ts +51 -221
  3. package/src/dispatch/dispatcher/index.ts +89 -47
  4. package/src/dispatch/session/index.ts +6 -24
  5. package/src/index.ts +2 -4
  6. package/src/photon/balancing/codec/index.ts +27 -53
  7. package/src/photon/balancing/format/authenticate/request/index.ts +52 -6
  8. package/src/photon/balancing/format/friends/request/index.ts +21 -5
  9. package/src/photon/balancing/format/game/create/request/index.ts +45 -8
  10. package/src/photon/balancing/format/game/debug/request/index.ts +19 -4
  11. package/src/photon/balancing/format/game/join/request/index.ts +65 -13
  12. package/src/photon/balancing/format/game/list/request/index.ts +29 -3
  13. package/src/photon/balancing/format/game/random/request/index.ts +58 -10
  14. package/src/photon/balancing/format/groups/request/index.ts +19 -3
  15. package/src/photon/balancing/format/index.ts +7 -0
  16. package/src/photon/balancing/format/leave/request/index.ts +19 -3
  17. package/src/photon/balancing/format/lobby/join/request/index.ts +23 -3
  18. package/src/photon/balancing/format/lobby/stats/request/index.ts +19 -3
  19. package/src/photon/balancing/format/once/request/index.ts +31 -8
  20. package/src/photon/balancing/format/properties/get/request/index.ts +31 -4
  21. package/src/photon/balancing/format/properties/set/request/index.ts +36 -7
  22. package/src/photon/balancing/format/raise/request/index.ts +76 -10
  23. package/src/photon/balancing/format/reader/index.ts +75 -6
  24. package/src/photon/balancing/format/regions/request/index.ts +16 -1
  25. package/src/photon/balancing/format/rpc/request/index.ts +26 -3
  26. package/src/photon/balancing/format/settings/request/index.ts +15 -2
  27. package/src/photon/balancing/format/shared/credentials/index.ts +77 -33
  28. package/src/photon/balancing/format/shared/lobby/index.ts +41 -5
  29. package/src/photon/balancing/format/shared/options/index.ts +56 -24
  30. package/src/photon/balancing/format/table/index.ts +399 -0
  31. package/src/photon/balancing/index.ts +11 -1
  32. package/src/photon/balancing/travel/index.ts +15 -12
  33. package/src/photon/client/connection/index.ts +6 -6
  34. package/src/photon/cluster/back/index.ts +32 -45
  35. package/src/photon/cluster/dresser/index.ts +7 -8
  36. package/src/photon/cluster/front/index.ts +25 -49
  37. package/src/photon/cluster/grid/index.ts +1 -1
  38. package/src/photon/cluster/mover/index.ts +12 -12
  39. package/src/photon/cluster/press/index.ts +2 -18
  40. package/src/photon/cluster/route/game/index.ts +9 -11
  41. package/src/photon/cluster/route/master/index.ts +15 -34
  42. package/src/photon/cluster/route/name/index.ts +4 -21
  43. package/src/photon/cluster/seat/game/index.ts +6 -26
  44. package/src/photon/cluster/seat/master/index.ts +1 -1
  45. package/src/photon/cluster/sessions/index.ts +5 -6
  46. package/src/photon/cluster/spread/index.ts +8 -147
  47. package/src/photon/enet/client/index.ts +1 -8
  48. package/src/photon/enet/gateway/index.ts +5 -15
  49. package/src/photon/enet/index.ts +1 -1
  50. package/src/photon/enet/link/index.ts +34 -15
  51. package/src/photon/enet/outbound/index.ts +279 -0
  52. package/src/photon/enet/peer/index.ts +59 -0
  53. package/src/photon/enet/transport/index.ts +8 -24
  54. package/src/photon/game/admission/index.ts +353 -0
  55. package/src/photon/game/bag/index.ts +13 -0
  56. package/src/photon/game/broadcast/index.ts +79 -0
  57. package/src/photon/game/editor/index.ts +446 -0
  58. package/src/photon/game/gate/index.ts +9 -8
  59. package/src/photon/game/handler/index.ts +30 -3
  60. package/src/photon/game/history/index.ts +234 -0
  61. package/src/photon/game/hooked/index.ts +16 -15
  62. package/src/photon/game/index.ts +12 -1
  63. package/src/photon/game/lifecycle/index.ts +193 -0
  64. package/src/photon/game/peer/index.ts +1 -10
  65. package/src/photon/game/properties/index.ts +342 -0
  66. package/src/photon/game/room/index.ts +435 -1793
  67. package/src/photon/game/rooms/index.ts +2 -1
  68. package/src/photon/game/seats/index.ts +237 -0
  69. package/src/photon/game/server/index.ts +12 -2
  70. package/src/photon/game/services/index.ts +41 -0
  71. package/src/photon/game/settings/index.ts +22 -0
  72. package/src/photon/game/snapshot/index.ts +133 -0
  73. package/src/photon/game/throttle/index.ts +60 -0
  74. package/src/photon/game/touch/index.ts +2 -5
  75. package/src/photon/game/venue/index.ts +31 -0
  76. package/src/photon/master/application/index.ts +7 -0
  77. package/src/photon/master/gate/index.ts +12 -8
  78. package/src/photon/master/handler/index.ts +36 -748
  79. package/src/photon/master/index.ts +5 -0
  80. package/src/photon/master/list/sql/index.ts +37 -3
  81. package/src/photon/master/listing/index.ts +133 -0
  82. package/src/photon/master/lobby/index.ts +9 -0
  83. package/src/photon/master/login/index.ts +424 -0
  84. package/src/photon/master/matchmaking/index.ts +282 -0
  85. package/src/photon/master/query/index.ts +45 -0
  86. package/src/photon/master/redirect/index.ts +8 -7
  87. package/src/photon/master/services/index.ts +35 -0
  88. package/src/photon/master/settings/index.ts +44 -0
  89. package/src/photon/master/sql/cost/index.ts +263 -0
  90. package/src/photon/master/sql/index.ts +1 -0
  91. package/src/photon/message/client/index.ts +14 -11
  92. package/src/photon/message/handler/index.ts +22 -64
  93. package/src/photon/message/pipeline/index.ts +12 -12
  94. package/src/photon/message/server/index.ts +87 -43
  95. package/src/photon/message/watch/index.ts +14 -37
  96. package/src/photon/server/deferral/index.ts +57 -0
  97. package/src/photon/server/host/index.ts +32 -10
  98. package/src/photon/server/index.ts +1 -0
  99. package/src/photon/tcp/client/index.ts +1 -1
  100. package/src/photon/tcp/codec/index.ts +13 -42
  101. package/src/photon/tcp/server/index.ts +4 -4
  102. package/src/photon/websocket/bridge/index.ts +16 -20
  103. package/src/photon/websocket/message/index.ts +27 -39
  104. package/src/photon/websocket/path/index.ts +2 -5
  105. package/src/scale/fanout/index.ts +6 -6
  106. package/src/scale/index.ts +2 -4
  107. package/src/scale/outbound/index.ts +192 -0
  108. package/src/scale/relay/index.ts +20 -31
  109. package/src/scale/sink/index.ts +6 -11
  110. package/src/scale/transport/index.ts +27 -44
  111. package/src/scale/tunnel/index.ts +37 -91
  112. package/src/smartfox/common/bluebox/gateway/index.ts +401 -0
  113. package/src/smartfox/common/bluebox/index.ts +4 -0
  114. package/src/smartfox/{x2 → common}/bluebox/transport/index.ts +36 -23
  115. package/src/smartfox/common/index.ts +5 -0
  116. package/src/smartfox/common/strikes/index.ts +74 -0
  117. package/src/smartfox/pro/bluebox/index.ts +176 -4
  118. package/src/smartfox/pro/codec/index.ts +8 -7
  119. package/src/smartfox/pro/escalation/index.ts +28 -20
  120. package/src/smartfox/pro/flood/index.ts +2 -2
  121. package/src/smartfox/pro/format/extension/raw/index.ts +12 -2
  122. package/src/smartfox/pro/handler/chat/index.ts +11 -8
  123. package/src/smartfox/pro/handler/login/index.ts +2 -25
  124. package/src/smartfox/pro/handler/shared/index.ts +4 -3
  125. package/src/smartfox/pro/index.ts +11 -5
  126. package/src/smartfox/pro/login/gate/index.ts +166 -0
  127. package/src/smartfox/pro/login/index.ts +1 -0
  128. package/src/smartfox/pro/moderation/index.ts +220 -0
  129. package/src/smartfox/pro/options/index.ts +5 -5
  130. package/src/smartfox/pro/protocol/index.ts +62 -8
  131. package/src/smartfox/pro/web/index.ts +33 -26
  132. package/src/smartfox/pro/zone/index.ts +59 -282
  133. package/src/smartfox/pro/zones/index.ts +3 -3
  134. package/src/smartfox/x2/bluebox/index.ts +149 -4
  135. package/src/smartfox/x2/chat/index.ts +9 -19
  136. package/src/smartfox/x2/codec/index.ts +31 -39
  137. package/src/smartfox/x2/config/index.ts +6 -1
  138. package/src/smartfox/x2/data/array/index.ts +96 -60
  139. package/src/smartfox/x2/data/object/index.ts +144 -82
  140. package/src/smartfox/x2/data/serializer/index.ts +41 -23
  141. package/src/smartfox/x2/flood/gate/index.ts +19 -13
  142. package/src/smartfox/x2/format/buddy/init/response/index.ts +4 -3
  143. package/src/smartfox/x2/format/find/rooms/response/index.ts +4 -3
  144. package/src/smartfox/x2/format/find/users/response/index.ts +4 -3
  145. package/src/smartfox/x2/format/group/subscribe/response/index.ts +4 -3
  146. package/src/smartfox/x2/format/login/response/index.ts +4 -3
  147. package/src/smartfox/x2/format/mmo/position/response/index.ts +8 -6
  148. package/src/smartfox/x2/format/room/join/response/index.ts +4 -3
  149. package/src/smartfox/x2/games/index.ts +35 -8
  150. package/src/smartfox/x2/hall/index.ts +0 -6
  151. package/src/smartfox/x2/handler/session/index.ts +1 -1
  152. package/src/smartfox/x2/index.ts +8 -3
  153. package/src/smartfox/x2/member/index.ts +10 -3
  154. package/src/smartfox/x2/packet/login/response/index.ts +12 -0
  155. package/src/smartfox/x2/protocol/index.ts +11 -1
  156. package/src/smartfox/x2/rooms/index.ts +1 -2
  157. package/src/smartfox/x2/sessions/index.ts +6 -0
  158. package/src/smartfox/x2/udp/index.ts +61 -24
  159. package/src/smartfox/x2/web/index.ts +35 -17
  160. package/src/smartfox/x2/websocket/index.ts +18 -36
  161. package/src/smartfox/x2/zone/index.ts +77 -28
  162. package/src/smartfox/x2/zones/index.ts +17 -5
  163. package/src/photon/enet/handler/index.ts +0 -65
  164. package/src/scale/hosted/index.ts +0 -68
  165. package/src/scale/outlet/index.ts +0 -121
  166. package/src/smartfox/pro/bluebox/gateway/index.ts +0 -310
  167. package/src/smartfox/pro/bluebox/session/index.ts +0 -63
  168. package/src/smartfox/pro/bluebox/transport/index.ts +0 -104
  169. package/src/smartfox/x2/bluebox/gateway/index.ts +0 -315
  170. /package/src/smartfox/{x2 → common}/bluebox/session/index.ts +0 -0
  171. /package/src/smartfox/{pro → common}/counters/index.ts +0 -0
  172. /package/src/smartfox/{pro → common}/counters/memory/index.ts +0 -0
  173. /package/src/smartfox/{pro → common}/counters/offender/index.ts +0 -0
  174. /package/src/smartfox/{pro → common}/counters/store/index.ts +0 -0
  175. /package/src/smartfox/{pro → common}/sequence/index.ts +0 -0
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  type Channel,
3
- type ChannelHandler,
4
3
  type ChannelSetup,
5
4
  type HandlerContext,
6
5
  InboundHandlerAdapter,
@@ -59,8 +58,8 @@ export class Dresser extends InboundHandlerAdapter {
59
58
  * @param outfit adds the cluster's handlers
60
59
  */
61
60
  private static after(setup: ChannelSetup, outfit: Outfit): ChannelSetup {
62
- return async (channel: Channel): Promise<void> => {
63
- await setup(channel)
61
+ return (channel: Channel): void => {
62
+ setup(channel)
64
63
  channel.pipeline.addLast<Dresser>(Dresser.NAME, new Dresser(outfit))
65
64
  }
66
65
  }
@@ -69,15 +68,15 @@ export class Dresser extends InboundHandlerAdapter {
69
68
  * Dresses the pipeline once the message layer is in it
70
69
  * @param context the connection
71
70
  */
72
- public override async channelActive(context: HandlerContext): Promise<void> {
71
+ public override channelActive(context: HandlerContext): void {
73
72
  const pipeline = context.pipeline
74
- if (pipeline.get<ChannelHandler>(MessagePipeline.handler) === null) {
75
- await context.fireChannelActive()
73
+ if (pipeline.get(MessagePipeline.handler) === null) {
74
+ context.fireChannelActive()
76
75
  return
77
76
  }
78
77
 
79
78
  this.outfit(context.channel)
80
- await context.fireChannelActive()
81
- pipeline.remove<Dresser>(context.name)
79
+ context.fireChannelActive()
80
+ pipeline.remove(context.name)
82
81
  }
83
82
  }
@@ -70,27 +70,29 @@ export class FrontBridge extends DuplexHandlerAdapter {
70
70
  * @param context the connection
71
71
  * @param message an envelope, or anything else
72
72
  */
73
- public override channelRead(
74
- context: HandlerContext,
75
- message: unknown,
76
- ): void | Promise<void> {
73
+ public override channelRead(context: HandlerContext, message: unknown): void {
77
74
  if (this.moved && message instanceof WireMessage) {
78
- return message.body instanceof Uint8Array
79
- ? context.fireChannelRead(
80
- ByteBuf.wrap(Carriage.forward(message, message.body)),
81
- )
82
- : context.fireChannelRead(message)
75
+ context.fireChannelRead(
76
+ message.body instanceof Uint8Array
77
+ ? ByteBuf.wrap(Carriage.forward(message, message.body))
78
+ : message,
79
+ )
80
+ return
83
81
  }
84
82
 
85
- if (!(message instanceof Envelope)) return context.fireChannelRead(message)
83
+ if (!(message instanceof Envelope)) {
84
+ context.fireChannelRead(message)
85
+ return
86
+ }
86
87
 
87
88
  const envelope = message as Envelope
88
89
  if (this.moved) {
89
- return context.fireChannelRead(ByteBuf.wrap(Carriage.pack(envelope)))
90
+ context.fireChannelRead(ByteBuf.wrap(Carriage.pack(envelope)))
91
+ return
90
92
  }
91
93
 
92
94
  this.last = envelope
93
- return context.fireChannelRead(message)
95
+ context.fireChannelRead(message)
94
96
  }
95
97
 
96
98
  /**
@@ -98,35 +100,33 @@ export class FrontBridge extends DuplexHandlerAdapter {
98
100
  * @param context the connection
99
101
  * @param event whatever happened
100
102
  */
101
- public override async userEventTriggered(
103
+ public override userEventTriggered(
102
104
  context: HandlerContext,
103
105
  event: unknown,
104
- ): Promise<void> {
106
+ ): void {
105
107
  if (
106
108
  this.moved &&
107
109
  event instanceof IdleStateEvent &&
108
110
  event.state === 'reader'
109
111
  ) {
110
- await context.fireChannelRead(ByteBuf.wrap(Carriage.idle()))
112
+ context.fireChannelRead(ByteBuf.wrap(Carriage.idle()))
111
113
  return
112
114
  }
113
115
 
114
- await context.fireUserEventTriggered(event)
116
+ context.fireUserEventTriggered(event)
115
117
  }
116
118
 
117
119
  /**
118
120
  * Tells a moved session's shard how its client's connection ended
119
121
  * @param context the connection
120
122
  */
121
- public override async channelInactive(
122
- context: HandlerContext,
123
- ): Promise<void> {
123
+ public override channelInactive(context: HandlerContext): void {
124
124
  const closure = EnetPeer.of(context.channel)?.closure ?? null
125
125
  if (this.moved && closure !== null) {
126
- await context.fireChannelRead(ByteBuf.wrap(Carriage.farewell(closure)))
126
+ context.fireChannelRead(ByteBuf.wrap(Carriage.farewell(closure)))
127
127
  }
128
128
 
129
- await context.fireChannelInactive()
129
+ context.fireChannelInactive()
130
130
  }
131
131
 
132
132
  /**
@@ -134,42 +134,18 @@ export class FrontBridge extends DuplexHandlerAdapter {
134
134
  * @param context where the write goes
135
135
  * @param message packed messages, or anything else
136
136
  */
137
- public override write(
138
- context: HandlerContext,
139
- message: unknown,
140
- ): Promise<void> {
141
- if (!(message instanceof ByteBuf)) return context.write(message)
142
-
143
- const plain = FrontBridge.plain(context)
144
- const writes: Promise<void>[] = []
145
- for (const cargo of this.unpack(message)) {
146
- if (!(cargo instanceof Parcel)) continue
147
-
148
- writes.push(context.write(FrontBridge.outbound(cargo, plain)))
149
- }
150
-
151
- return Promise.all(writes).then((): void => undefined)
152
- }
153
-
154
- /**
155
- * Unpacks what a moved session's shard sent, without a promise
156
- * @param context where the write goes
157
- * @param message packed messages, or anything else
158
- */
159
- public writeSync(context: HandlerContext, message: unknown): boolean {
137
+ public override write(context: HandlerContext, message: unknown): void {
160
138
  if (!(message instanceof ByteBuf)) {
161
- context.writeSync(message)
162
- return true
139
+ context.write(message)
140
+ return
163
141
  }
164
142
 
165
143
  const plain = FrontBridge.plain(context)
166
144
  for (const cargo of this.unpack(message)) {
167
145
  if (cargo instanceof Parcel) {
168
- context.writeSync(FrontBridge.outbound(cargo, plain))
146
+ context.write(FrontBridge.outbound(cargo, plain))
169
147
  }
170
148
  }
171
-
172
- return true
173
149
  }
174
150
 
175
151
  /**
@@ -336,10 +336,10 @@ export class Grid {
336
336
  const seat = new GameSeat(
337
337
  server,
338
338
  this.shared ? this.mover : null,
339
- this.spreader,
340
339
  authority,
341
340
  clock,
342
341
  )
342
+ server.broadcaster.reroute(this.spreader)
343
343
  this.sessions.game(seat)
344
344
  this.reporting?.attach((): void => {
345
345
  server.replicate()
@@ -1,8 +1,8 @@
1
1
  import type { Channel, HandlerContext } from '@netifyjs/netify'
2
2
 
3
- import type { PacketDispatcher } from '../../../dispatch/dispatcher/index.ts'
3
+ import { PacketDispatcher } from '../../../dispatch/dispatcher/index.ts'
4
+ import { Session } from '../../../dispatch/session/index.ts'
4
5
  import type { Mesh } from '../../../scale/mesh/index.ts'
5
- import { Tunnel } from '../../../scale/tunnel/index.ts'
6
6
  import { PhotonPeer } from '../../message/peer/index.ts'
7
7
  import { Carriage } from '../carriage/index.ts'
8
8
  import { FrontBridge } from '../front/index.ts'
@@ -117,22 +117,22 @@ export class SessionMover {
117
117
  * @param scope an application or a room
118
118
  * @param luggage what goes along
119
119
  */
120
- public async move(
120
+ public move(
121
121
  context: HandlerContext,
122
122
  scope: string,
123
123
  luggage: Luggage,
124
- ): Promise<boolean> {
124
+ ): boolean {
125
125
  const channel = context.channel
126
126
  const owner = this.mesh.ownerOf(scope)
127
- if (owner === this.mesh.link.id || Tunnel.carries(channel)) return false
127
+ if (owner === this.mesh.link.id || Session.of(channel).moved) return false
128
128
 
129
- const bridge = channel.pipeline.get<FrontBridge>(FrontBridge.NAME)
129
+ const bridge = channel.pipeline.get(FrontBridge.NAME)
130
130
  const photon = PhotonPeer.of(channel)
131
- if (bridge === null || photon === null) return false
131
+ if (!(bridge instanceof FrontBridge) || photon === null) return false
132
132
 
133
133
  const bytes = SessionMover.opening(bridge, luggage)
134
134
  Seeds.stash(channel, Seeds.of(luggage.role, photon, luggage.ticket))
135
- await SessionMover.release(channel)
135
+ SessionMover.release(channel)
136
136
 
137
137
  bridge.engage()
138
138
  photon.forward()
@@ -161,13 +161,13 @@ export class SessionMover {
161
161
  * Tells this shard's server the session is gone
162
162
  * @param channel the client's connection
163
163
  */
164
- private static async release(channel: Channel): Promise<void> {
164
+ private static release(channel: Channel): void {
165
165
  const pipeline = channel.pipeline
166
166
  const name = SessionMover.DISPATCHER
167
- const dispatcher = pipeline.get<PacketDispatcher<unknown>>(name)
167
+ const dispatcher = pipeline.get(name)
168
168
  const context = pipeline.context(name)
169
- if (dispatcher === null || context === null) return
169
+ if (!(dispatcher instanceof PacketDispatcher) || context === null) return
170
170
 
171
- await dispatcher.channelInactive(context)
171
+ dispatcher.channelInactive(context)
172
172
  }
173
173
  }
@@ -34,24 +34,8 @@ class Catch extends OutboundHandlerAdapter {
34
34
  * @param _context unused
35
35
  * @param message what the codec wrote
36
36
  */
37
- public override write(
38
- _context: HandlerContext,
39
- message: unknown,
40
- ): Promise<void> {
41
- this.writeSync(_context, message)
42
-
43
- return Promise.resolve()
44
- }
45
-
46
- /**
47
- * Keeps an envelope and drops everything else, without a promise
48
- * @param _context unused
49
- * @param message what the codec wrote
50
- */
51
- public writeSync(_context: HandlerContext, message: unknown): boolean {
37
+ public override write(_context: HandlerContext, message: unknown): void {
52
38
  this.caught = message instanceof Envelope ? (message as Envelope) : null
53
-
54
- return true
55
39
  }
56
40
  }
57
41
 
@@ -89,7 +73,7 @@ export class PacketPress {
89
73
  if (!(packet instanceof PacketAdapter)) return null
90
74
 
91
75
  this.output.caught = null
92
- this.channel.pipeline.writeSync(packet)
76
+ this.channel.pipeline.write(packet)
93
77
 
94
78
  return this.output.caught
95
79
  }
@@ -55,18 +55,16 @@ export class GameRouter extends InboundHandlerAdapter {
55
55
  * @param context the connection
56
56
  * @param message a packet, or anything else
57
57
  */
58
- public override channelRead(
59
- context: HandlerContext,
60
- message: unknown,
61
- ): void | Promise<void> {
58
+ public override channelRead(context: HandlerContext, message: unknown): void {
62
59
  if (
63
60
  message instanceof CreateGameRequest ||
64
61
  message instanceof JoinGameRequest
65
62
  ) {
66
- return this.enter(context, message)
63
+ this.enter(context, message)
64
+ return
67
65
  }
68
66
 
69
- return context.fireChannelRead(message)
67
+ context.fireChannelRead(message)
70
68
  }
71
69
 
72
70
  /**
@@ -74,22 +72,22 @@ export class GameRouter extends InboundHandlerAdapter {
74
72
  * @param context the connection
75
73
  * @param message the create or join request
76
74
  */
77
- private async enter(
75
+ private enter(
78
76
  context: HandlerContext,
79
77
  message: CreateGameRequest | JoinGameRequest,
80
- ): Promise<void> {
78
+ ): void {
81
79
  const room = message.roomName
82
80
  const token = GamePeer.of(context.channel, this.clock.now()).token
83
81
  const moved =
84
82
  room !== null &&
85
83
  token !== null &&
86
- (await this.mover.move(
84
+ this.mover.move(
87
85
  context,
88
86
  `${MasterRouter.SCOPE}${room}`,
89
87
  Luggage.game(this.authority.seal(token, false)),
90
- ))
88
+ )
91
89
  if (moved) return
92
90
 
93
- await context.fireChannelRead(message)
91
+ context.fireChannelRead(message)
94
92
  }
95
93
  }
@@ -75,17 +75,15 @@ export class MasterRouter extends DuplexHandlerAdapter {
75
75
  * @param context the connection
76
76
  * @param message a packet, or anything else
77
77
  */
78
- public override channelRead(
79
- context: HandlerContext,
80
- message: unknown,
81
- ): void | Promise<void> {
78
+ public override channelRead(context: HandlerContext, message: unknown): void {
82
79
  if (message instanceof CreateGameRequest) this.asked = message.roomName
83
80
  if (message instanceof JoinGameRequest) this.asked = message.roomName
84
81
  if (message instanceof AuthenticateRequest) {
85
- return this.login(context, message)
82
+ this.login(context, message)
83
+ return
86
84
  }
87
85
 
88
- return context.fireChannelRead(message)
86
+ context.fireChannelRead(message)
89
87
  }
90
88
 
91
89
  /**
@@ -93,21 +91,18 @@ export class MasterRouter extends DuplexHandlerAdapter {
93
91
  * @param context the connection
94
92
  * @param message the login
95
93
  */
96
- private async login(
97
- context: HandlerContext,
98
- message: AuthenticateRequest,
99
- ): Promise<void> {
94
+ private login(context: HandlerContext, message: AuthenticateRequest): void {
100
95
  const application = this.application(message)
101
96
  const moved =
102
97
  application !== null &&
103
- (await this.mover.move(
98
+ this.mover.move(
104
99
  context,
105
100
  `${NameRouter.SCOPE}${application}`,
106
101
  Luggage.master(true),
107
- ))
102
+ )
108
103
  if (moved) return
109
104
 
110
- await context.fireChannelRead(message)
105
+ context.fireChannelRead(message)
111
106
  }
112
107
 
113
108
  /**
@@ -115,22 +110,22 @@ export class MasterRouter extends DuplexHandlerAdapter {
115
110
  * @param context the connection
116
111
  * @param event whatever happened
117
112
  */
118
- public override async userEventTriggered(
113
+ public override userEventTriggered(
119
114
  context: HandlerContext,
120
115
  event: unknown,
121
- ): Promise<void> {
116
+ ): void {
122
117
  const token =
123
118
  event instanceof InitRequest ? TokenGate.admitted(context.channel) : null
124
119
  const moved =
125
120
  token !== null &&
126
- (await this.mover.move(
121
+ this.mover.move(
127
122
  context,
128
123
  `${NameRouter.SCOPE}${token.applicationId ?? ''}`,
129
124
  Luggage.master(false),
130
- ))
125
+ )
131
126
  if (moved) return
132
127
 
133
- await context.fireUserEventTriggered(event)
128
+ context.fireUserEventTriggered(event)
134
129
  }
135
130
 
136
131
  /**
@@ -138,22 +133,8 @@ export class MasterRouter extends DuplexHandlerAdapter {
138
133
  * @param context the connection
139
134
  * @param message a packet, or anything else
140
135
  */
141
- public override write(
142
- context: HandlerContext,
143
- message: unknown,
144
- ): Promise<void> {
145
- return context.write(this.directed(context.channel, message))
146
- }
147
-
148
- /**
149
- * Points an answer at the shard that owns the room without waiting
150
- * @param context the connection
151
- * @param message a packet, or anything else
152
- */
153
- public writeSync(context: HandlerContext, message: unknown): boolean {
154
- context.writeSync(this.directed(context.channel, message))
155
-
156
- return true
136
+ public override write(context: HandlerContext, message: unknown): void {
137
+ context.write(this.directed(context.channel, message))
157
138
  }
158
139
 
159
140
  /**
@@ -68,10 +68,7 @@ export class NameRouter extends DuplexHandlerAdapter {
68
68
  * @param context the connection
69
69
  * @param message a packet, or anything else
70
70
  */
71
- public override channelRead(
72
- context: HandlerContext,
73
- message: unknown,
74
- ): void | Promise<void> {
71
+ public override channelRead(context: HandlerContext, message: unknown): void {
75
72
  if (message instanceof AuthenticateRequest) {
76
73
  this.application = message.credentials?.applicationId ?? null
77
74
  } else if (message instanceof AuthenticateOnceRequest) {
@@ -81,7 +78,7 @@ export class NameRouter extends DuplexHandlerAdapter {
81
78
  this.application = message.applicationId
82
79
  }
83
80
 
84
- return context.fireChannelRead(message)
81
+ context.fireChannelRead(message)
85
82
  }
86
83
 
87
84
  /**
@@ -89,22 +86,8 @@ export class NameRouter extends DuplexHandlerAdapter {
89
86
  * @param context the connection
90
87
  * @param message a packet, or anything else
91
88
  */
92
- public override write(
93
- context: HandlerContext,
94
- message: unknown,
95
- ): Promise<void> {
96
- return context.write(this.directed(context.channel, message))
97
- }
98
-
99
- /**
100
- * Points an answer at the owning shard's Master without waiting
101
- * @param context the connection
102
- * @param message a packet, or anything else
103
- */
104
- public writeSync(context: HandlerContext, message: unknown): boolean {
105
- context.writeSync(this.directed(context.channel, message))
106
-
107
- return true
89
+ public override write(context: HandlerContext, message: unknown): void {
90
+ context.write(this.directed(context.channel, message))
108
91
  }
109
92
 
110
93
  /**
@@ -10,7 +10,6 @@ import { FrontBridge } from '../../front/index.ts'
10
10
  import type { SessionMover } from '../../mover/index.ts'
11
11
  import { GameRouter } from '../../route/game/index.ts'
12
12
  import { Seeds, type SessionSeed } from '../../seed/index.ts'
13
- import { SpreadHandler, type Spreader } from '../../spread/index.ts'
14
13
 
15
14
  /**
16
15
  * A Game Server's place among the shards
@@ -27,11 +26,6 @@ export class GameSeat {
27
26
  */
28
27
  private readonly mover: SessionMover | null
29
28
 
30
- /**
31
- * Gathers room broadcasts
32
- */
33
- private readonly spreader: Spreader
34
-
35
29
  /**
36
30
  * Seals and reads the tokens sessions take along
37
31
  */
@@ -45,20 +39,17 @@ export class GameSeat {
45
39
  /**
46
40
  * @param server the Game Server of this shard
47
41
  * @param mover carries sessions to other shards, or null
48
- * @param spreader gathers room broadcasts
49
42
  * @param authority seals and reads the tokens sessions take along
50
43
  * @param clock tells the time
51
44
  */
52
45
  public constructor(
53
46
  server: GameServer,
54
47
  mover: SessionMover | null,
55
- spreader: Spreader,
56
48
  authority: TokenAuthority,
57
49
  clock: Clock,
58
50
  ) {
59
51
  this.server = server
60
52
  this.mover = mover
61
- this.spreader = spreader
62
53
  this.authority = authority
63
54
  this.clock = clock
64
55
  }
@@ -69,17 +60,11 @@ export class GameSeat {
69
60
  */
70
61
  public outfit(channel: Channel): void {
71
62
  const pipeline = channel.pipeline
72
- pipeline
73
- .addAfter<FrontBridge>(
74
- MessagePipeline.handler,
75
- FrontBridge.NAME,
76
- new FrontBridge(),
77
- )
78
- .addBefore<SpreadHandler>(
79
- GameServer.dispatcher,
80
- SpreadHandler.NAME,
81
- new SpreadHandler(this.spreader),
82
- )
63
+ pipeline.addAfter<FrontBridge>(
64
+ MessagePipeline.handler,
65
+ FrontBridge.NAME,
66
+ new FrontBridge(),
67
+ )
83
68
  if (this.mover === null) return
84
69
 
85
70
  pipeline.addBefore<GameRouter>(
@@ -102,12 +87,7 @@ export class GameSeat {
102
87
  Seeds.open(channel, seed).initialise(init)
103
88
  channel.pipeline.addLast<BackBridge>(BackBridge.NAME, new BackBridge(init))
104
89
 
105
- void this.server.setup(false)(channel)
106
- channel.pipeline.addBefore<SpreadHandler>(
107
- GameServer.dispatcher,
108
- SpreadHandler.NAME,
109
- new SpreadHandler(this.spreader),
110
- )
90
+ this.server.setup(false)(channel)
111
91
  GamePeer.of(channel, this.clock.now()).token = token
112
92
  }
113
93
  }
@@ -78,7 +78,7 @@ export class MasterSeat {
78
78
 
79
79
  const pipeline = channel.pipeline
80
80
  pipeline.addLast<BackBridge>(BackBridge.NAME, new BackBridge(init))
81
- void this.server.setup(false)(channel)
81
+ this.server.setup(false)(channel)
82
82
 
83
83
  if (pipeline.context(SessionMover.DISPATCHER) === null) return
84
84
  pipeline.addBefore<MasterRouter>(
@@ -1,8 +1,8 @@
1
1
  import type { Channel, ChannelHandler } from '@netifyjs/netify'
2
2
 
3
3
  import { PacketDispatcher } from '../../../dispatch/dispatcher/index.ts'
4
+ import { Session } from '../../../dispatch/session/index.ts'
4
5
  import type { Portable, Reach } from '../../../scale/portable/index.ts'
5
- import { Tunnel } from '../../../scale/tunnel/index.ts'
6
6
  import { BalancingCodec } from '../../balancing/codec/index.ts'
7
7
  import { GameGate } from '../../game/gate/index.ts'
8
8
  import { SharedFrames } from '../../game/shared/index.ts'
@@ -14,7 +14,6 @@ import { MasterRouter } from '../route/master/index.ts'
14
14
  import type { GameSeat } from '../seat/game/index.ts'
15
15
  import type { MasterSeat } from '../seat/master/index.ts'
16
16
  import { type SeedRole, Seeds, type SessionSeed } from '../seed/index.ts'
17
- import { SpreadHandler } from '../spread/index.ts'
18
17
 
19
18
  /**
20
19
  * Photon's side of moving sessions and sharing broadcasts between shards
@@ -107,8 +106,7 @@ export class Sessions implements Portable<SessionSeed> {
107
106
  handler instanceof OperationGate ||
108
107
  handler instanceof TouchHandler ||
109
108
  handler instanceof MasterRouter ||
110
- handler instanceof GameRouter ||
111
- handler instanceof SpreadHandler
109
+ handler instanceof GameRouter
112
110
  )
113
111
  }
114
112
 
@@ -119,9 +117,10 @@ export class Sessions implements Portable<SessionSeed> {
119
117
  public reach(channel: Channel): Reach {
120
118
  if (SharedFrames.reads(channel)) return 'socket'
121
119
 
120
+ const bridge = channel.pipeline.get(FrontBridge.NAME)
122
121
  const away =
123
- Tunnel.carries(channel) ||
124
- channel.pipeline.get<FrontBridge>(FrontBridge.NAME)?.engaged === true
122
+ Session.of(channel).moved ||
123
+ (bridge instanceof FrontBridge && bridge.engaged)
125
124
 
126
125
  return away ? 'pipeline' : 'packet'
127
126
  }