@netifyjs/protocol 0.0.0-stage → 1.0.0-alpha.2
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/LICENSE +21 -0
- package/README.md +38 -2
- package/package.json +56 -4
- package/src/codec/index.ts +256 -0
- package/src/dispatch/dispatcher/index.ts +200 -0
- package/src/dispatch/event/index.ts +49 -0
- package/src/dispatch/index.ts +11 -0
- package/src/dispatch/route/index.ts +141 -0
- package/src/dispatch/session/index.ts +60 -0
- package/src/format/index.ts +72 -0
- package/src/index.ts +66 -0
- package/src/names/index.ts +73 -0
- package/src/photon/application/index.ts +76 -0
- package/src/photon/authentication/admission/index.ts +47 -0
- package/src/photon/authentication/authenticator/index.ts +106 -0
- package/src/photon/authentication/failure/index.ts +15 -0
- package/src/photon/authentication/gate/index.ts +221 -0
- package/src/photon/authentication/http/index.ts +337 -0
- package/src/photon/authentication/index.ts +18 -0
- package/src/photon/authentication/keys/index.ts +67 -0
- package/src/photon/authentication/provider/index.ts +48 -0
- package/src/photon/authentication/queue/index.ts +284 -0
- package/src/photon/authentication/result/index.ts +191 -0
- package/src/photon/balancing/catalogue/events/index.ts +93 -0
- package/src/photon/balancing/catalogue/index.ts +148 -0
- package/src/photon/balancing/catalogue/requests/index.ts +104 -0
- package/src/photon/balancing/catalogue/responses/index.ts +106 -0
- package/src/photon/balancing/code/actor/index.ts +24 -0
- package/src/photon/balancing/code/authentication/index.ts +101 -0
- package/src/photon/balancing/code/caching/index.ts +69 -0
- package/src/photon/balancing/code/cause/index.ts +115 -0
- package/src/photon/balancing/code/error/index.ts +280 -0
- package/src/photon/balancing/code/event/index.ts +104 -0
- package/src/photon/balancing/code/friends/index.ts +35 -0
- package/src/photon/balancing/code/game/index.ts +69 -0
- package/src/photon/balancing/code/index.ts +52 -0
- package/src/photon/balancing/code/join/index.ts +29 -0
- package/src/photon/balancing/code/lobby/index.ts +29 -0
- package/src/photon/balancing/code/matchmaking/index.ts +25 -0
- package/src/photon/balancing/code/message/index.ts +507 -0
- package/src/photon/balancing/code/operation/index.ts +124 -0
- package/src/photon/balancing/code/parameter/index.ts +414 -0
- package/src/photon/balancing/code/ping/index.ts +29 -0
- package/src/photon/balancing/code/port/index.ts +89 -0
- package/src/photon/balancing/code/property/index.ts +30 -0
- package/src/photon/balancing/code/receiver/index.ts +24 -0
- package/src/photon/balancing/code/room/index.ts +45 -0
- package/src/photon/balancing/code/state/index.ts +109 -0
- package/src/photon/balancing/code/status/index.ts +89 -0
- package/src/photon/balancing/code/web/index.ts +29 -0
- package/src/photon/balancing/codec/index.ts +294 -0
- package/src/photon/balancing/dotnet/index.ts +55 -0
- package/src/photon/balancing/entity/authentication/index.ts +51 -0
- package/src/photon/balancing/entity/credentials/index.ts +77 -0
- package/src/photon/balancing/entity/entry/index.ts +77 -0
- package/src/photon/balancing/entity/grant/index.ts +192 -0
- package/src/photon/balancing/entity/index.ts +7 -0
- package/src/photon/balancing/entity/lobby/index.ts +35 -0
- package/src/photon/balancing/entity/options/index.ts +174 -0
- package/src/photon/balancing/entity/stat/index.ts +59 -0
- package/src/photon/balancing/format/authenticate/index.ts +2 -0
- package/src/photon/balancing/format/authenticate/request/index.ts +82 -0
- package/src/photon/balancing/format/authenticate/response/index.ts +61 -0
- package/src/photon/balancing/format/contract/index.ts +51 -0
- package/src/photon/balancing/format/event/auth/index.ts +49 -0
- package/src/photon/balancing/format/event/azure/index.ts +56 -0
- package/src/photon/balancing/format/event/custom/index.ts +55 -0
- package/src/photon/balancing/format/event/disconnect/index.ts +54 -0
- package/src/photon/balancing/format/event/error/index.ts +51 -0
- package/src/photon/balancing/format/event/index.ts +16 -0
- package/src/photon/balancing/format/event/join/index.ts +58 -0
- package/src/photon/balancing/format/event/leave/index.ts +60 -0
- package/src/photon/balancing/format/event/list/index.ts +53 -0
- package/src/photon/balancing/format/event/match/index.ts +55 -0
- package/src/photon/balancing/format/event/offline/index.ts +52 -0
- package/src/photon/balancing/format/event/properties/index.ts +60 -0
- package/src/photon/balancing/format/event/purged/index.ts +44 -0
- package/src/photon/balancing/format/event/queue/index.ts +51 -0
- package/src/photon/balancing/format/event/slice/index.ts +57 -0
- package/src/photon/balancing/format/event/stats/app/index.ts +60 -0
- package/src/photon/balancing/format/event/stats/index.ts +2 -0
- package/src/photon/balancing/format/event/stats/lobby/index.ts +54 -0
- package/src/photon/balancing/format/event/update/index.ts +53 -0
- package/src/photon/balancing/format/friends/index.ts +2 -0
- package/src/photon/balancing/format/friends/request/index.ts +56 -0
- package/src/photon/balancing/format/friends/response/index.ts +64 -0
- package/src/photon/balancing/format/game/create/index.ts +2 -0
- package/src/photon/balancing/format/game/create/request/index.ts +79 -0
- package/src/photon/balancing/format/game/create/response/index.ts +87 -0
- package/src/photon/balancing/format/game/debug/index.ts +2 -0
- package/src/photon/balancing/format/game/debug/request/index.ts +55 -0
- package/src/photon/balancing/format/game/debug/response/index.ts +60 -0
- package/src/photon/balancing/format/game/index.ts +17 -0
- package/src/photon/balancing/format/game/join/index.ts +2 -0
- package/src/photon/balancing/format/game/join/request/index.ts +93 -0
- package/src/photon/balancing/format/game/join/response/index.ts +87 -0
- package/src/photon/balancing/format/game/list/index.ts +2 -0
- package/src/photon/balancing/format/game/list/request/index.ts +59 -0
- package/src/photon/balancing/format/game/list/response/index.ts +57 -0
- package/src/photon/balancing/format/game/random/index.ts +2 -0
- package/src/photon/balancing/format/game/random/request/index.ts +87 -0
- package/src/photon/balancing/format/game/random/response/index.ts +66 -0
- package/src/photon/balancing/format/groups/index.ts +2 -0
- package/src/photon/balancing/format/groups/request/index.ts +54 -0
- package/src/photon/balancing/format/groups/response/index.ts +52 -0
- package/src/photon/balancing/format/index.ts +88 -0
- package/src/photon/balancing/format/leave/index.ts +2 -0
- package/src/photon/balancing/format/leave/request/index.ts +54 -0
- package/src/photon/balancing/format/leave/response/index.ts +49 -0
- package/src/photon/balancing/format/lobby/index.ts +12 -0
- package/src/photon/balancing/format/lobby/join/index.ts +2 -0
- package/src/photon/balancing/format/lobby/join/request/index.ts +63 -0
- package/src/photon/balancing/format/lobby/join/response/index.ts +45 -0
- package/src/photon/balancing/format/lobby/leave/index.ts +2 -0
- package/src/photon/balancing/format/lobby/leave/request/index.ts +43 -0
- package/src/photon/balancing/format/lobby/leave/response/index.ts +45 -0
- package/src/photon/balancing/format/lobby/stats/index.ts +2 -0
- package/src/photon/balancing/format/lobby/stats/request/index.ts +54 -0
- package/src/photon/balancing/format/lobby/stats/response/index.ts +62 -0
- package/src/photon/balancing/format/once/index.ts +2 -0
- package/src/photon/balancing/format/once/request/index.ts +72 -0
- package/src/photon/balancing/format/once/response/index.ts +65 -0
- package/src/photon/balancing/format/ping/index.ts +2 -0
- package/src/photon/balancing/format/ping/request/index.ts +43 -0
- package/src/photon/balancing/format/ping/response/index.ts +49 -0
- package/src/photon/balancing/format/properties/get/index.ts +2 -0
- package/src/photon/balancing/format/properties/get/request/index.ts +58 -0
- package/src/photon/balancing/format/properties/get/response/index.ts +62 -0
- package/src/photon/balancing/format/properties/index.ts +8 -0
- package/src/photon/balancing/format/properties/set/index.ts +2 -0
- package/src/photon/balancing/format/properties/set/request/index.ts +66 -0
- package/src/photon/balancing/format/properties/set/response/index.ts +53 -0
- package/src/photon/balancing/format/raise/index.ts +2 -0
- package/src/photon/balancing/format/raise/request/index.ts +93 -0
- package/src/photon/balancing/format/raise/response/index.ts +49 -0
- package/src/photon/balancing/format/reader/index.ts +362 -0
- package/src/photon/balancing/format/regions/index.ts +2 -0
- package/src/photon/balancing/format/regions/request/index.ts +49 -0
- package/src/photon/balancing/format/regions/response/index.ts +62 -0
- package/src/photon/balancing/format/rpc/index.ts +2 -0
- package/src/photon/balancing/format/rpc/request/index.ts +56 -0
- package/src/photon/balancing/format/rpc/response/index.ts +62 -0
- package/src/photon/balancing/format/settings/index.ts +2 -0
- package/src/photon/balancing/format/settings/request/index.ts +52 -0
- package/src/photon/balancing/format/settings/response/index.ts +49 -0
- package/src/photon/balancing/format/shared/credentials/index.ts +84 -0
- package/src/photon/balancing/format/shared/entry/index.ts +43 -0
- package/src/photon/balancing/format/shared/grant/index.ts +96 -0
- package/src/photon/balancing/format/shared/index.ts +6 -0
- package/src/photon/balancing/format/shared/lobby/index.ts +36 -0
- package/src/photon/balancing/format/shared/options/index.ts +68 -0
- package/src/photon/balancing/format/shared/stats/index.ts +55 -0
- package/src/photon/balancing/format/writer/index.ts +187 -0
- package/src/photon/balancing/index.ts +239 -0
- package/src/photon/balancing/packet/adapter/index.ts +39 -0
- package/src/photon/balancing/packet/authenticate/index.ts +2 -0
- package/src/photon/balancing/packet/authenticate/request/index.ts +105 -0
- package/src/photon/balancing/packet/authenticate/response/index.ts +49 -0
- package/src/photon/balancing/packet/event/auth/index.ts +30 -0
- package/src/photon/balancing/packet/event/azure/index.ts +54 -0
- package/src/photon/balancing/packet/event/custom/index.ts +50 -0
- package/src/photon/balancing/packet/event/disconnect/index.ts +30 -0
- package/src/photon/balancing/packet/event/error/index.ts +29 -0
- package/src/photon/balancing/packet/event/index.ts +16 -0
- package/src/photon/balancing/packet/event/join/index.ts +54 -0
- package/src/photon/balancing/packet/event/leave/index.ts +63 -0
- package/src/photon/balancing/packet/event/list/index.ts +30 -0
- package/src/photon/balancing/packet/event/match/index.ts +37 -0
- package/src/photon/balancing/packet/event/offline/index.ts +29 -0
- package/src/photon/balancing/packet/event/properties/index.ts +58 -0
- package/src/photon/balancing/packet/event/purged/index.ts +21 -0
- package/src/photon/balancing/packet/event/queue/index.ts +29 -0
- package/src/photon/balancing/packet/event/slice/index.ts +40 -0
- package/src/photon/balancing/packet/event/stats/app/index.ts +56 -0
- package/src/photon/balancing/packet/event/stats/index.ts +2 -0
- package/src/photon/balancing/packet/event/stats/lobby/index.ts +30 -0
- package/src/photon/balancing/packet/event/update/index.ts +30 -0
- package/src/photon/balancing/packet/friends/index.ts +2 -0
- package/src/photon/balancing/packet/friends/request/index.ts +40 -0
- package/src/photon/balancing/packet/friends/response/index.ts +60 -0
- package/src/photon/balancing/packet/game/create/index.ts +2 -0
- package/src/photon/balancing/packet/game/create/request/index.ts +160 -0
- package/src/photon/balancing/packet/game/create/response/index.ts +122 -0
- package/src/photon/balancing/packet/game/debug/index.ts +2 -0
- package/src/photon/balancing/packet/game/debug/request/index.ts +40 -0
- package/src/photon/balancing/packet/game/debug/response/index.ts +70 -0
- package/src/photon/balancing/packet/game/index.ts +8 -0
- package/src/photon/balancing/packet/game/join/index.ts +2 -0
- package/src/photon/balancing/packet/game/join/request/index.ts +218 -0
- package/src/photon/balancing/packet/game/join/response/index.ts +122 -0
- package/src/photon/balancing/packet/game/list/index.ts +2 -0
- package/src/photon/balancing/packet/game/list/request/index.ts +41 -0
- package/src/photon/balancing/packet/game/list/response/index.ts +49 -0
- package/src/photon/balancing/packet/game/random/index.ts +2 -0
- package/src/photon/balancing/packet/game/random/request/index.ts +172 -0
- package/src/photon/balancing/packet/game/random/response/index.ts +95 -0
- package/src/photon/balancing/packet/groups/index.ts +2 -0
- package/src/photon/balancing/packet/groups/request/index.ts +40 -0
- package/src/photon/balancing/packet/groups/response/index.ts +35 -0
- package/src/photon/balancing/packet/index.ts +69 -0
- package/src/photon/balancing/packet/leave/index.ts +2 -0
- package/src/photon/balancing/packet/leave/request/index.ts +40 -0
- package/src/photon/balancing/packet/leave/response/index.ts +35 -0
- package/src/photon/balancing/packet/lobby/index.ts +3 -0
- package/src/photon/balancing/packet/lobby/join/index.ts +2 -0
- package/src/photon/balancing/packet/lobby/join/request/index.ts +55 -0
- package/src/photon/balancing/packet/lobby/join/response/index.ts +35 -0
- package/src/photon/balancing/packet/lobby/leave/index.ts +2 -0
- package/src/photon/balancing/packet/lobby/leave/request/index.ts +21 -0
- package/src/photon/balancing/packet/lobby/leave/response/index.ts +43 -0
- package/src/photon/balancing/packet/lobby/stats/index.ts +2 -0
- package/src/photon/balancing/packet/lobby/stats/request/index.ts +43 -0
- package/src/photon/balancing/packet/lobby/stats/response/index.ts +49 -0
- package/src/photon/balancing/packet/once/index.ts +2 -0
- package/src/photon/balancing/packet/once/request/index.ts +70 -0
- package/src/photon/balancing/packet/once/response/index.ts +49 -0
- package/src/photon/balancing/packet/ping/index.ts +2 -0
- package/src/photon/balancing/packet/ping/request/index.ts +21 -0
- package/src/photon/balancing/packet/ping/response/index.ts +35 -0
- package/src/photon/balancing/packet/properties/get/index.ts +2 -0
- package/src/photon/balancing/packet/properties/get/request/index.ts +69 -0
- package/src/photon/balancing/packet/properties/get/response/index.ts +66 -0
- package/src/photon/balancing/packet/properties/index.ts +2 -0
- package/src/photon/balancing/packet/properties/set/index.ts +2 -0
- package/src/photon/balancing/packet/properties/set/request/index.ts +122 -0
- package/src/photon/balancing/packet/properties/set/response/index.ts +35 -0
- package/src/photon/balancing/packet/raise/index.ts +2 -0
- package/src/photon/balancing/packet/raise/request/index.ts +219 -0
- package/src/photon/balancing/packet/raise/response/index.ts +35 -0
- package/src/photon/balancing/packet/regions/index.ts +2 -0
- package/src/photon/balancing/packet/regions/request/index.ts +29 -0
- package/src/photon/balancing/packet/regions/response/index.ts +60 -0
- package/src/photon/balancing/packet/reply/index.ts +59 -0
- package/src/photon/balancing/packet/rpc/index.ts +2 -0
- package/src/photon/balancing/packet/rpc/request/index.ts +54 -0
- package/src/photon/balancing/packet/rpc/response/index.ts +88 -0
- package/src/photon/balancing/packet/settings/index.ts +2 -0
- package/src/photon/balancing/packet/settings/request/index.ts +29 -0
- package/src/photon/balancing/packet/settings/response/index.ts +35 -0
- package/src/photon/balancing/packet/unknown/index.ts +71 -0
- package/src/photon/balancing/pun/code/index.ts +376 -0
- package/src/photon/balancing/pun/destroy/index.ts +2 -0
- package/src/photon/balancing/pun/destroy/object/index.ts +48 -0
- package/src/photon/balancing/pun/destroy/player/index.ts +53 -0
- package/src/photon/balancing/pun/events/index.ts +283 -0
- package/src/photon/balancing/pun/filter/index.ts +45 -0
- package/src/photon/balancing/pun/index.ts +34 -0
- package/src/photon/balancing/pun/instantiation/index.ts +213 -0
- package/src/photon/balancing/pun/keys/index.ts +78 -0
- package/src/photon/balancing/pun/master/index.ts +48 -0
- package/src/photon/balancing/pun/ownership/index.ts +4 -0
- package/src/photon/balancing/pun/ownership/request/index.ts +55 -0
- package/src/photon/balancing/pun/ownership/transfer/index.ts +55 -0
- package/src/photon/balancing/pun/ownership/update/index.ts +57 -0
- package/src/photon/balancing/pun/rpc/index.ts +180 -0
- package/src/photon/balancing/pun/serialize/batch/index.ts +143 -0
- package/src/photon/balancing/pun/serialize/index.ts +2 -0
- package/src/photon/balancing/pun/serialize/view/index.ts +96 -0
- package/src/photon/balancing/pun/view/index.ts +41 -0
- package/src/photon/balancing/role/index.ts +24 -0
- package/src/photon/balancing/travel/index.ts +103 -0
- package/src/photon/binary/adapter/index.ts +619 -0
- package/src/photon/binary/custom/index.ts +148 -0
- package/src/photon/binary/dictionary/index.ts +110 -0
- package/src/photon/binary/disconnect/index.ts +51 -0
- package/src/photon/binary/event/index.ts +48 -0
- package/src/photon/binary/factory/index.ts +23 -0
- package/src/photon/binary/hashtable/index.ts +83 -0
- package/src/photon/binary/index.ts +25 -0
- package/src/photon/binary/kind/index.ts +104 -0
- package/src/photon/binary/parameters/index.ts +119 -0
- package/src/photon/binary/protocol/index.ts +122 -0
- package/src/photon/binary/request/index.ts +38 -0
- package/src/photon/binary/response/index.ts +92 -0
- package/src/photon/binary/shape/index.ts +260 -0
- package/src/photon/binary/v16/index.ts +834 -0
- package/src/photon/binary/v18/index.ts +1428 -0
- package/src/photon/binary/value/index.ts +414 -0
- package/src/photon/client/bot/index.ts +662 -0
- package/src/photon/client/connection/index.ts +420 -0
- package/src/photon/client/endpoint/index.ts +87 -0
- package/src/photon/client/failure/index.ts +37 -0
- package/src/photon/client/index.ts +5 -0
- package/src/photon/client/options/index.ts +78 -0
- package/src/photon/cluster/back/index.ts +186 -0
- package/src/photon/cluster/carriage/index.ts +334 -0
- package/src/photon/cluster/directory/index.ts +103 -0
- package/src/photon/cluster/dresser/index.ts +83 -0
- package/src/photon/cluster/feed/index.ts +267 -0
- package/src/photon/cluster/front/index.ts +205 -0
- package/src/photon/cluster/grid/index.ts +429 -0
- package/src/photon/cluster/hub/index.ts +434 -0
- package/src/photon/cluster/index.ts +18 -0
- package/src/photon/cluster/mover/index.ts +173 -0
- package/src/photon/cluster/parcel/index.ts +158 -0
- package/src/photon/cluster/pooled/index.ts +66 -0
- package/src/photon/cluster/press/index.ts +96 -0
- package/src/photon/cluster/route/game/index.ts +95 -0
- package/src/photon/cluster/route/index.ts +3 -0
- package/src/photon/cluster/route/master/index.ts +235 -0
- package/src/photon/cluster/route/name/index.ts +176 -0
- package/src/photon/cluster/seat/game/index.ts +113 -0
- package/src/photon/cluster/seat/index.ts +2 -0
- package/src/photon/cluster/seat/master/index.ts +97 -0
- package/src/photon/cluster/seed/index.ts +190 -0
- package/src/photon/cluster/sessions/index.ts +136 -0
- package/src/photon/cluster/spread/index.ts +236 -0
- package/src/photon/cluster/value/index.ts +46 -0
- package/src/photon/crypto/code/index.ts +149 -0
- package/src/photon/crypto/connection/index.ts +127 -0
- package/src/photon/crypto/data/index.ts +214 -0
- package/src/photon/crypto/datagram/index.ts +119 -0
- package/src/photon/crypto/error/index.ts +29 -0
- package/src/photon/crypto/exchange/index.ts +187 -0
- package/src/photon/crypto/index.ts +31 -0
- package/src/photon/crypto/init/binary/index.ts +249 -0
- package/src/photon/crypto/init/http/index.ts +222 -0
- package/src/photon/crypto/init/index.ts +6 -0
- package/src/photon/crypto/init/query/index.ts +85 -0
- package/src/photon/crypto/init/socket/index.ts +82 -0
- package/src/photon/crypto/method/index.ts +20 -0
- package/src/photon/crypto/mode/index.ts +35 -0
- package/src/photon/crypto/once/gate/index.ts +60 -0
- package/src/photon/crypto/once/index.ts +4 -0
- package/src/photon/crypto/once/reply/index.ts +96 -0
- package/src/photon/crypto/once/request/index.ts +14 -0
- package/src/photon/crypto/payload/index.ts +189 -0
- package/src/photon/crypto/protocol/index.ts +30 -0
- package/src/photon/crypto/refusal/index.ts +118 -0
- package/src/photon/crypto/sequence/index.ts +97 -0
- package/src/photon/crypto/token/authority/index.ts +158 -0
- package/src/photon/crypto/token/codec/index.ts +18 -0
- package/src/photon/crypto/token/index.ts +5 -0
- package/src/photon/crypto/token/record/index.ts +116 -0
- package/src/photon/crypto/token/sealed/index.ts +285 -0
- package/src/photon/crypto/token/verdict/index.ts +43 -0
- package/src/photon/enet/client/index.ts +204 -0
- package/src/photon/enet/closure/index.ts +90 -0
- package/src/photon/enet/command/index.ts +301 -0
- package/src/photon/enet/datagram/index.ts +289 -0
- package/src/photon/enet/flight/index.ts +93 -0
- package/src/photon/enet/gateway/index.ts +311 -0
- package/src/photon/enet/handler/index.ts +65 -0
- package/src/photon/enet/index.ts +21 -0
- package/src/photon/enet/lane/index.ts +403 -0
- package/src/photon/enet/link/index.ts +200 -0
- package/src/photon/enet/options/index.ts +283 -0
- package/src/photon/enet/peer/index.ts +1527 -0
- package/src/photon/enet/server/index.ts +107 -0
- package/src/photon/enet/transport/index.ts +83 -0
- package/src/photon/enet/window/index.ts +48 -0
- package/src/photon/envelope/index.ts +83 -0
- package/src/photon/family/index.ts +41 -0
- package/src/photon/frame/index.ts +88 -0
- package/src/photon/game/actor/index.ts +117 -0
- package/src/photon/game/authenticator/index.ts +139 -0
- package/src/photon/game/bag/index.ts +169 -0
- package/src/photon/game/cache/index.ts +456 -0
- package/src/photon/game/clock/index.ts +137 -0
- package/src/photon/game/compare/index.ts +162 -0
- package/src/photon/game/entry/index.ts +334 -0
- package/src/photon/game/fault/index.ts +77 -0
- package/src/photon/game/gate/index.ts +177 -0
- package/src/photon/game/groups/index.ts +115 -0
- package/src/photon/game/guard/index.ts +54 -0
- package/src/photon/game/handler/index.ts +458 -0
- package/src/photon/game/hooked/index.ts +873 -0
- package/src/photon/game/index.ts +41 -0
- package/src/photon/game/peer/index.ts +186 -0
- package/src/photon/game/report/index.ts +120 -0
- package/src/photon/game/room/index.ts +2271 -0
- package/src/photon/game/rooms/index.ts +149 -0
- package/src/photon/game/server/index.ts +503 -0
- package/src/photon/game/settings/index.ts +341 -0
- package/src/photon/game/shared/index.ts +54 -0
- package/src/photon/game/snapshot/index.ts +124 -0
- package/src/photon/game/stage/index.ts +74 -0
- package/src/photon/game/touch/index.ts +43 -0
- package/src/photon/game/wellknown/index.ts +353 -0
- package/src/photon/hooks/index.ts +9 -0
- package/src/photon/hooks/reason/index.ts +129 -0
- package/src/photon/hooks/reply/index.ts +239 -0
- package/src/photon/hooks/request/index.ts +383 -0
- package/src/photon/hooks/sender/index.ts +268 -0
- package/src/photon/hooks/settings/index.ts +383 -0
- package/src/photon/hooks/state/index.ts +545 -0
- package/src/photon/index.ts +31 -0
- package/src/photon/master/application/index.ts +446 -0
- package/src/photon/master/balancer/index.ts +170 -0
- package/src/photon/master/context/index.ts +127 -0
- package/src/photon/master/equality/index.ts +104 -0
- package/src/photon/master/fault/index.ts +86 -0
- package/src/photon/master/game/index.ts +847 -0
- package/src/photon/master/gate/index.ts +243 -0
- package/src/photon/master/handler/index.ts +1103 -0
- package/src/photon/master/index.ts +20 -0
- package/src/photon/master/list/channel/index.ts +417 -0
- package/src/photon/master/list/games/index.ts +419 -0
- package/src/photon/master/list/index.ts +6 -0
- package/src/photon/master/list/limited/index.ts +103 -0
- package/src/photon/master/list/plain/index.ts +47 -0
- package/src/photon/master/list/silent/index.ts +45 -0
- package/src/photon/master/list/sql/index.ts +280 -0
- package/src/photon/master/lobbies/index.ts +85 -0
- package/src/photon/master/lobby/index.ts +572 -0
- package/src/photon/master/peer/index.ts +168 -0
- package/src/photon/master/players/index.ts +177 -0
- package/src/photon/master/redirect/index.ts +90 -0
- package/src/photon/master/rpc/index.ts +2 -0
- package/src/photon/master/server/index.ts +212 -0
- package/src/photon/master/settings/index.ts +515 -0
- package/src/photon/master/sql/error/index.ts +92 -0
- package/src/photon/master/sql/host/index.ts +153 -0
- package/src/photon/master/sql/index.ts +9 -0
- package/src/photon/master/sql/relay/index.ts +141 -0
- package/src/photon/master/sql/remote/index.ts +257 -0
- package/src/photon/master/sql/store/index.ts +37 -0
- package/src/photon/master/sql/table/index.ts +219 -0
- package/src/photon/master/sql/value/index.ts +93 -0
- package/src/photon/master/sql/watch/index.ts +80 -0
- package/src/photon/master/sql/wire/index.ts +98 -0
- package/src/photon/master/stats/app/index.ts +122 -0
- package/src/photon/master/stats/index.ts +2 -0
- package/src/photon/master/stats/lobby/index.ts +180 -0
- package/src/photon/master/wellknown/index.ts +220 -0
- package/src/photon/message/binary/index.ts +289 -0
- package/src/photon/message/client/index.ts +110 -0
- package/src/photon/message/dialect/index.ts +61 -0
- package/src/photon/message/format/index.ts +21 -0
- package/src/photon/message/handler/index.ts +176 -0
- package/src/photon/message/index.ts +23 -0
- package/src/photon/message/init/classic/index.ts +204 -0
- package/src/photon/message/init/form/index.ts +29 -0
- package/src/photon/message/init/index.ts +6 -0
- package/src/photon/message/init/request/index.ts +388 -0
- package/src/photon/message/internal/index.ts +203 -0
- package/src/photon/message/json/format/index.ts +129 -0
- package/src/photon/message/json/index.ts +3 -0
- package/src/photon/message/json/keys/index.ts +44 -0
- package/src/photon/message/json/values/index.ts +323 -0
- package/src/photon/message/once/index.ts +69 -0
- package/src/photon/message/peer/index.ts +276 -0
- package/src/photon/message/pipeline/index.ts +350 -0
- package/src/photon/message/server/index.ts +208 -0
- package/src/photon/message/type/index.ts +59 -0
- package/src/photon/message/watch/index.ts +30 -0
- package/src/photon/message/wire/index.ts +215 -0
- package/src/photon/name/config/index.ts +133 -0
- package/src/photon/name/handler/index.ts +816 -0
- package/src/photon/name/index.ts +12 -0
- package/src/photon/name/node/index.ts +181 -0
- package/src/photon/name/peer/index.ts +23 -0
- package/src/photon/name/regions/index.ts +110 -0
- package/src/photon/name/server/index.ts +207 -0
- package/src/photon/registry/index.ts +244 -0
- package/src/photon/rpc/fault/index.ts +60 -0
- package/src/photon/rpc/http/index.ts +508 -0
- package/src/photon/rpc/index.ts +10 -0
- package/src/photon/rpc/meter/index.ts +47 -0
- package/src/photon/rpc/relay/index.ts +112 -0
- package/src/photon/rpc/service/index.ts +67 -0
- package/src/photon/seal/index.ts +17 -0
- package/src/photon/server/config/index.ts +241 -0
- package/src/photon/server/gatekeeper/index.ts +99 -0
- package/src/photon/server/host/index.ts +581 -0
- package/src/photon/server/index.ts +5 -0
- package/src/photon/server/listeners/index.ts +250 -0
- package/src/photon/server/ports/index.ts +156 -0
- package/src/photon/tcp/client/index.ts +64 -0
- package/src/photon/tcp/clock/index.ts +12 -0
- package/src/photon/tcp/codec/index.ts +174 -0
- package/src/photon/tcp/framing/index.ts +131 -0
- package/src/photon/tcp/index.ts +8 -0
- package/src/photon/tcp/ping/index.ts +43 -0
- package/src/photon/tcp/pong/index.ts +53 -0
- package/src/photon/tcp/server/index.ts +81 -0
- package/src/photon/timers/index.ts +68 -0
- package/src/photon/websocket/binary/index.ts +71 -0
- package/src/photon/websocket/bridge/index.ts +301 -0
- package/src/photon/websocket/framing/index.ts +45 -0
- package/src/photon/websocket/index.ts +14 -0
- package/src/photon/websocket/json/index.ts +49 -0
- package/src/photon/websocket/message/index.ts +176 -0
- package/src/photon/websocket/negotiation/index.ts +99 -0
- package/src/photon/websocket/path/index.ts +52 -0
- package/src/photon/websocket/plain/index.ts +25 -0
- package/src/photon/websocket/query/index.ts +99 -0
- package/src/photon/websocket/reassembly/index.ts +75 -0
- package/src/photon/websocket/subprotocol/index.ts +24 -0
- package/src/photon/websocket/text/index.ts +80 -0
- package/src/protocol/index.ts +61 -0
- package/src/scale/batch/index.ts +210 -0
- package/src/scale/courier/index.ts +726 -0
- package/src/scale/datagram/index.ts +337 -0
- package/src/scale/fanout/index.ts +654 -0
- package/src/scale/handoff/index.ts +271 -0
- package/src/scale/hosted/index.ts +68 -0
- package/src/scale/index.ts +41 -0
- package/src/scale/layout/index.ts +29 -0
- package/src/scale/mesh/index.ts +211 -0
- package/src/scale/outlet/index.ts +121 -0
- package/src/scale/pending/index.ts +165 -0
- package/src/scale/placement/index.ts +89 -0
- package/src/scale/portable/index.ts +42 -0
- package/src/scale/relay/index.ts +136 -0
- package/src/scale/sink/index.ts +51 -0
- package/src/scale/switchboard/index.ts +91 -0
- package/src/scale/transport/index.ts +112 -0
- package/src/scale/tunnel/index.ts +743 -0
- package/src/smartfox/index.ts +2 -0
- package/src/smartfox/pro/bans/index.ts +3 -0
- package/src/smartfox/pro/bans/list/index.ts +101 -0
- package/src/smartfox/pro/bans/memory/index.ts +57 -0
- package/src/smartfox/pro/bans/store/index.ts +43 -0
- package/src/smartfox/pro/bluebox/gateway/index.ts +310 -0
- package/src/smartfox/pro/bluebox/index.ts +4 -0
- package/src/smartfox/pro/bluebox/session/index.ts +63 -0
- package/src/smartfox/pro/bluebox/transport/index.ts +104 -0
- package/src/smartfox/pro/buddies/index.ts +4 -0
- package/src/smartfox/pro/buddies/memory/index.ts +38 -0
- package/src/smartfox/pro/buddies/roster/index.ts +411 -0
- package/src/smartfox/pro/buddies/store/index.ts +37 -0
- package/src/smartfox/pro/buddy/index.ts +65 -0
- package/src/smartfox/pro/catalogue/index.ts +141 -0
- package/src/smartfox/pro/claims/index.ts +110 -0
- package/src/smartfox/pro/codec/index.ts +87 -0
- package/src/smartfox/pro/counters/index.ts +3 -0
- package/src/smartfox/pro/counters/memory/index.ts +90 -0
- package/src/smartfox/pro/counters/offender/index.ts +47 -0
- package/src/smartfox/pro/counters/store/index.ts +17 -0
- package/src/smartfox/pro/entity/index.ts +111 -0
- package/src/smartfox/pro/escalation/index.ts +194 -0
- package/src/smartfox/pro/filter/index.ts +226 -0
- package/src/smartfox/pro/flood/index.ts +190 -0
- package/src/smartfox/pro/format/buddy/add/index.ts +2 -0
- package/src/smartfox/pro/format/buddy/add/notice/index.ts +44 -0
- package/src/smartfox/pro/format/buddy/add/request/index.ts +37 -0
- package/src/smartfox/pro/format/buddy/block/index.ts +44 -0
- package/src/smartfox/pro/format/buddy/clear/index.ts +37 -0
- package/src/smartfox/pro/format/buddy/index.ts +13 -0
- package/src/smartfox/pro/format/buddy/list/index.ts +59 -0
- package/src/smartfox/pro/format/buddy/load/index.ts +37 -0
- package/src/smartfox/pro/format/buddy/permission/index.ts +2 -0
- package/src/smartfox/pro/format/buddy/permission/notice/index.ts +43 -0
- package/src/smartfox/pro/format/buddy/permission/request/index.ts +48 -0
- package/src/smartfox/pro/format/buddy/remove/index.ts +2 -0
- package/src/smartfox/pro/format/buddy/remove/notice/index.ts +37 -0
- package/src/smartfox/pro/format/buddy/remove/request/index.ts +37 -0
- package/src/smartfox/pro/format/buddy/room/index.ts +2 -0
- package/src/smartfox/pro/format/buddy/room/reply/index.ts +50 -0
- package/src/smartfox/pro/format/buddy/room/request/index.ts +37 -0
- package/src/smartfox/pro/format/buddy/update/index.ts +54 -0
- package/src/smartfox/pro/format/buddy/variables/index.ts +48 -0
- package/src/smartfox/pro/format/chat/admin/index.ts +48 -0
- package/src/smartfox/pro/format/chat/index.ts +13 -0
- package/src/smartfox/pro/format/chat/moderator/index.ts +2 -0
- package/src/smartfox/pro/format/chat/moderator/message/index.ts +48 -0
- package/src/smartfox/pro/format/chat/moderator/request/index.ts +52 -0
- package/src/smartfox/pro/format/chat/private/index.ts +2 -0
- package/src/smartfox/pro/format/chat/private/message/index.ts +48 -0
- package/src/smartfox/pro/format/chat/private/request/index.ts +49 -0
- package/src/smartfox/pro/format/chat/public/index.ts +2 -0
- package/src/smartfox/pro/format/chat/public/message/index.ts +48 -0
- package/src/smartfox/pro/format/chat/public/request/index.ts +40 -0
- package/src/smartfox/pro/format/create/added/index.ts +76 -0
- package/src/smartfox/pro/format/create/deleted/index.ts +37 -0
- package/src/smartfox/pro/format/create/index.ts +4 -0
- package/src/smartfox/pro/format/create/refused/index.ts +37 -0
- package/src/smartfox/pro/format/create/request/index.ts +95 -0
- package/src/smartfox/pro/format/data/group/index.ts +62 -0
- package/src/smartfox/pro/format/data/index.ts +3 -0
- package/src/smartfox/pro/format/data/message/index.ts +54 -0
- package/src/smartfox/pro/format/data/request/index.ts +46 -0
- package/src/smartfox/pro/format/entry/buddy/index.ts +62 -0
- package/src/smartfox/pro/format/entry/index.ts +5 -0
- package/src/smartfox/pro/format/entry/object/index.ts +171 -0
- package/src/smartfox/pro/format/entry/room/index.ts +70 -0
- package/src/smartfox/pro/format/entry/user/index.ts +60 -0
- package/src/smartfox/pro/format/entry/variables/index.ts +148 -0
- package/src/smartfox/pro/format/extension/index.ts +3 -0
- package/src/smartfox/pro/format/extension/json/index.ts +99 -0
- package/src/smartfox/pro/format/extension/object/index.ts +95 -0
- package/src/smartfox/pro/format/extension/raw/index.ts +139 -0
- package/src/smartfox/pro/format/index.ts +86 -0
- package/src/smartfox/pro/format/join/accepted/index.ts +72 -0
- package/src/smartfox/pro/format/join/index.ts +3 -0
- package/src/smartfox/pro/format/join/refused/index.ts +37 -0
- package/src/smartfox/pro/format/join/request/index.ts +54 -0
- package/src/smartfox/pro/format/key/index.ts +2 -0
- package/src/smartfox/pro/format/key/reply/index.ts +37 -0
- package/src/smartfox/pro/format/key/request/index.ts +37 -0
- package/src/smartfox/pro/format/leave/index.ts +2 -0
- package/src/smartfox/pro/format/leave/notice/index.ts +41 -0
- package/src/smartfox/pro/format/leave/request/index.ts +41 -0
- package/src/smartfox/pro/format/login/accepted/index.ts +49 -0
- package/src/smartfox/pro/format/login/index.ts +3 -0
- package/src/smartfox/pro/format/login/refused/index.ts +37 -0
- package/src/smartfox/pro/format/login/request/index.ts +53 -0
- package/src/smartfox/pro/format/logout/index.ts +2 -0
- package/src/smartfox/pro/format/logout/notice/index.ts +37 -0
- package/src/smartfox/pro/format/logout/request/index.ts +37 -0
- package/src/smartfox/pro/format/ping/index.ts +2 -0
- package/src/smartfox/pro/format/ping/reply/index.ts +37 -0
- package/src/smartfox/pro/format/ping/request/index.ts +37 -0
- package/src/smartfox/pro/format/presence/count/index.ts +44 -0
- package/src/smartfox/pro/format/presence/entered/index.ts +47 -0
- package/src/smartfox/pro/format/presence/index.ts +3 -0
- package/src/smartfox/pro/format/presence/left/index.ts +44 -0
- package/src/smartfox/pro/format/rooms/auto/index.ts +37 -0
- package/src/smartfox/pro/format/rooms/index.ts +3 -0
- package/src/smartfox/pro/format/rooms/list/index.ts +54 -0
- package/src/smartfox/pro/format/rooms/request/index.ts +37 -0
- package/src/smartfox/pro/format/seat/index.ts +8 -0
- package/src/smartfox/pro/format/seat/player/index.ts +2 -0
- package/src/smartfox/pro/format/seat/player/notice/index.ts +49 -0
- package/src/smartfox/pro/format/seat/player/request/index.ts +37 -0
- package/src/smartfox/pro/format/seat/spectator/index.ts +2 -0
- package/src/smartfox/pro/format/seat/spectator/notice/index.ts +49 -0
- package/src/smartfox/pro/format/seat/spectator/request/index.ts +38 -0
- package/src/smartfox/pro/format/system/index.ts +19 -0
- package/src/smartfox/pro/format/variables/index.ts +8 -0
- package/src/smartfox/pro/format/variables/room/index.ts +2 -0
- package/src/smartfox/pro/format/variables/room/request/index.ts +50 -0
- package/src/smartfox/pro/format/variables/room/update/index.ts +52 -0
- package/src/smartfox/pro/format/variables/user/index.ts +2 -0
- package/src/smartfox/pro/format/variables/user/request/index.ts +47 -0
- package/src/smartfox/pro/format/variables/user/update/index.ts +52 -0
- package/src/smartfox/pro/format/version/accepted/index.ts +37 -0
- package/src/smartfox/pro/format/version/index.ts +3 -0
- package/src/smartfox/pro/format/version/refused/index.ts +37 -0
- package/src/smartfox/pro/format/version/request/index.ts +37 -0
- package/src/smartfox/pro/handler/buddy/index.ts +138 -0
- package/src/smartfox/pro/handler/chat/index.ts +221 -0
- package/src/smartfox/pro/handler/index.ts +7 -0
- package/src/smartfox/pro/handler/login/index.ts +175 -0
- package/src/smartfox/pro/handler/room/index.ts +121 -0
- package/src/smartfox/pro/handler/seat/index.ts +75 -0
- package/src/smartfox/pro/handler/shared/index.ts +29 -0
- package/src/smartfox/pro/handler/variable/index.ts +77 -0
- package/src/smartfox/pro/index.ts +60 -0
- package/src/smartfox/pro/login/attempt/index.ts +83 -0
- package/src/smartfox/pro/login/authenticator/index.ts +9 -0
- package/src/smartfox/pro/login/index.ts +3 -0
- package/src/smartfox/pro/login/verdict/index.ts +48 -0
- package/src/smartfox/pro/messages/index.ts +136 -0
- package/src/smartfox/pro/object/index.ts +12 -0
- package/src/smartfox/pro/options/index.ts +189 -0
- package/src/smartfox/pro/packet/buddy/add/index.ts +2 -0
- package/src/smartfox/pro/packet/buddy/add/notice/index.ts +27 -0
- package/src/smartfox/pro/packet/buddy/add/request/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/block/index.ts +33 -0
- package/src/smartfox/pro/packet/buddy/clear/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/index.ts +10 -0
- package/src/smartfox/pro/packet/buddy/list/index.ts +41 -0
- package/src/smartfox/pro/packet/buddy/load/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/permission/index.ts +2 -0
- package/src/smartfox/pro/packet/buddy/permission/notice/index.ts +33 -0
- package/src/smartfox/pro/packet/buddy/permission/request/index.ts +33 -0
- package/src/smartfox/pro/packet/buddy/remove/index.ts +2 -0
- package/src/smartfox/pro/packet/buddy/remove/notice/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/remove/request/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/room/index.ts +2 -0
- package/src/smartfox/pro/packet/buddy/room/reply/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/room/request/index.ts +25 -0
- package/src/smartfox/pro/packet/buddy/update/index.ts +35 -0
- package/src/smartfox/pro/packet/buddy/variables/index.ts +27 -0
- package/src/smartfox/pro/packet/chat/admin/index.ts +41 -0
- package/src/smartfox/pro/packet/chat/index.ts +5 -0
- package/src/smartfox/pro/packet/chat/moderator/index.ts +3 -0
- package/src/smartfox/pro/packet/chat/moderator/message/index.ts +41 -0
- package/src/smartfox/pro/packet/chat/moderator/request/index.ts +64 -0
- package/src/smartfox/pro/packet/chat/private/index.ts +2 -0
- package/src/smartfox/pro/packet/chat/private/message/index.ts +41 -0
- package/src/smartfox/pro/packet/chat/private/request/index.ts +45 -0
- package/src/smartfox/pro/packet/chat/public/index.ts +2 -0
- package/src/smartfox/pro/packet/chat/public/message/index.ts +41 -0
- package/src/smartfox/pro/packet/chat/public/request/index.ts +33 -0
- package/src/smartfox/pro/packet/create/added/index.ts +27 -0
- package/src/smartfox/pro/packet/create/deleted/index.ts +25 -0
- package/src/smartfox/pro/packet/create/index.ts +5 -0
- package/src/smartfox/pro/packet/create/refused/index.ts +25 -0
- package/src/smartfox/pro/packet/create/request/index.ts +105 -0
- package/src/smartfox/pro/packet/data/group/index.ts +51 -0
- package/src/smartfox/pro/packet/data/index.ts +3 -0
- package/src/smartfox/pro/packet/data/message/index.ts +43 -0
- package/src/smartfox/pro/packet/data/request/index.ts +35 -0
- package/src/smartfox/pro/packet/extension/index.ts +3 -0
- package/src/smartfox/pro/packet/extension/json/index.ts +2 -0
- package/src/smartfox/pro/packet/extension/json/reply/index.ts +33 -0
- package/src/smartfox/pro/packet/extension/json/request/index.ts +66 -0
- package/src/smartfox/pro/packet/extension/object/index.ts +2 -0
- package/src/smartfox/pro/packet/extension/object/reply/index.ts +35 -0
- package/src/smartfox/pro/packet/extension/object/request/index.ts +68 -0
- package/src/smartfox/pro/packet/extension/raw/index.ts +2 -0
- package/src/smartfox/pro/packet/extension/raw/reply/index.ts +25 -0
- package/src/smartfox/pro/packet/extension/raw/request/index.ts +66 -0
- package/src/smartfox/pro/packet/frame/index.ts +2 -0
- package/src/smartfox/pro/packet/frame/policy/file/index.ts +25 -0
- package/src/smartfox/pro/packet/frame/policy/index.ts +2 -0
- package/src/smartfox/pro/packet/frame/policy/request/index.ts +25 -0
- package/src/smartfox/pro/packet/frame/unknown/index.ts +25 -0
- package/src/smartfox/pro/packet/index.ts +72 -0
- package/src/smartfox/pro/packet/join/accepted/index.ts +74 -0
- package/src/smartfox/pro/packet/join/index.ts +3 -0
- package/src/smartfox/pro/packet/join/refused/index.ts +25 -0
- package/src/smartfox/pro/packet/join/request/index.ts +79 -0
- package/src/smartfox/pro/packet/key/index.ts +2 -0
- package/src/smartfox/pro/packet/key/reply/index.ts +25 -0
- package/src/smartfox/pro/packet/key/request/index.ts +25 -0
- package/src/smartfox/pro/packet/leave/index.ts +2 -0
- package/src/smartfox/pro/packet/leave/notice/index.ts +25 -0
- package/src/smartfox/pro/packet/leave/request/index.ts +25 -0
- package/src/smartfox/pro/packet/login/accepted/index.ts +45 -0
- package/src/smartfox/pro/packet/login/index.ts +3 -0
- package/src/smartfox/pro/packet/login/refused/index.ts +25 -0
- package/src/smartfox/pro/packet/login/request/index.ts +41 -0
- package/src/smartfox/pro/packet/logout/index.ts +2 -0
- package/src/smartfox/pro/packet/logout/notice/index.ts +25 -0
- package/src/smartfox/pro/packet/logout/request/index.ts +25 -0
- package/src/smartfox/pro/packet/ping/index.ts +2 -0
- package/src/smartfox/pro/packet/ping/reply/index.ts +25 -0
- package/src/smartfox/pro/packet/ping/request/index.ts +25 -0
- package/src/smartfox/pro/packet/presence/count/index.ts +41 -0
- package/src/smartfox/pro/packet/presence/entered/index.ts +35 -0
- package/src/smartfox/pro/packet/presence/index.ts +3 -0
- package/src/smartfox/pro/packet/presence/left/index.ts +33 -0
- package/src/smartfox/pro/packet/rooms/auto/index.ts +25 -0
- package/src/smartfox/pro/packet/rooms/index.ts +3 -0
- package/src/smartfox/pro/packet/rooms/list/index.ts +27 -0
- package/src/smartfox/pro/packet/rooms/request/index.ts +25 -0
- package/src/smartfox/pro/packet/seat/index.ts +2 -0
- package/src/smartfox/pro/packet/seat/player/index.ts +2 -0
- package/src/smartfox/pro/packet/seat/player/notice/index.ts +45 -0
- package/src/smartfox/pro/packet/seat/player/request/index.ts +25 -0
- package/src/smartfox/pro/packet/seat/spectator/index.ts +2 -0
- package/src/smartfox/pro/packet/seat/spectator/notice/index.ts +45 -0
- package/src/smartfox/pro/packet/seat/spectator/request/index.ts +25 -0
- package/src/smartfox/pro/packet/variables/index.ts +2 -0
- package/src/smartfox/pro/packet/variables/room/index.ts +2 -0
- package/src/smartfox/pro/packet/variables/room/request/index.ts +51 -0
- package/src/smartfox/pro/packet/variables/room/update/index.ts +47 -0
- package/src/smartfox/pro/packet/variables/user/index.ts +2 -0
- package/src/smartfox/pro/packet/variables/user/request/index.ts +35 -0
- package/src/smartfox/pro/packet/variables/user/update/index.ts +47 -0
- package/src/smartfox/pro/packet/version/accepted/index.ts +25 -0
- package/src/smartfox/pro/packet/version/index.ts +3 -0
- package/src/smartfox/pro/packet/version/refused/index.ts +25 -0
- package/src/smartfox/pro/packet/version/request/index.ts +25 -0
- package/src/smartfox/pro/penalty/index.ts +65 -0
- package/src/smartfox/pro/protocol/index.ts +395 -0
- package/src/smartfox/pro/room/index.ts +155 -0
- package/src/smartfox/pro/route/index.ts +25 -0
- package/src/smartfox/pro/sequence/index.ts +35 -0
- package/src/smartfox/pro/user/index.ts +80 -0
- package/src/smartfox/pro/variable/index.ts +34 -0
- package/src/smartfox/pro/web/index.ts +155 -0
- package/src/smartfox/pro/xml/index.ts +2 -0
- package/src/smartfox/pro/xml/reader/index.ts +228 -0
- package/src/smartfox/pro/xml/templates/index.ts +169 -0
- package/src/smartfox/pro/xml/writer/index.ts +147 -0
- package/src/smartfox/pro/zone/index.ts +874 -0
- package/src/smartfox/pro/zones/index.ts +324 -0
- package/src/smartfox/x2/balancer/index.ts +193 -0
- package/src/smartfox/x2/ban/index.ts +4 -0
- package/src/smartfox/x2/ban/list/index.ts +136 -0
- package/src/smartfox/x2/ban/memory/index.ts +71 -0
- package/src/smartfox/x2/ban/record/index.ts +36 -0
- package/src/smartfox/x2/ban/store/index.ts +28 -0
- package/src/smartfox/x2/bluebox/gateway/index.ts +315 -0
- package/src/smartfox/x2/bluebox/index.ts +4 -0
- package/src/smartfox/x2/bluebox/session/index.ts +63 -0
- package/src/smartfox/x2/bluebox/transport/index.ts +125 -0
- package/src/smartfox/x2/buddies/index.ts +608 -0
- package/src/smartfox/x2/catalogue/index.ts +23 -0
- package/src/smartfox/x2/catalogue/requests/index.ts +91 -0
- package/src/smartfox/x2/catalogue/responses/index.ts +93 -0
- package/src/smartfox/x2/chat/index.ts +383 -0
- package/src/smartfox/x2/cipher/index.ts +88 -0
- package/src/smartfox/x2/codec/index.ts +201 -0
- package/src/smartfox/x2/config/index.ts +383 -0
- package/src/smartfox/x2/data/array/index.ts +467 -0
- package/src/smartfox/x2/data/entry/index.ts +35 -0
- package/src/smartfox/x2/data/index.ts +6 -0
- package/src/smartfox/x2/data/object/index.ts +597 -0
- package/src/smartfox/x2/data/serializer/index.ts +393 -0
- package/src/smartfox/x2/data/type/index.ts +94 -0
- package/src/smartfox/x2/entity/buddy/index.ts +114 -0
- package/src/smartfox/x2/entity/index.ts +38 -0
- package/src/smartfox/x2/entity/invitation/index.ts +90 -0
- package/src/smartfox/x2/entity/item/index.ts +74 -0
- package/src/smartfox/x2/entity/match/index.ts +269 -0
- package/src/smartfox/x2/entity/privilege/index.ts +26 -0
- package/src/smartfox/x2/entity/room/index.ts +334 -0
- package/src/smartfox/x2/entity/settings/index.ts +239 -0
- package/src/smartfox/x2/entity/user/index.ts +118 -0
- package/src/smartfox/x2/entity/variable/buddy/index.ts +114 -0
- package/src/smartfox/x2/entity/variable/index.ts +16 -0
- package/src/smartfox/x2/entity/variable/item/index.ts +114 -0
- package/src/smartfox/x2/entity/variable/room/index.ts +153 -0
- package/src/smartfox/x2/entity/variable/type/index.ts +166 -0
- package/src/smartfox/x2/entity/variable/user/index.ts +134 -0
- package/src/smartfox/x2/entity/vector/index.ts +127 -0
- package/src/smartfox/x2/flood/gate/index.ts +78 -0
- package/src/smartfox/x2/flood/index.ts +162 -0
- package/src/smartfox/x2/flood/shared/index.ts +113 -0
- package/src/smartfox/x2/format/buddy/add/index.ts +2 -0
- package/src/smartfox/x2/format/buddy/add/request/index.ts +42 -0
- package/src/smartfox/x2/format/buddy/add/response/index.ts +55 -0
- package/src/smartfox/x2/format/buddy/block/index.ts +2 -0
- package/src/smartfox/x2/format/buddy/block/request/index.ts +45 -0
- package/src/smartfox/x2/format/buddy/block/response/index.ts +60 -0
- package/src/smartfox/x2/format/buddy/index.ts +21 -0
- package/src/smartfox/x2/format/buddy/init/index.ts +2 -0
- package/src/smartfox/x2/format/buddy/init/request/index.ts +38 -0
- package/src/smartfox/x2/format/buddy/init/response/index.ts +92 -0
- package/src/smartfox/x2/format/buddy/online/index.ts +2 -0
- package/src/smartfox/x2/format/buddy/online/request/index.ts +42 -0
- package/src/smartfox/x2/format/buddy/online/response/index.ts +61 -0
- package/src/smartfox/x2/format/buddy/remove/index.ts +2 -0
- package/src/smartfox/x2/format/buddy/remove/request/index.ts +42 -0
- package/src/smartfox/x2/format/buddy/remove/response/index.ts +51 -0
- package/src/smartfox/x2/format/buddy/variables/index.ts +2 -0
- package/src/smartfox/x2/format/buddy/variables/request/index.ts +46 -0
- package/src/smartfox/x2/format/buddy/variables/response/index.ts +58 -0
- package/src/smartfox/x2/format/cluster/connection/index.ts +1 -0
- package/src/smartfox/x2/format/cluster/connection/response/index.ts +52 -0
- package/src/smartfox/x2/format/cluster/error/index.ts +1 -0
- package/src/smartfox/x2/format/cluster/error/response/index.ts +38 -0
- package/src/smartfox/x2/format/cluster/index.ts +4 -0
- package/src/smartfox/x2/format/cluster/invite/index.ts +1 -0
- package/src/smartfox/x2/format/cluster/invite/request/index.ts +55 -0
- package/src/smartfox/x2/format/cluster/join/index.ts +1 -0
- package/src/smartfox/x2/format/cluster/join/request/index.ts +107 -0
- package/src/smartfox/x2/format/contract/index.ts +37 -0
- package/src/smartfox/x2/format/disconnect/index.ts +1 -0
- package/src/smartfox/x2/format/disconnect/request/index.ts +39 -0
- package/src/smartfox/x2/format/event/count/index.ts +49 -0
- package/src/smartfox/x2/format/event/disconnection/index.ts +48 -0
- package/src/smartfox/x2/format/event/enter/index.ts +53 -0
- package/src/smartfox/x2/format/event/exit/index.ts +45 -0
- package/src/smartfox/x2/format/event/index.ts +7 -0
- package/src/smartfox/x2/format/event/item/index.ts +51 -0
- package/src/smartfox/x2/format/event/lost/index.ts +2 -0
- package/src/smartfox/x2/format/event/lost/room/index.ts +42 -0
- package/src/smartfox/x2/format/event/lost/user/index.ts +42 -0
- package/src/smartfox/x2/format/event/reconnection/index.ts +39 -0
- package/src/smartfox/x2/format/extension/index.ts +2 -0
- package/src/smartfox/x2/format/extension/request/index.ts +49 -0
- package/src/smartfox/x2/format/extension/response/index.ts +47 -0
- package/src/smartfox/x2/format/find/index.ts +8 -0
- package/src/smartfox/x2/format/find/rooms/index.ts +2 -0
- package/src/smartfox/x2/format/find/rooms/request/index.ts +51 -0
- package/src/smartfox/x2/format/find/rooms/response/index.ts +74 -0
- package/src/smartfox/x2/format/find/users/index.ts +2 -0
- package/src/smartfox/x2/format/find/users/request/index.ts +54 -0
- package/src/smartfox/x2/format/find/users/response/index.ts +74 -0
- package/src/smartfox/x2/format/game/create/index.ts +1 -0
- package/src/smartfox/x2/format/game/create/request/index.ts +61 -0
- package/src/smartfox/x2/format/game/index.ts +14 -0
- package/src/smartfox/x2/format/game/invite/index.ts +2 -0
- package/src/smartfox/x2/format/game/invite/request/index.ts +50 -0
- package/src/smartfox/x2/format/game/invite/response/index.ts +61 -0
- package/src/smartfox/x2/format/game/join/index.ts +1 -0
- package/src/smartfox/x2/format/game/join/request/index.ts +55 -0
- package/src/smartfox/x2/format/game/quick/index.ts +2 -0
- package/src/smartfox/x2/format/game/quick/request/index.ts +56 -0
- package/src/smartfox/x2/format/game/quick/response/index.ts +48 -0
- package/src/smartfox/x2/format/game/reply/index.ts +2 -0
- package/src/smartfox/x2/format/game/reply/request/index.ts +50 -0
- package/src/smartfox/x2/format/game/reply/response/index.ts +70 -0
- package/src/smartfox/x2/format/group/index.ts +8 -0
- package/src/smartfox/x2/format/group/subscribe/index.ts +2 -0
- package/src/smartfox/x2/format/group/subscribe/request/index.ts +43 -0
- package/src/smartfox/x2/format/group/subscribe/response/index.ts +89 -0
- package/src/smartfox/x2/format/group/unsubscribe/index.ts +2 -0
- package/src/smartfox/x2/format/group/unsubscribe/request/index.ts +43 -0
- package/src/smartfox/x2/format/group/unsubscribe/response/index.ts +52 -0
- package/src/smartfox/x2/format/handshake/index.ts +2 -0
- package/src/smartfox/x2/format/handshake/request/index.ts +52 -0
- package/src/smartfox/x2/format/handshake/response/index.ts +62 -0
- package/src/smartfox/x2/format/index.ts +105 -0
- package/src/smartfox/x2/format/login/index.ts +2 -0
- package/src/smartfox/x2/format/login/request/index.ts +52 -0
- package/src/smartfox/x2/format/login/response/index.ts +99 -0
- package/src/smartfox/x2/format/logout/index.ts +2 -0
- package/src/smartfox/x2/format/logout/request/index.ts +38 -0
- package/src/smartfox/x2/format/logout/response/index.ts +42 -0
- package/src/smartfox/x2/format/message/index.ts +2 -0
- package/src/smartfox/x2/format/message/request/index.ts +126 -0
- package/src/smartfox/x2/format/message/response/index.ts +68 -0
- package/src/smartfox/x2/format/mmo/index.ts +4 -0
- package/src/smartfox/x2/format/mmo/position/index.ts +2 -0
- package/src/smartfox/x2/format/mmo/position/request/index.ts +49 -0
- package/src/smartfox/x2/format/mmo/position/response/index.ts +107 -0
- package/src/smartfox/x2/format/moderation/ban/index.ts +1 -0
- package/src/smartfox/x2/format/moderation/ban/request/index.ts +57 -0
- package/src/smartfox/x2/format/moderation/index.ts +2 -0
- package/src/smartfox/x2/format/moderation/kick/index.ts +1 -0
- package/src/smartfox/x2/format/moderation/kick/request/index.ts +48 -0
- package/src/smartfox/x2/format/ping/index.ts +2 -0
- package/src/smartfox/x2/format/ping/request/index.ts +38 -0
- package/src/smartfox/x2/format/ping/response/index.ts +38 -0
- package/src/smartfox/x2/format/room/capacity/index.ts +2 -0
- package/src/smartfox/x2/format/room/capacity/request/index.ts +50 -0
- package/src/smartfox/x2/format/room/capacity/response/index.ts +59 -0
- package/src/smartfox/x2/format/room/create/index.ts +2 -0
- package/src/smartfox/x2/format/room/create/request/index.ts +55 -0
- package/src/smartfox/x2/format/room/create/response/index.ts +55 -0
- package/src/smartfox/x2/format/room/index.ts +23 -0
- package/src/smartfox/x2/format/room/join/index.ts +2 -0
- package/src/smartfox/x2/format/room/join/request/index.ts +53 -0
- package/src/smartfox/x2/format/room/join/response/index.ts +84 -0
- package/src/smartfox/x2/format/room/leave/index.ts +1 -0
- package/src/smartfox/x2/format/room/leave/request/index.ts +42 -0
- package/src/smartfox/x2/format/room/password/index.ts +2 -0
- package/src/smartfox/x2/format/room/password/request/index.ts +46 -0
- package/src/smartfox/x2/format/room/password/response/index.ts +55 -0
- package/src/smartfox/x2/format/room/quick/index.ts +1 -0
- package/src/smartfox/x2/format/room/quick/request/index.ts +68 -0
- package/src/smartfox/x2/format/room/rename/index.ts +2 -0
- package/src/smartfox/x2/format/room/rename/request/index.ts +46 -0
- package/src/smartfox/x2/format/room/rename/response/index.ts +55 -0
- package/src/smartfox/x2/format/room/variables/index.ts +2 -0
- package/src/smartfox/x2/format/room/variables/request/index.ts +49 -0
- package/src/smartfox/x2/format/room/variables/response/index.ts +49 -0
- package/src/smartfox/x2/format/seat/index.ts +8 -0
- package/src/smartfox/x2/format/seat/player/index.ts +2 -0
- package/src/smartfox/x2/format/seat/player/request/index.ts +43 -0
- package/src/smartfox/x2/format/seat/player/response/index.ts +59 -0
- package/src/smartfox/x2/format/seat/spectator/index.ts +2 -0
- package/src/smartfox/x2/format/seat/spectator/request/index.ts +43 -0
- package/src/smartfox/x2/format/seat/spectator/response/index.ts +55 -0
- package/src/smartfox/x2/format/settings/index.ts +276 -0
- package/src/smartfox/x2/format/user/index.ts +4 -0
- package/src/smartfox/x2/format/user/variables/index.ts +2 -0
- package/src/smartfox/x2/format/user/variables/request/index.ts +46 -0
- package/src/smartfox/x2/format/user/variables/response/index.ts +49 -0
- package/src/smartfox/x2/games/index.ts +484 -0
- package/src/smartfox/x2/hall/index.ts +240 -0
- package/src/smartfox/x2/handler/buddy/index.ts +120 -0
- package/src/smartfox/x2/handler/chat/index.ts +213 -0
- package/src/smartfox/x2/handler/extension/index.ts +33 -0
- package/src/smartfox/x2/handler/game/index.ts +171 -0
- package/src/smartfox/x2/handler/index.ts +6 -0
- package/src/smartfox/x2/handler/room/index.ts +466 -0
- package/src/smartfox/x2/handler/session/index.ts +201 -0
- package/src/smartfox/x2/header/index.ts +25 -0
- package/src/smartfox/x2/index.ts +275 -0
- package/src/smartfox/x2/login/attempt/index.ts +102 -0
- package/src/smartfox/x2/login/index.ts +2 -0
- package/src/smartfox/x2/login/verdict/index.ts +81 -0
- package/src/smartfox/x2/member/index.ts +260 -0
- package/src/smartfox/x2/packet/buddy/add/index.ts +2 -0
- package/src/smartfox/x2/packet/buddy/add/request/index.ts +25 -0
- package/src/smartfox/x2/packet/buddy/add/response/index.ts +43 -0
- package/src/smartfox/x2/packet/buddy/block/index.ts +2 -0
- package/src/smartfox/x2/packet/buddy/block/request/index.ts +33 -0
- package/src/smartfox/x2/packet/buddy/block/response/index.ts +68 -0
- package/src/smartfox/x2/packet/buddy/index.ts +13 -0
- package/src/smartfox/x2/packet/buddy/init/index.ts +2 -0
- package/src/smartfox/x2/packet/buddy/init/request/index.ts +14 -0
- package/src/smartfox/x2/packet/buddy/init/response/index.ts +69 -0
- package/src/smartfox/x2/packet/buddy/online/index.ts +2 -0
- package/src/smartfox/x2/packet/buddy/online/request/index.ts +25 -0
- package/src/smartfox/x2/packet/buddy/online/response/index.ts +85 -0
- package/src/smartfox/x2/packet/buddy/remove/index.ts +2 -0
- package/src/smartfox/x2/packet/buddy/remove/request/index.ts +25 -0
- package/src/smartfox/x2/packet/buddy/remove/response/index.ts +42 -0
- package/src/smartfox/x2/packet/buddy/variables/index.ts +2 -0
- package/src/smartfox/x2/packet/buddy/variables/request/index.ts +29 -0
- package/src/smartfox/x2/packet/buddy/variables/response/index.ts +58 -0
- package/src/smartfox/x2/packet/cluster/connection/index.ts +1 -0
- package/src/smartfox/x2/packet/cluster/connection/response/index.ts +54 -0
- package/src/smartfox/x2/packet/cluster/error/index.ts +1 -0
- package/src/smartfox/x2/packet/cluster/error/response/index.ts +14 -0
- package/src/smartfox/x2/packet/cluster/index.ts +4 -0
- package/src/smartfox/x2/packet/cluster/invite/index.ts +1 -0
- package/src/smartfox/x2/packet/cluster/invite/request/index.ts +77 -0
- package/src/smartfox/x2/packet/cluster/join/index.ts +1 -0
- package/src/smartfox/x2/packet/cluster/join/request/index.ts +52 -0
- package/src/smartfox/x2/packet/disconnect/index.ts +1 -0
- package/src/smartfox/x2/packet/disconnect/request/index.ts +14 -0
- package/src/smartfox/x2/packet/error/codes/index.ts +231 -0
- package/src/smartfox/x2/packet/error/index.ts +69 -0
- package/src/smartfox/x2/packet/event/count/index.ts +45 -0
- package/src/smartfox/x2/packet/event/disconnection/index.ts +72 -0
- package/src/smartfox/x2/packet/event/enter/index.ts +47 -0
- package/src/smartfox/x2/packet/event/exit/index.ts +33 -0
- package/src/smartfox/x2/packet/event/index.ts +10 -0
- package/src/smartfox/x2/packet/event/item/index.ts +51 -0
- package/src/smartfox/x2/packet/event/lost/index.ts +2 -0
- package/src/smartfox/x2/packet/event/lost/room/index.ts +25 -0
- package/src/smartfox/x2/packet/event/lost/user/index.ts +25 -0
- package/src/smartfox/x2/packet/event/reconnection/index.ts +14 -0
- package/src/smartfox/x2/packet/extension/index.ts +2 -0
- package/src/smartfox/x2/packet/extension/request/index.ts +74 -0
- package/src/smartfox/x2/packet/extension/response/index.ts +54 -0
- package/src/smartfox/x2/packet/find/index.ts +2 -0
- package/src/smartfox/x2/packet/find/rooms/index.ts +2 -0
- package/src/smartfox/x2/packet/find/rooms/request/index.ts +51 -0
- package/src/smartfox/x2/packet/find/rooms/response/index.ts +27 -0
- package/src/smartfox/x2/packet/find/users/index.ts +2 -0
- package/src/smartfox/x2/packet/find/users/request/index.ts +89 -0
- package/src/smartfox/x2/packet/find/users/response/index.ts +27 -0
- package/src/smartfox/x2/packet/game/create/index.ts +1 -0
- package/src/smartfox/x2/packet/game/create/request/index.ts +27 -0
- package/src/smartfox/x2/packet/game/index.ts +8 -0
- package/src/smartfox/x2/packet/game/invite/index.ts +2 -0
- package/src/smartfox/x2/packet/game/invite/request/index.ts +51 -0
- package/src/smartfox/x2/packet/game/invite/response/index.ts +92 -0
- package/src/smartfox/x2/packet/game/join/index.ts +1 -0
- package/src/smartfox/x2/packet/game/join/request/index.ts +77 -0
- package/src/smartfox/x2/packet/game/quick/index.ts +2 -0
- package/src/smartfox/x2/packet/game/quick/request/index.ts +89 -0
- package/src/smartfox/x2/packet/game/quick/response/index.ts +34 -0
- package/src/smartfox/x2/packet/game/reply/index.ts +2 -0
- package/src/smartfox/x2/packet/game/reply/request/index.ts +51 -0
- package/src/smartfox/x2/packet/game/reply/response/index.ts +91 -0
- package/src/smartfox/x2/packet/group/index.ts +8 -0
- package/src/smartfox/x2/packet/group/subscribe/index.ts +2 -0
- package/src/smartfox/x2/packet/group/subscribe/request/index.ts +25 -0
- package/src/smartfox/x2/packet/group/subscribe/response/index.ts +58 -0
- package/src/smartfox/x2/packet/group/unsubscribe/index.ts +2 -0
- package/src/smartfox/x2/packet/group/unsubscribe/request/index.ts +25 -0
- package/src/smartfox/x2/packet/group/unsubscribe/response/index.ts +42 -0
- package/src/smartfox/x2/packet/handshake/index.ts +2 -0
- package/src/smartfox/x2/packet/handshake/request/index.ts +49 -0
- package/src/smartfox/x2/packet/handshake/response/index.ts +83 -0
- package/src/smartfox/x2/packet/index.ts +99 -0
- package/src/smartfox/x2/packet/login/index.ts +2 -0
- package/src/smartfox/x2/packet/login/request/index.ts +95 -0
- package/src/smartfox/x2/packet/login/response/index.ts +131 -0
- package/src/smartfox/x2/packet/logout/index.ts +2 -0
- package/src/smartfox/x2/packet/logout/request/index.ts +14 -0
- package/src/smartfox/x2/packet/logout/response/index.ts +25 -0
- package/src/smartfox/x2/packet/message/index.ts +4 -0
- package/src/smartfox/x2/packet/message/request/index.ts +241 -0
- package/src/smartfox/x2/packet/message/response/index.ts +216 -0
- package/src/smartfox/x2/packet/message/type/index.ts +56 -0
- package/src/smartfox/x2/packet/mmo/index.ts +5 -0
- package/src/smartfox/x2/packet/mmo/position/index.ts +3 -0
- package/src/smartfox/x2/packet/mmo/position/request/index.ts +38 -0
- package/src/smartfox/x2/packet/mmo/position/response/index.ts +114 -0
- package/src/smartfox/x2/packet/moderation/ban/index.ts +1 -0
- package/src/smartfox/x2/packet/moderation/ban/request/index.ts +83 -0
- package/src/smartfox/x2/packet/moderation/index.ts +2 -0
- package/src/smartfox/x2/packet/moderation/kick/index.ts +1 -0
- package/src/smartfox/x2/packet/moderation/kick/request/index.ts +45 -0
- package/src/smartfox/x2/packet/ping/index.ts +2 -0
- package/src/smartfox/x2/packet/ping/request/index.ts +14 -0
- package/src/smartfox/x2/packet/ping/response/index.ts +14 -0
- package/src/smartfox/x2/packet/room/capacity/index.ts +2 -0
- package/src/smartfox/x2/packet/room/capacity/request/index.ts +45 -0
- package/src/smartfox/x2/packet/room/capacity/response/index.ts +67 -0
- package/src/smartfox/x2/packet/room/create/index.ts +2 -0
- package/src/smartfox/x2/packet/room/create/request/index.ts +51 -0
- package/src/smartfox/x2/packet/room/create/response/index.ts +43 -0
- package/src/smartfox/x2/packet/room/index.ts +21 -0
- package/src/smartfox/x2/packet/room/join/index.ts +3 -0
- package/src/smartfox/x2/packet/room/join/request/index.ts +101 -0
- package/src/smartfox/x2/packet/room/join/response/index.ts +74 -0
- package/src/smartfox/x2/packet/room/leave/index.ts +1 -0
- package/src/smartfox/x2/packet/room/leave/request/index.ts +25 -0
- package/src/smartfox/x2/packet/room/password/index.ts +2 -0
- package/src/smartfox/x2/packet/room/password/request/index.ts +33 -0
- package/src/smartfox/x2/packet/room/password/response/index.ts +57 -0
- package/src/smartfox/x2/packet/room/quick/index.ts +1 -0
- package/src/smartfox/x2/packet/room/quick/request/index.ts +67 -0
- package/src/smartfox/x2/packet/room/rename/index.ts +2 -0
- package/src/smartfox/x2/packet/room/rename/request/index.ts +33 -0
- package/src/smartfox/x2/packet/room/rename/response/index.ts +50 -0
- package/src/smartfox/x2/packet/room/variables/index.ts +2 -0
- package/src/smartfox/x2/packet/room/variables/request/index.ts +38 -0
- package/src/smartfox/x2/packet/room/variables/response/index.ts +38 -0
- package/src/smartfox/x2/packet/seat/index.ts +8 -0
- package/src/smartfox/x2/packet/seat/player/index.ts +2 -0
- package/src/smartfox/x2/packet/seat/player/request/index.ts +25 -0
- package/src/smartfox/x2/packet/seat/player/response/index.ts +67 -0
- package/src/smartfox/x2/packet/seat/spectator/index.ts +2 -0
- package/src/smartfox/x2/packet/seat/spectator/request/index.ts +25 -0
- package/src/smartfox/x2/packet/seat/spectator/response/index.ts +50 -0
- package/src/smartfox/x2/packet/unknown/index.ts +47 -0
- package/src/smartfox/x2/packet/user/index.ts +4 -0
- package/src/smartfox/x2/packet/user/variables/index.ts +2 -0
- package/src/smartfox/x2/packet/user/variables/request/index.ts +29 -0
- package/src/smartfox/x2/packet/user/variables/response/index.ts +38 -0
- package/src/smartfox/x2/protocol/index.ts +495 -0
- package/src/smartfox/x2/proximity/index.ts +353 -0
- package/src/smartfox/x2/rooms/index.ts +981 -0
- package/src/smartfox/x2/roster/index.ts +3 -0
- package/src/smartfox/x2/roster/memory/index.ts +41 -0
- package/src/smartfox/x2/roster/record/index.ts +31 -0
- package/src/smartfox/x2/roster/store/index.ts +21 -0
- package/src/smartfox/x2/route/index.ts +17 -0
- package/src/smartfox/x2/sessions/index.ts +18 -0
- package/src/smartfox/x2/udp/index.ts +392 -0
- package/src/smartfox/x2/web/index.ts +183 -0
- package/src/smartfox/x2/websocket/index.ts +119 -0
- package/src/smartfox/x2/words/index.ts +265 -0
- package/src/smartfox/x2/zone/index.ts +1163 -0
- package/src/smartfox/x2/zones/index.ts +608 -0
|
@@ -0,0 +1,1527 @@
|
|
|
1
|
+
import { randomInt } from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
import { AttributeKey, ByteBuf, type Channel } from '@netifyjs/netify'
|
|
4
|
+
|
|
5
|
+
import { Delivery, Frame } from '../../frame/index.ts'
|
|
6
|
+
import type { DatagramSeal } from '../../seal/index.ts'
|
|
7
|
+
import { DisconnectReason, EnetClosure } from '../closure/index.ts'
|
|
8
|
+
import { Command, CommandFlag, CommandType } from '../command/index.ts'
|
|
9
|
+
import { EnetDatagram } from '../datagram/index.ts'
|
|
10
|
+
import { Flight } from '../flight/index.ts'
|
|
11
|
+
import { Admission, type AdmissionCode, EnetLane } from '../lane/index.ts'
|
|
12
|
+
import { EnetSettings } from '../options/index.ts'
|
|
13
|
+
import { UnsequencedWindow } from '../window/index.ts'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* What a peer needs from whoever owns it
|
|
17
|
+
*/
|
|
18
|
+
export type EnetHooks = {
|
|
19
|
+
/**
|
|
20
|
+
* Puts a datagram on the wire
|
|
21
|
+
* @param datagram bytes ready to send
|
|
22
|
+
*/
|
|
23
|
+
transmit(datagram: Uint8Array): void
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Hands a message to the application
|
|
27
|
+
* @param frame what arrived
|
|
28
|
+
*/
|
|
29
|
+
deliver(frame: Frame): void
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The server accepted a connection this side asked for
|
|
33
|
+
*/
|
|
34
|
+
established(): void
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The connection is over
|
|
38
|
+
*/
|
|
39
|
+
closed(): void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What switches a connection to encrypted datagrams
|
|
44
|
+
*/
|
|
45
|
+
export type EnetEncryption = {
|
|
46
|
+
/**
|
|
47
|
+
* Encrypts and opens the datagrams
|
|
48
|
+
*/
|
|
49
|
+
readonly seal: DatagramSeal
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sequence number offsets by channel, control channel last
|
|
53
|
+
*/
|
|
54
|
+
readonly offsets: ArrayLike<number>
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether the offsets replace the counters, false by default
|
|
58
|
+
*/
|
|
59
|
+
readonly absolute?: boolean
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Most bytes the seal adds to a block, 64 by default
|
|
63
|
+
*/
|
|
64
|
+
readonly overhead?: number
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Where a connection is in its life
|
|
69
|
+
*/
|
|
70
|
+
const PeerState = {
|
|
71
|
+
/**
|
|
72
|
+
* Nothing has happened yet
|
|
73
|
+
*/
|
|
74
|
+
IDLE: 0,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Waiting for the server to accept
|
|
78
|
+
*/
|
|
79
|
+
CONNECTING: 1,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Messages flow
|
|
83
|
+
*/
|
|
84
|
+
CONNECTED: 2,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Sending what's left before hanging up
|
|
88
|
+
*/
|
|
89
|
+
LEAVING: 3,
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Over
|
|
93
|
+
*/
|
|
94
|
+
CLOSED: 4,
|
|
95
|
+
} as const
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* One end of a Photon reliable UDP connection
|
|
99
|
+
* @class
|
|
100
|
+
*/
|
|
101
|
+
export class EnetPeer {
|
|
102
|
+
/**
|
|
103
|
+
* Where a virtual channel keeps its peer
|
|
104
|
+
*/
|
|
105
|
+
public static readonly key: AttributeKey<EnetPeer> =
|
|
106
|
+
new AttributeKey<EnetPeer>('netify:protocol:photon:enet:peer')
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Bytes of a connect or verify connect body
|
|
110
|
+
*/
|
|
111
|
+
public static readonly greeting: number = 32
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Largest round trip an ack is believed to show, in ms
|
|
115
|
+
*/
|
|
116
|
+
private static readonly ceiling: number = 10_000
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Round trip below which a first sample is rounded up, in ms
|
|
120
|
+
*/
|
|
121
|
+
private static readonly floor: number = 15
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Timing, limits and the clock
|
|
125
|
+
*/
|
|
126
|
+
private readonly settings: EnetSettings
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Whoever owns the peer
|
|
130
|
+
*/
|
|
131
|
+
private readonly hooks: EnetHooks
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Whether this end asked for the connection
|
|
135
|
+
*/
|
|
136
|
+
private readonly client: boolean
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Reserved byte this end puts on its commands
|
|
140
|
+
*/
|
|
141
|
+
private readonly filler: number
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Channels in use, by number
|
|
145
|
+
*/
|
|
146
|
+
private readonly lanes: Map<number, EnetLane>
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The control channel
|
|
150
|
+
*/
|
|
151
|
+
private readonly control: EnetLane
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Unsequenced messages already seen
|
|
155
|
+
*/
|
|
156
|
+
private readonly groups: UnsequencedWindow
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Reliable commands waiting for an ack
|
|
160
|
+
*/
|
|
161
|
+
private readonly flights: Map<number, Flight>
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Peers with something due at the end of this turn
|
|
165
|
+
*/
|
|
166
|
+
private static readonly ready: EnetPeer[] = []
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Set once the end of this turn is booked
|
|
170
|
+
*/
|
|
171
|
+
private static roused = false
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Runs the next resend, ping or delayed send
|
|
175
|
+
*/
|
|
176
|
+
private readonly tick: () => void
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Where the connection is in its life
|
|
180
|
+
*/
|
|
181
|
+
private state: number
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Id the server gave the client
|
|
185
|
+
*/
|
|
186
|
+
private assigned: number
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Peer id this end writes in its datagrams
|
|
190
|
+
*/
|
|
191
|
+
private tag: number
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The client's connection token
|
|
195
|
+
*/
|
|
196
|
+
private token: number
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Largest datagram for this connection in bytes
|
|
200
|
+
*/
|
|
201
|
+
private unit: number
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* How many channels the client asked for
|
|
205
|
+
*/
|
|
206
|
+
private count: number
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Whether outgoing datagrams get a checksum
|
|
210
|
+
*/
|
|
211
|
+
private checked: boolean
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Channels in use, lowest first
|
|
215
|
+
*/
|
|
216
|
+
private order: EnetLane[]
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Acks waiting to leave
|
|
220
|
+
*/
|
|
221
|
+
private acks: Command[]
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Commands of the datagram being built
|
|
225
|
+
*/
|
|
226
|
+
private batch: Command[]
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Bytes of the datagram being built
|
|
230
|
+
*/
|
|
231
|
+
private filled: number
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Commands waiting in any channel
|
|
235
|
+
*/
|
|
236
|
+
private queued: number
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Unacked reliable bytes on the wire
|
|
240
|
+
*/
|
|
241
|
+
private transit: number
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Payload bytes waiting for missing pieces
|
|
245
|
+
*/
|
|
246
|
+
private buffered: number
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Number of the last unsequenced message sent
|
|
250
|
+
*/
|
|
251
|
+
private group: number
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Smoothed round trip in ms
|
|
255
|
+
*/
|
|
256
|
+
private round: number
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* How much the round trip wanders, in ms
|
|
260
|
+
*/
|
|
261
|
+
private variance: number
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Time the last ack arrived in ms
|
|
265
|
+
*/
|
|
266
|
+
private heard: number
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Clock reading the datagram timestamps count from
|
|
270
|
+
*/
|
|
271
|
+
private origin: number
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Server clock minus this end's timestamps, or null
|
|
275
|
+
*/
|
|
276
|
+
private skew: number | null
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Encrypts and opens datagrams, or null
|
|
280
|
+
*/
|
|
281
|
+
private seal: DatagramSeal | null
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Whether outgoing datagrams are encrypted
|
|
285
|
+
*/
|
|
286
|
+
private sealing: boolean
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Whether an encrypted datagram has arrived
|
|
290
|
+
*/
|
|
291
|
+
private sealed: boolean
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Most bytes the seal adds to a block
|
|
295
|
+
*/
|
|
296
|
+
private overhead: number
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Sequence number offsets by channel, or null
|
|
300
|
+
*/
|
|
301
|
+
private offsets: ArrayLike<number> | null
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Whether the offsets replace the counters
|
|
305
|
+
*/
|
|
306
|
+
private absolute: boolean
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Whether the verify connect has been queued
|
|
310
|
+
*/
|
|
311
|
+
private greeted: boolean
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Whether the client must prove it hears this end before messages flow
|
|
315
|
+
*/
|
|
316
|
+
private guarded: boolean
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Whether the latest datagram named the id the client was given
|
|
320
|
+
*/
|
|
321
|
+
private named: boolean
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Whether the client acked the verify connect under its given id
|
|
325
|
+
*/
|
|
326
|
+
private heeded: boolean
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Whether the closing disconnect has been queued
|
|
330
|
+
*/
|
|
331
|
+
private parted: boolean
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Whether something must leave right after this datagram
|
|
335
|
+
*/
|
|
336
|
+
private urgent: boolean
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* The pending wake-up, or null
|
|
340
|
+
*/
|
|
341
|
+
private timer: Timer | null
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Set while the peer waits for the end of this turn
|
|
345
|
+
*/
|
|
346
|
+
private listed: boolean
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Time the pending wake-up fires in ms
|
|
350
|
+
*/
|
|
351
|
+
private due: number
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* How the connection ended, or null
|
|
355
|
+
*/
|
|
356
|
+
private ending: EnetClosure | null
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @param settings timing, limits and the clock
|
|
360
|
+
* @param hooks whoever owns the peer
|
|
361
|
+
* @param client whether this end asks for the connection
|
|
362
|
+
*/
|
|
363
|
+
private constructor(
|
|
364
|
+
settings: EnetSettings,
|
|
365
|
+
hooks: EnetHooks,
|
|
366
|
+
client: boolean,
|
|
367
|
+
) {
|
|
368
|
+
this.settings = settings
|
|
369
|
+
this.hooks = hooks
|
|
370
|
+
this.client = client
|
|
371
|
+
this.listed = false
|
|
372
|
+
this.filler = client ? 4 : 0
|
|
373
|
+
this.lanes = new Map<number, EnetLane>()
|
|
374
|
+
this.control = new EnetLane(Command.control)
|
|
375
|
+
this.groups = new UnsequencedWindow()
|
|
376
|
+
this.flights = new Map<number, Flight>()
|
|
377
|
+
this.tick = (): void => {
|
|
378
|
+
this.service(this.settings.clock())
|
|
379
|
+
}
|
|
380
|
+
this.state = PeerState.IDLE
|
|
381
|
+
this.assigned = -1
|
|
382
|
+
this.tag = -1
|
|
383
|
+
this.token = 0
|
|
384
|
+
this.unit = settings.mtu
|
|
385
|
+
this.count = 0
|
|
386
|
+
this.checked = false
|
|
387
|
+
this.order = []
|
|
388
|
+
this.acks = []
|
|
389
|
+
this.batch = []
|
|
390
|
+
this.filled = 0
|
|
391
|
+
this.queued = 0
|
|
392
|
+
this.transit = 0
|
|
393
|
+
this.buffered = 0
|
|
394
|
+
this.group = 0
|
|
395
|
+
this.round = 200
|
|
396
|
+
this.variance = 5
|
|
397
|
+
this.heard = 0
|
|
398
|
+
this.origin = 0
|
|
399
|
+
this.skew = null
|
|
400
|
+
this.seal = null
|
|
401
|
+
this.sealing = false
|
|
402
|
+
this.sealed = false
|
|
403
|
+
this.overhead = 0
|
|
404
|
+
this.offsets = null
|
|
405
|
+
this.absolute = false
|
|
406
|
+
this.greeted = false
|
|
407
|
+
this.guarded = false
|
|
408
|
+
this.named = false
|
|
409
|
+
this.heeded = false
|
|
410
|
+
this.parted = false
|
|
411
|
+
this.urgent = false
|
|
412
|
+
this.timer = null
|
|
413
|
+
this.due = Infinity
|
|
414
|
+
this.ending = null
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* The peer behind a virtual channel, or null
|
|
419
|
+
* @param channel a connection handlers see
|
|
420
|
+
*/
|
|
421
|
+
public static of(channel: Channel): EnetPeer | null {
|
|
422
|
+
return channel.attributes.get<EnetPeer>(EnetPeer.key)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* The end that waits for a connect
|
|
427
|
+
* @param settings timing, limits and the clock
|
|
428
|
+
* @param hooks whoever owns the peer
|
|
429
|
+
*/
|
|
430
|
+
public static server(settings: EnetSettings, hooks: EnetHooks): EnetPeer {
|
|
431
|
+
return new EnetPeer(settings, hooks, false)
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The end that asks for the connection
|
|
436
|
+
* @param settings timing, limits and the clock
|
|
437
|
+
* @param hooks whoever owns the peer
|
|
438
|
+
*/
|
|
439
|
+
public static client(settings: EnetSettings, hooks: EnetHooks): EnetPeer {
|
|
440
|
+
return new EnetPeer(settings, hooks, true)
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Id the server gave the client, or -1
|
|
445
|
+
*/
|
|
446
|
+
public get id(): number {
|
|
447
|
+
return this.assigned
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* The client's connection token
|
|
452
|
+
*/
|
|
453
|
+
public get challenge(): number {
|
|
454
|
+
return this.token
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Largest datagram for this connection in bytes
|
|
459
|
+
*/
|
|
460
|
+
public get mtu(): number {
|
|
461
|
+
return this.unit
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* How many channels the client asked for
|
|
466
|
+
*/
|
|
467
|
+
public get channels(): number {
|
|
468
|
+
return this.count
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Whether messages can be sent
|
|
473
|
+
*/
|
|
474
|
+
public get open(): boolean {
|
|
475
|
+
return this.state === PeerState.CONNECTED
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Whether datagrams are encrypted
|
|
480
|
+
*/
|
|
481
|
+
public get encrypted(): boolean {
|
|
482
|
+
return this.seal !== null
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Smoothed round trip in ms
|
|
487
|
+
*/
|
|
488
|
+
public get roundTripTime(): number {
|
|
489
|
+
return this.round
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* The server's clock in ms, or null
|
|
494
|
+
*/
|
|
495
|
+
public get serverTime(): number | null {
|
|
496
|
+
if (this.skew === null) return null
|
|
497
|
+
|
|
498
|
+
return (this.skew + this.stamp(this.settings.clock())) | 0
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* How the connection ended, or null
|
|
503
|
+
*/
|
|
504
|
+
public get closure(): EnetClosure | null {
|
|
505
|
+
return this.ending
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Whether the client has shown it receives what this end sends
|
|
510
|
+
*/
|
|
511
|
+
public get proven(): boolean {
|
|
512
|
+
return this.heeded
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Starts the server end from a client's connect
|
|
517
|
+
* @param id peer id the client is given
|
|
518
|
+
* @param datagram the datagram the connect came in
|
|
519
|
+
* @param connect the connect command
|
|
520
|
+
* @param guarded whether the client must prove it hears this end first
|
|
521
|
+
*/
|
|
522
|
+
public accept(
|
|
523
|
+
id: number,
|
|
524
|
+
datagram: EnetDatagram,
|
|
525
|
+
connect: Command,
|
|
526
|
+
guarded = false,
|
|
527
|
+
): void {
|
|
528
|
+
if (this.state !== PeerState.IDLE) throw new Error('Peer is in use')
|
|
529
|
+
if (guarded) this.control.sent = randomInt(0x4000_0000)
|
|
530
|
+
|
|
531
|
+
this.guarded = guarded
|
|
532
|
+
|
|
533
|
+
const body = ByteBuf.wrap(connect.payload)
|
|
534
|
+
const settings = this.settings
|
|
535
|
+
|
|
536
|
+
this.assigned = id
|
|
537
|
+
this.tag = body.getInt16(0)
|
|
538
|
+
this.token = datagram.challenge
|
|
539
|
+
this.unit = Math.min(
|
|
540
|
+
Math.max(body.getUint16(2), EnetSettings.smallest),
|
|
541
|
+
settings.mtu,
|
|
542
|
+
)
|
|
543
|
+
this.count = Math.min(Math.max(body.getInt32(8), 1), settings.maxChannels)
|
|
544
|
+
this.heard = settings.clock()
|
|
545
|
+
this.state = PeerState.CONNECTING
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Asks the server for a connection
|
|
550
|
+
* @param channels how many channels to ask for
|
|
551
|
+
* @param checked whether datagrams get a checksum
|
|
552
|
+
*/
|
|
553
|
+
public connect(channels: number, checked: boolean): void {
|
|
554
|
+
if (this.state !== PeerState.IDLE) throw new Error('Peer is in use')
|
|
555
|
+
if (!(channels >= 1 && channels <= Command.control)) {
|
|
556
|
+
throw new RangeError('Channel count is invalid')
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const now = this.settings.clock()
|
|
560
|
+
const body = ByteBuf.wrap(new Uint8Array(EnetPeer.greeting))
|
|
561
|
+
.setUint16(2, this.unit)
|
|
562
|
+
.setUint32(4, 0x8000)
|
|
563
|
+
.setUint32(8, channels)
|
|
564
|
+
.setUint32(20, 5000)
|
|
565
|
+
.setUint32(24, 2)
|
|
566
|
+
.setUint32(28, 2)
|
|
567
|
+
|
|
568
|
+
this.count = channels
|
|
569
|
+
this.checked = checked
|
|
570
|
+
this.token = randomInt(0x7fff_ffff)
|
|
571
|
+
this.origin = now
|
|
572
|
+
this.heard = now
|
|
573
|
+
this.state = PeerState.CONNECTING
|
|
574
|
+
this.enqueue(
|
|
575
|
+
this.control,
|
|
576
|
+
this.steer(CommandType.CONNECT, CommandFlag.RELIABLE, body.array),
|
|
577
|
+
)
|
|
578
|
+
this.service(now)
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Takes a datagram from the other end
|
|
583
|
+
* @param datagram what arrived
|
|
584
|
+
*/
|
|
585
|
+
public receive(datagram: EnetDatagram): void {
|
|
586
|
+
const opened = this.unwrap(datagram)
|
|
587
|
+
if (opened === null) return
|
|
588
|
+
|
|
589
|
+
const now = this.settings.clock()
|
|
590
|
+
for (const command of opened.commands()) {
|
|
591
|
+
if (this.state === PeerState.CLOSED) return
|
|
592
|
+
this.handle(command, opened.time, now)
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (!this.urgent || this.state === PeerState.CLOSED) return
|
|
596
|
+
this.service(now)
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Queues a message for the other end
|
|
601
|
+
* @param frame what to send
|
|
602
|
+
*/
|
|
603
|
+
public send(frame: Frame): void {
|
|
604
|
+
const refusal = this.refusal(frame)
|
|
605
|
+
if (refusal !== null) throw new Error(refusal)
|
|
606
|
+
|
|
607
|
+
const lane = this.lane(frame.channel)
|
|
608
|
+
const payload = frame.payload.slice()
|
|
609
|
+
const channel = frame.channel
|
|
610
|
+
|
|
611
|
+
if (payload.length > this.piece) {
|
|
612
|
+
this.split(lane, payload, frame.delivery)
|
|
613
|
+
} else if (frame.delivery === Delivery.RELIABLE) {
|
|
614
|
+
lane.sent += 1
|
|
615
|
+
this.enqueue(
|
|
616
|
+
lane,
|
|
617
|
+
Command.of(
|
|
618
|
+
CommandType.RELIABLE,
|
|
619
|
+
channel,
|
|
620
|
+
CommandFlag.RELIABLE,
|
|
621
|
+
this.filler,
|
|
622
|
+
lane.sent,
|
|
623
|
+
[],
|
|
624
|
+
payload,
|
|
625
|
+
),
|
|
626
|
+
)
|
|
627
|
+
} else if (frame.delivery === Delivery.RELIABLE_UNSEQUENCED) {
|
|
628
|
+
lane.loose += 1
|
|
629
|
+
this.enqueue(
|
|
630
|
+
lane,
|
|
631
|
+
Command.of(
|
|
632
|
+
CommandType.LOOSE,
|
|
633
|
+
channel,
|
|
634
|
+
CommandFlag.RELIABLE | CommandFlag.UNSEQUENCED,
|
|
635
|
+
this.filler,
|
|
636
|
+
lane.loose,
|
|
637
|
+
[],
|
|
638
|
+
payload,
|
|
639
|
+
),
|
|
640
|
+
)
|
|
641
|
+
} else if (frame.delivery === Delivery.UNSEQUENCED) {
|
|
642
|
+
this.group += 1
|
|
643
|
+
this.enqueue(
|
|
644
|
+
lane,
|
|
645
|
+
Command.of(
|
|
646
|
+
CommandType.UNSEQUENCED,
|
|
647
|
+
channel,
|
|
648
|
+
CommandFlag.UNSEQUENCED,
|
|
649
|
+
this.filler,
|
|
650
|
+
0,
|
|
651
|
+
[this.group],
|
|
652
|
+
payload,
|
|
653
|
+
),
|
|
654
|
+
)
|
|
655
|
+
} else {
|
|
656
|
+
lane.unreliable += 1
|
|
657
|
+
this.enqueue(
|
|
658
|
+
lane,
|
|
659
|
+
Command.of(
|
|
660
|
+
CommandType.UNRELIABLE,
|
|
661
|
+
channel,
|
|
662
|
+
0,
|
|
663
|
+
this.filler,
|
|
664
|
+
lane.sent,
|
|
665
|
+
[lane.unreliable],
|
|
666
|
+
payload,
|
|
667
|
+
),
|
|
668
|
+
)
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
this.wake(this.settings.clock() + this.settings.sendDelay)
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Sends everything that's waiting now
|
|
676
|
+
*/
|
|
677
|
+
public flush(): void {
|
|
678
|
+
this.service(this.settings.clock())
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Switches the connection to encrypted datagrams
|
|
683
|
+
* @param encryption the seal and the sequence number offsets
|
|
684
|
+
*/
|
|
685
|
+
public encrypt(encryption: EnetEncryption): void {
|
|
686
|
+
if (this.seal !== null) throw new Error('Connection is already encrypted')
|
|
687
|
+
if (this.state !== PeerState.CONNECTED) {
|
|
688
|
+
throw new Error('Connection is not open')
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
this.seal = encryption.seal
|
|
692
|
+
this.sealing = !this.client
|
|
693
|
+
this.overhead = encryption.overhead ?? 64
|
|
694
|
+
this.offsets = encryption.offsets
|
|
695
|
+
this.absolute = encryption.absolute ?? false
|
|
696
|
+
|
|
697
|
+
for (const lane of this.order) {
|
|
698
|
+
lane.shift(this.offset(lane.id), this.absolute)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
this.control.shift(this.offset(this.count), this.absolute)
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Asks the server for its clock
|
|
706
|
+
*/
|
|
707
|
+
public synchronise(): void {
|
|
708
|
+
if (!this.client) throw new Error('Only a client asks for the time')
|
|
709
|
+
if (this.state !== PeerState.CONNECTED) {
|
|
710
|
+
throw new Error('Connection is not open')
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
this.enqueue(
|
|
714
|
+
this.control,
|
|
715
|
+
this.steer(CommandType.TIME, CommandFlag.RELIABLE),
|
|
716
|
+
)
|
|
717
|
+
this.service(this.settings.clock())
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Hangs up after sending what's queued
|
|
722
|
+
* @param reason reserved byte the other end is shown
|
|
723
|
+
*/
|
|
724
|
+
public disconnect(
|
|
725
|
+
reason: number = this.client
|
|
726
|
+
? DisconnectReason.CLIENT
|
|
727
|
+
: DisconnectReason.LOGIC,
|
|
728
|
+
): void {
|
|
729
|
+
if (this.state === PeerState.CLOSED) return
|
|
730
|
+
if (this.state === PeerState.LEAVING) return
|
|
731
|
+
|
|
732
|
+
const now = this.settings.clock()
|
|
733
|
+
this.ending = EnetClosure.local(reason)
|
|
734
|
+
|
|
735
|
+
if (this.state === PeerState.IDLE) {
|
|
736
|
+
this.finish(this.ending)
|
|
737
|
+
return
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (!this.client && this.state === PeerState.CONNECTED) {
|
|
741
|
+
this.state = PeerState.LEAVING
|
|
742
|
+
this.service(now)
|
|
743
|
+
return
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const flags =
|
|
747
|
+
this.state === PeerState.CONNECTED
|
|
748
|
+
? CommandFlag.RELIABLE
|
|
749
|
+
: CommandFlag.UNSEQUENCED
|
|
750
|
+
this.fill(now, [])
|
|
751
|
+
this.load(this.steer(CommandType.DISCONNECT, flags, undefined, reason), now)
|
|
752
|
+
this.emit(now)
|
|
753
|
+
this.finish(this.ending)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Hangs up at once
|
|
758
|
+
* @param reason reserved byte the other end is shown
|
|
759
|
+
*/
|
|
760
|
+
public abort(reason: number): void {
|
|
761
|
+
if (this.state === PeerState.CLOSED) return
|
|
762
|
+
|
|
763
|
+
const now = this.settings.clock()
|
|
764
|
+
if (this.state !== PeerState.IDLE) {
|
|
765
|
+
this.batch = []
|
|
766
|
+
this.filled = 0
|
|
767
|
+
this.load(
|
|
768
|
+
this.steer(
|
|
769
|
+
CommandType.DISCONNECT,
|
|
770
|
+
CommandFlag.UNSEQUENCED,
|
|
771
|
+
undefined,
|
|
772
|
+
reason,
|
|
773
|
+
),
|
|
774
|
+
now,
|
|
775
|
+
)
|
|
776
|
+
this.emit(now)
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
this.finish(EnetClosure.local(reason))
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Why a message can't be sent, or null
|
|
784
|
+
* @param frame what the application wrote
|
|
785
|
+
*/
|
|
786
|
+
private refusal(frame: Frame): string | null {
|
|
787
|
+
if (this.state !== PeerState.CONNECTED) return 'Connection is not open'
|
|
788
|
+
if (!(frame.channel >= 0 && frame.channel < this.count)) {
|
|
789
|
+
return 'Channel is out of range'
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (frame.payload.length > this.settings.maxMessageSize) {
|
|
793
|
+
return 'Message is too large'
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return null
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Most command bytes one datagram may carry
|
|
801
|
+
*/
|
|
802
|
+
private get budget(): number {
|
|
803
|
+
if (this.seal !== null) {
|
|
804
|
+
return this.unit - EnetDatagram.header - Math.max(this.overhead, 4)
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
return (
|
|
808
|
+
this.unit -
|
|
809
|
+
EnetDatagram.header -
|
|
810
|
+
(this.checked ? EnetDatagram.checksum : 0)
|
|
811
|
+
)
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Most payload bytes one command may carry
|
|
816
|
+
*/
|
|
817
|
+
private get piece(): number {
|
|
818
|
+
if (this.seal !== null) return this.budget - Command.piece
|
|
819
|
+
|
|
820
|
+
return this.unit - EnetDatagram.header - Command.piece - 4
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* This end's timestamp for a clock reading
|
|
825
|
+
* @param now clock reading in ms
|
|
826
|
+
*/
|
|
827
|
+
private stamp(now: number): number {
|
|
828
|
+
return (now - this.origin) | 0
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Sequence number offset of a channel
|
|
833
|
+
* @param index position of the channel, control channel last
|
|
834
|
+
*/
|
|
835
|
+
private offset(index: number): number {
|
|
836
|
+
const offsets = this.offsets
|
|
837
|
+
if (offsets === null || offsets.length === 0) return 0
|
|
838
|
+
|
|
839
|
+
return offsets[index % offsets.length] ?? 0
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* State of a data channel
|
|
844
|
+
* @param channel channel number
|
|
845
|
+
*/
|
|
846
|
+
private lane(channel: number): EnetLane {
|
|
847
|
+
const existing = this.lanes.get(channel)
|
|
848
|
+
if (existing !== undefined) return existing
|
|
849
|
+
|
|
850
|
+
const lane = new EnetLane(channel)
|
|
851
|
+
if (this.offsets !== null) lane.shift(this.offset(channel), this.absolute)
|
|
852
|
+
|
|
853
|
+
this.lanes.set(channel, lane)
|
|
854
|
+
this.order.push(lane)
|
|
855
|
+
this.order.sort(
|
|
856
|
+
(left: EnetLane, right: EnetLane): number => left.id - right.id,
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
return lane
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* A command for the control channel
|
|
864
|
+
* @param type what kind of command it is
|
|
865
|
+
* @param flags reliable and unsequenced bits
|
|
866
|
+
* @param payload its body
|
|
867
|
+
* @param reserved disconnect reason, or filler
|
|
868
|
+
*/
|
|
869
|
+
private steer(
|
|
870
|
+
type: number,
|
|
871
|
+
flags: number,
|
|
872
|
+
payload: Uint8Array = new Uint8Array(0),
|
|
873
|
+
reserved: number = this.filler,
|
|
874
|
+
): Command {
|
|
875
|
+
const control = this.control
|
|
876
|
+
if ((flags & CommandFlag.UNSEQUENCED) === 0) control.sent += 1
|
|
877
|
+
else control.loose += 1
|
|
878
|
+
|
|
879
|
+
return Command.of(
|
|
880
|
+
type,
|
|
881
|
+
Command.control,
|
|
882
|
+
flags,
|
|
883
|
+
reserved,
|
|
884
|
+
(flags & CommandFlag.UNSEQUENCED) === 0 ? control.sent : control.loose,
|
|
885
|
+
[],
|
|
886
|
+
payload,
|
|
887
|
+
)
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Cuts a large message into fragments and queues them
|
|
892
|
+
* @param lane channel the message travels on
|
|
893
|
+
* @param payload the message
|
|
894
|
+
* @param delivery how it was meant to be delivered
|
|
895
|
+
*/
|
|
896
|
+
private split(lane: EnetLane, payload: Uint8Array, delivery: number): void {
|
|
897
|
+
const loose =
|
|
898
|
+
delivery === Delivery.UNSEQUENCED ||
|
|
899
|
+
delivery === Delivery.RELIABLE_UNSEQUENCED
|
|
900
|
+
const size = this.piece
|
|
901
|
+
const count = Math.ceil(payload.length / size)
|
|
902
|
+
const start = (loose ? lane.loose : lane.sent) + 1
|
|
903
|
+
|
|
904
|
+
for (let index = 0; index < count; index += 1) {
|
|
905
|
+
if (loose) lane.loose += 1
|
|
906
|
+
else lane.sent += 1
|
|
907
|
+
|
|
908
|
+
this.enqueue(
|
|
909
|
+
lane,
|
|
910
|
+
Command.of(
|
|
911
|
+
loose ? CommandType.LOOSE_FRAGMENT : CommandType.FRAGMENT,
|
|
912
|
+
lane.id,
|
|
913
|
+
loose
|
|
914
|
+
? CommandFlag.RELIABLE | CommandFlag.UNSEQUENCED
|
|
915
|
+
: CommandFlag.RELIABLE,
|
|
916
|
+
this.filler,
|
|
917
|
+
start + index,
|
|
918
|
+
[start, count, index, payload.length, index * size],
|
|
919
|
+
payload.subarray(index * size, (index + 1) * size),
|
|
920
|
+
),
|
|
921
|
+
)
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Puts a command in its channel's queue
|
|
927
|
+
* @param lane channel the command travels on
|
|
928
|
+
* @param command what to send
|
|
929
|
+
*/
|
|
930
|
+
private enqueue(lane: EnetLane, command: Command): void {
|
|
931
|
+
if (command.reliable) lane.reliables.push(command)
|
|
932
|
+
else lane.unreliables.push(command)
|
|
933
|
+
|
|
934
|
+
this.queued += 1
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* The datagram to work with, or null
|
|
939
|
+
* @param datagram what arrived
|
|
940
|
+
*/
|
|
941
|
+
private unwrap(datagram: EnetDatagram): EnetDatagram | null {
|
|
942
|
+
if (this.state === PeerState.IDLE || this.state === PeerState.CLOSED) {
|
|
943
|
+
return null
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
if (datagram.challenge !== this.token) return null
|
|
947
|
+
if (!this.client && !this.owns(datagram.peer)) return null
|
|
948
|
+
|
|
949
|
+
this.named = datagram.peer === this.assigned
|
|
950
|
+
|
|
951
|
+
if (datagram.flags === EnetDatagram.sealed) {
|
|
952
|
+
const opened =
|
|
953
|
+
this.seal === null ? null : EnetDatagram.open(datagram, this.seal)
|
|
954
|
+
if (opened === null) return null
|
|
955
|
+
|
|
956
|
+
this.sealed = true
|
|
957
|
+
this.sealing = true
|
|
958
|
+
return opened
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (this.sealed) return null
|
|
962
|
+
if (!this.client && datagram.flags === EnetDatagram.checked) {
|
|
963
|
+
this.checked = true
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
return datagram
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Whether a client may put this peer id in its datagrams
|
|
971
|
+
* @param peer id from a datagram header
|
|
972
|
+
*/
|
|
973
|
+
private owns(peer: number): boolean {
|
|
974
|
+
return peer === this.assigned || peer === -1 || peer === -2
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Acts on one command
|
|
979
|
+
* @param command what arrived
|
|
980
|
+
* @param time header time of its datagram
|
|
981
|
+
* @param now clock reading in ms
|
|
982
|
+
*/
|
|
983
|
+
private handle(command: Command, time: number, now: number): void {
|
|
984
|
+
switch (command.type) {
|
|
985
|
+
case CommandType.ACK:
|
|
986
|
+
case CommandType.LOOSE_ACK:
|
|
987
|
+
this.acknowledge(command, time, now)
|
|
988
|
+
return
|
|
989
|
+
case CommandType.DISCONNECT:
|
|
990
|
+
this.depart(command, time, now)
|
|
991
|
+
return
|
|
992
|
+
case CommandType.RELIABLE:
|
|
993
|
+
case CommandType.UNRELIABLE:
|
|
994
|
+
case CommandType.FRAGMENT:
|
|
995
|
+
case CommandType.UNSEQUENCED:
|
|
996
|
+
case CommandType.LOOSE:
|
|
997
|
+
case CommandType.LOOSE_FRAGMENT:
|
|
998
|
+
this.take(command, time, now)
|
|
999
|
+
return
|
|
1000
|
+
case CommandType.CONNECT:
|
|
1001
|
+
this.greet()
|
|
1002
|
+
break
|
|
1003
|
+
case CommandType.VERIFY:
|
|
1004
|
+
this.verify(command)
|
|
1005
|
+
break
|
|
1006
|
+
case CommandType.TIME:
|
|
1007
|
+
this.urgent = true
|
|
1008
|
+
break
|
|
1009
|
+
default:
|
|
1010
|
+
break
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
this.confirm(command, time, now)
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Queues the ack a reliable command asks for
|
|
1018
|
+
* @param command what arrived
|
|
1019
|
+
* @param time header time of its datagram
|
|
1020
|
+
* @param now clock reading in ms
|
|
1021
|
+
*/
|
|
1022
|
+
private confirm(command: Command, time: number, now: number): void {
|
|
1023
|
+
if (!command.reliable) return
|
|
1024
|
+
|
|
1025
|
+
this.acks.push(Command.ack(command, time, this.filler))
|
|
1026
|
+
this.wake(now + this.settings.ackDelay)
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Answers a connect with a verify connect
|
|
1031
|
+
*/
|
|
1032
|
+
private greet(): void {
|
|
1033
|
+
if (this.client || this.greeted) return
|
|
1034
|
+
|
|
1035
|
+
const body = ByteBuf.wrap(new Uint8Array(EnetPeer.greeting))
|
|
1036
|
+
.setInt16(0, this.assigned)
|
|
1037
|
+
.setUint16(2, this.unit)
|
|
1038
|
+
.setUint32(4, 0x8000)
|
|
1039
|
+
.setUint32(8, this.count)
|
|
1040
|
+
.setUint32(20, 5000)
|
|
1041
|
+
.setUint32(24, 2)
|
|
1042
|
+
.setUint32(28, 2)
|
|
1043
|
+
|
|
1044
|
+
this.greeted = true
|
|
1045
|
+
this.urgent = true
|
|
1046
|
+
this.state = PeerState.CONNECTED
|
|
1047
|
+
this.enqueue(
|
|
1048
|
+
this.control,
|
|
1049
|
+
this.steer(CommandType.VERIFY, CommandFlag.RELIABLE, body.array),
|
|
1050
|
+
)
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Learns the peer id from the server's verify connect
|
|
1055
|
+
* @param command what arrived
|
|
1056
|
+
*/
|
|
1057
|
+
private verify(command: Command): void {
|
|
1058
|
+
if (!this.client || this.state !== PeerState.CONNECTING) return
|
|
1059
|
+
if (command.payload.length < 2) return
|
|
1060
|
+
|
|
1061
|
+
this.assigned = ByteBuf.wrap(command.payload).getInt16(0)
|
|
1062
|
+
this.tag = this.assigned
|
|
1063
|
+
this.state = PeerState.CONNECTED
|
|
1064
|
+
this.urgent = true
|
|
1065
|
+
this.hooks.established()
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Takes a command that carries a message
|
|
1070
|
+
* @param command what arrived
|
|
1071
|
+
* @param time header time of its datagram
|
|
1072
|
+
* @param now clock reading in ms
|
|
1073
|
+
*/
|
|
1074
|
+
private take(command: Command, time: number, now: number): void {
|
|
1075
|
+
if (this.state !== PeerState.CONNECTED) {
|
|
1076
|
+
this.confirm(command, time, now)
|
|
1077
|
+
return
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
if (command.channel >= this.count) return
|
|
1081
|
+
if (this.guarded && !this.heeded) return
|
|
1082
|
+
|
|
1083
|
+
const lane = this.lane(command.channel)
|
|
1084
|
+
const before = lane.weight
|
|
1085
|
+
const admission = this.admit(lane, command)
|
|
1086
|
+
this.buffered += lane.weight - before
|
|
1087
|
+
|
|
1088
|
+
if (admission === Admission.REFUSED) return
|
|
1089
|
+
if (
|
|
1090
|
+
admission === Admission.BROKEN ||
|
|
1091
|
+
this.buffered > this.settings.maxBuffered
|
|
1092
|
+
) {
|
|
1093
|
+
this.abort(DisconnectReason.LOGIC)
|
|
1094
|
+
return
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
this.confirm(command, time, now)
|
|
1098
|
+
|
|
1099
|
+
for (const frame of lane.collect()) {
|
|
1100
|
+
this.hooks.deliver(frame)
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Runs a message command through its channel's rules
|
|
1106
|
+
* @param lane channel the command came on
|
|
1107
|
+
* @param command what arrived
|
|
1108
|
+
*/
|
|
1109
|
+
private admit(lane: EnetLane, command: Command): AdmissionCode {
|
|
1110
|
+
const settings = this.settings
|
|
1111
|
+
|
|
1112
|
+
switch (command.type) {
|
|
1113
|
+
case CommandType.RELIABLE:
|
|
1114
|
+
case CommandType.FRAGMENT:
|
|
1115
|
+
return lane.order(command, settings.window, settings.maxMessageSize)
|
|
1116
|
+
case CommandType.LOOSE:
|
|
1117
|
+
case CommandType.LOOSE_FRAGMENT:
|
|
1118
|
+
return lane.scatter(command, settings.window, settings.maxMessageSize)
|
|
1119
|
+
case CommandType.UNRELIABLE:
|
|
1120
|
+
lane.follow(command, settings.window)
|
|
1121
|
+
return Admission.FRESH
|
|
1122
|
+
default:
|
|
1123
|
+
if (this.groups.admit(command.word(0))) {
|
|
1124
|
+
this.hooks.deliver(
|
|
1125
|
+
Frame.of(command.payload, Delivery.UNSEQUENCED, lane.id),
|
|
1126
|
+
)
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
return Admission.FRESH
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Clears the command an ack is for and learns from its timing
|
|
1135
|
+
* @param command the ack
|
|
1136
|
+
* @param time header time of its datagram
|
|
1137
|
+
* @param now clock reading in ms
|
|
1138
|
+
*/
|
|
1139
|
+
private acknowledge(command: Command, time: number, now: number): void {
|
|
1140
|
+
const key = Flight.key(
|
|
1141
|
+
command.channel,
|
|
1142
|
+
command.type === CommandType.LOOSE_ACK,
|
|
1143
|
+
command.word(0),
|
|
1144
|
+
)
|
|
1145
|
+
const flight = this.flights.get(key)
|
|
1146
|
+
|
|
1147
|
+
this.heard = now
|
|
1148
|
+
this.wake(now + this.settings.pingInterval)
|
|
1149
|
+
if (flight === undefined) return
|
|
1150
|
+
|
|
1151
|
+
const lane =
|
|
1152
|
+
command.channel === Command.control
|
|
1153
|
+
? this.control
|
|
1154
|
+
: this.lanes.get(command.channel)
|
|
1155
|
+
if (lane !== undefined) lane.flying -= 1
|
|
1156
|
+
|
|
1157
|
+
this.flights.delete(key)
|
|
1158
|
+
this.transit -= flight.command.size
|
|
1159
|
+
if (this.queued > 0 || this.state === PeerState.LEAVING) this.urgent = true
|
|
1160
|
+
|
|
1161
|
+
const elapsed = (this.stamp(now) - command.word(1)) | 0
|
|
1162
|
+
const sample =
|
|
1163
|
+
elapsed < 0 || elapsed > EnetPeer.ceiling ? this.round * 4 : elapsed
|
|
1164
|
+
|
|
1165
|
+
switch (flight.command.type) {
|
|
1166
|
+
case CommandType.TIME:
|
|
1167
|
+
this.align(sample, time, now)
|
|
1168
|
+
return
|
|
1169
|
+
case CommandType.DISCONNECT:
|
|
1170
|
+
this.finish(EnetClosure.local(flight.command.reserved))
|
|
1171
|
+
return
|
|
1172
|
+
case CommandType.CONNECT:
|
|
1173
|
+
case CommandType.VERIFY:
|
|
1174
|
+
this.measure(sample)
|
|
1175
|
+
this.round = Math.max(sample, EnetPeer.floor)
|
|
1176
|
+
if (sample <= EnetPeer.floor) this.variance = 5
|
|
1177
|
+
this.heed()
|
|
1178
|
+
return
|
|
1179
|
+
default:
|
|
1180
|
+
this.measure(sample)
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Notes that the client acked the verify connect under its given id
|
|
1186
|
+
*/
|
|
1187
|
+
private heed(): void {
|
|
1188
|
+
if (this.client || this.heeded || !this.named) return
|
|
1189
|
+
|
|
1190
|
+
this.heeded = true
|
|
1191
|
+
if (this.guarded) this.hooks.established()
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Folds a round trip sample into the average
|
|
1196
|
+
* @param sample round trip in ms
|
|
1197
|
+
*/
|
|
1198
|
+
private measure(sample: number): void {
|
|
1199
|
+
const above = sample >= this.round
|
|
1200
|
+
|
|
1201
|
+
this.variance -= Math.trunc(this.variance / 4)
|
|
1202
|
+
this.round += Math.trunc((sample - this.round) / 8)
|
|
1203
|
+
|
|
1204
|
+
const drift = Math.trunc((sample - this.round) / 4)
|
|
1205
|
+
this.variance += above ? drift : -drift
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Works out the server's clock from the ack of a time request
|
|
1210
|
+
* @param sample round trip in ms
|
|
1211
|
+
* @param time header time of the ack's datagram
|
|
1212
|
+
* @param now clock reading in ms
|
|
1213
|
+
*/
|
|
1214
|
+
private align(sample: number, time: number, now: number): void {
|
|
1215
|
+
if (sample > this.round) {
|
|
1216
|
+
this.enqueue(
|
|
1217
|
+
this.control,
|
|
1218
|
+
this.steer(CommandType.TIME, CommandFlag.RELIABLE),
|
|
1219
|
+
)
|
|
1220
|
+
this.urgent = true
|
|
1221
|
+
return
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
this.skew = (time + (sample >> 1) - this.stamp(now)) | 0
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* Ends the connection at the other end's request
|
|
1229
|
+
* @param command the disconnect
|
|
1230
|
+
* @param time header time of its datagram
|
|
1231
|
+
* @param now clock reading in ms
|
|
1232
|
+
*/
|
|
1233
|
+
private depart(command: Command, time: number, now: number): void {
|
|
1234
|
+
if (command.reliable) {
|
|
1235
|
+
this.acks.push(Command.ack(command, time, this.filler))
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
this.fill(now, [])
|
|
1239
|
+
|
|
1240
|
+
if (this.client) {
|
|
1241
|
+
const flags =
|
|
1242
|
+
this.state === PeerState.CONNECTED
|
|
1243
|
+
? CommandFlag.RELIABLE
|
|
1244
|
+
: CommandFlag.UNSEQUENCED
|
|
1245
|
+
this.load(this.steer(CommandType.DISCONNECT, flags), now)
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
this.emit(now)
|
|
1249
|
+
this.finish(EnetClosure.remote(command.reserved))
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* Resends, pings and sends whatever is due
|
|
1254
|
+
* @param now clock reading in ms
|
|
1255
|
+
*/
|
|
1256
|
+
private service(now: number): void {
|
|
1257
|
+
if (this.state === PeerState.IDLE || this.state === PeerState.CLOSED) {
|
|
1258
|
+
return
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
if (this.timer !== null) clearTimeout(this.timer)
|
|
1262
|
+
this.timer = null
|
|
1263
|
+
this.due = Infinity
|
|
1264
|
+
this.urgent = false
|
|
1265
|
+
|
|
1266
|
+
const late = this.overdue(now)
|
|
1267
|
+
if (late === null) {
|
|
1268
|
+
this.abort(DisconnectReason.TIMEOUT)
|
|
1269
|
+
return
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
this.idle(now)
|
|
1273
|
+
this.fill(now, late)
|
|
1274
|
+
this.emit(now)
|
|
1275
|
+
this.wake(this.next())
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Commands whose ack is late, or null
|
|
1280
|
+
* @param now clock reading in ms
|
|
1281
|
+
*/
|
|
1282
|
+
private overdue(now: number): Flight[] | null {
|
|
1283
|
+
const settings = this.settings
|
|
1284
|
+
const late: Flight[] = []
|
|
1285
|
+
|
|
1286
|
+
for (const flight of this.flights.values()) {
|
|
1287
|
+
if (now < flight.last + flight.wait) continue
|
|
1288
|
+
|
|
1289
|
+
const silence = now - flight.first
|
|
1290
|
+
if (silence >= settings.maximumTimeout) return null
|
|
1291
|
+
if (flight.wait >= flight.limit && silence >= settings.minimumTimeout) {
|
|
1292
|
+
return null
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
flight.wait *= 2
|
|
1296
|
+
late.push(flight)
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
return late
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Queues a ping or the closing disconnect
|
|
1304
|
+
* @param now clock reading in ms
|
|
1305
|
+
*/
|
|
1306
|
+
private idle(now: number): void {
|
|
1307
|
+
if (this.flights.size > 0 || this.queued > 0) return
|
|
1308
|
+
|
|
1309
|
+
if (this.state === PeerState.LEAVING && !this.parted) {
|
|
1310
|
+
const reason = this.ending?.reason ?? DisconnectReason.LOGIC
|
|
1311
|
+
this.parted = true
|
|
1312
|
+
this.enqueue(
|
|
1313
|
+
this.control,
|
|
1314
|
+
this.steer(
|
|
1315
|
+
CommandType.DISCONNECT,
|
|
1316
|
+
CommandFlag.RELIABLE,
|
|
1317
|
+
undefined,
|
|
1318
|
+
reason,
|
|
1319
|
+
),
|
|
1320
|
+
)
|
|
1321
|
+
return
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
if (this.state !== PeerState.CONNECTED) return
|
|
1325
|
+
if (now - this.heard < this.settings.pingInterval) return
|
|
1326
|
+
|
|
1327
|
+
this.enqueue(
|
|
1328
|
+
this.control,
|
|
1329
|
+
this.steer(CommandType.PING, CommandFlag.RELIABLE),
|
|
1330
|
+
)
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Loads acks, resends and queued commands into datagrams
|
|
1335
|
+
* @param now clock reading in ms
|
|
1336
|
+
* @param late commands to send again
|
|
1337
|
+
*/
|
|
1338
|
+
private fill(now: number, late: readonly Flight[]): void {
|
|
1339
|
+
const acks = this.acks
|
|
1340
|
+
this.acks = []
|
|
1341
|
+
|
|
1342
|
+
for (const ack of acks) {
|
|
1343
|
+
this.load(ack, now)
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
for (const flight of late) {
|
|
1347
|
+
flight.last = now
|
|
1348
|
+
this.load(flight.command, now)
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
for (const lane of this.order) {
|
|
1352
|
+
this.drain(lane, now)
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
this.drain(this.control, now)
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Loads what one channel has queued
|
|
1360
|
+
* @param lane the channel
|
|
1361
|
+
* @param now clock reading in ms
|
|
1362
|
+
*/
|
|
1363
|
+
private drain(lane: EnetLane, now: number): void {
|
|
1364
|
+
const settings = this.settings
|
|
1365
|
+
const wait = Math.max(
|
|
1366
|
+
settings.resendTimeout,
|
|
1367
|
+
this.round + 4 * this.variance,
|
|
1368
|
+
)
|
|
1369
|
+
|
|
1370
|
+
while (lane === this.control || this.roomy(lane)) {
|
|
1371
|
+
const command = lane.reliables.shift()
|
|
1372
|
+
if (command === undefined) break
|
|
1373
|
+
|
|
1374
|
+
const flight = Flight.of(command, now, wait, wait * settings.resendLimit)
|
|
1375
|
+
this.flights.set(flight.key, flight)
|
|
1376
|
+
this.transit += command.size
|
|
1377
|
+
this.queued -= 1
|
|
1378
|
+
lane.flying += 1
|
|
1379
|
+
this.load(command, now)
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
for (const command of lane.unreliables) {
|
|
1383
|
+
this.load(command, now)
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
this.queued -= lane.unreliables.length
|
|
1387
|
+
lane.unreliables.length = 0
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Whether the wire has room for another reliable command of a channel
|
|
1392
|
+
* @param lane the channel
|
|
1393
|
+
*/
|
|
1394
|
+
private roomy(lane: EnetLane): boolean {
|
|
1395
|
+
const settings = this.settings
|
|
1396
|
+
|
|
1397
|
+
return (
|
|
1398
|
+
this.transit < settings.maxInTransit && lane.flying < settings.sendWindow
|
|
1399
|
+
)
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Adds a command to the datagram being built
|
|
1404
|
+
* @param command what to add
|
|
1405
|
+
* @param now clock reading in ms
|
|
1406
|
+
*/
|
|
1407
|
+
private load(command: Command, now: number): void {
|
|
1408
|
+
const full =
|
|
1409
|
+
this.filled + command.size > this.budget ||
|
|
1410
|
+
this.batch.length >= EnetDatagram.limit
|
|
1411
|
+
if (full) this.emit(now)
|
|
1412
|
+
|
|
1413
|
+
this.batch.push(command)
|
|
1414
|
+
this.filled += command.size
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* Sends the datagram being built
|
|
1419
|
+
* @param now clock reading in ms
|
|
1420
|
+
*/
|
|
1421
|
+
private emit(now: number): void {
|
|
1422
|
+
const batch = this.batch
|
|
1423
|
+
if (batch.length === 0) return
|
|
1424
|
+
|
|
1425
|
+
this.batch = []
|
|
1426
|
+
this.filled = 0
|
|
1427
|
+
this.hooks.transmit(
|
|
1428
|
+
this.sealing && this.seal !== null
|
|
1429
|
+
? EnetDatagram.seal(
|
|
1430
|
+
this.tag,
|
|
1431
|
+
this.token,
|
|
1432
|
+
this.stamp(now),
|
|
1433
|
+
batch,
|
|
1434
|
+
this.seal,
|
|
1435
|
+
)
|
|
1436
|
+
: EnetDatagram.plain(
|
|
1437
|
+
this.tag,
|
|
1438
|
+
this.token,
|
|
1439
|
+
this.stamp(now),
|
|
1440
|
+
batch,
|
|
1441
|
+
this.checked,
|
|
1442
|
+
),
|
|
1443
|
+
)
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Time of the next resend or ping in ms
|
|
1448
|
+
*/
|
|
1449
|
+
private next(): number {
|
|
1450
|
+
let next = Infinity
|
|
1451
|
+
for (const flight of this.flights.values()) {
|
|
1452
|
+
next = Math.min(next, flight.last + flight.wait)
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (this.state === PeerState.CONNECTED && this.flights.size === 0) {
|
|
1456
|
+
next = Math.min(next, this.heard + this.settings.pingInterval)
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
return next
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Makes sure the peer is serviced by a given time
|
|
1464
|
+
* @param at clock reading in ms
|
|
1465
|
+
*/
|
|
1466
|
+
private wake(at: number): void {
|
|
1467
|
+
if (this.state === PeerState.CLOSED || at >= this.due) return
|
|
1468
|
+
if (this.timer !== null) clearTimeout(this.timer)
|
|
1469
|
+
|
|
1470
|
+
const wait = at - this.settings.clock()
|
|
1471
|
+
|
|
1472
|
+
this.due = at
|
|
1473
|
+
if (wait > 0) {
|
|
1474
|
+
this.timer = setTimeout(this.tick, wait)
|
|
1475
|
+
this.timer.unref()
|
|
1476
|
+
return
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
this.timer = null
|
|
1480
|
+
if (this.listed) return
|
|
1481
|
+
|
|
1482
|
+
this.listed = true
|
|
1483
|
+
EnetPeer.ready.push(this)
|
|
1484
|
+
if (EnetPeer.roused) return
|
|
1485
|
+
|
|
1486
|
+
EnetPeer.roused = true
|
|
1487
|
+
setImmediate((): void => {
|
|
1488
|
+
EnetPeer.rouse()
|
|
1489
|
+
})
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Services every peer with something due this turn
|
|
1494
|
+
*/
|
|
1495
|
+
private static rouse(): void {
|
|
1496
|
+
const ready = EnetPeer.ready.splice(0)
|
|
1497
|
+
EnetPeer.roused = false
|
|
1498
|
+
|
|
1499
|
+
for (const peer of ready) {
|
|
1500
|
+
peer.listed = false
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
for (const peer of ready) {
|
|
1504
|
+
const now = peer.settings.clock()
|
|
1505
|
+
if (peer.due <= now) peer.service(now)
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Stops everything and tells the owner
|
|
1511
|
+
* @param closure how the connection ended
|
|
1512
|
+
*/
|
|
1513
|
+
private finish(closure: EnetClosure): void {
|
|
1514
|
+
if (this.state === PeerState.CLOSED) return
|
|
1515
|
+
if (this.timer !== null) clearTimeout(this.timer)
|
|
1516
|
+
|
|
1517
|
+
this.state = PeerState.CLOSED
|
|
1518
|
+
this.ending ??= closure
|
|
1519
|
+
this.timer = null
|
|
1520
|
+
this.acks = []
|
|
1521
|
+
this.batch = []
|
|
1522
|
+
this.order = []
|
|
1523
|
+
this.lanes.clear()
|
|
1524
|
+
this.flights.clear()
|
|
1525
|
+
this.hooks.closed()
|
|
1526
|
+
}
|
|
1527
|
+
}
|