@netifyjs/protocol 0.0.0-stage → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +38 -2
- package/package.json +56 -4
- package/src/codec/index.ts +193 -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 +59 -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 +117 -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 +362 -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 +456 -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 +161 -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 +175 -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/courier/index.ts +703 -0
- package/src/scale/datagram/index.ts +337 -0
- package/src/scale/fanout/index.ts +653 -0
- package/src/scale/handoff/index.ts +271 -0
- package/src/scale/hosted/index.ts +62 -0
- package/src/scale/index.ts +36 -0
- package/src/scale/layout/index.ts +29 -0
- package/src/scale/mesh/index.ts +211 -0
- package/src/scale/outlet/index.ts +58 -0
- package/src/scale/placement/index.ts +89 -0
- package/src/scale/portable/index.ts +42 -0
- package/src/scale/relay/index.ts +125 -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 +677 -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,1428 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ByteBuf,
|
|
3
|
+
DecoderError,
|
|
4
|
+
EncoderError,
|
|
5
|
+
type Endian,
|
|
6
|
+
} from '@netifyjs/netify'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
BinaryProtocolAdapter,
|
|
10
|
+
type DictionaryHeader,
|
|
11
|
+
} from '../adapter/index.ts'
|
|
12
|
+
import type { PhotonDictionary } from '../dictionary/index.ts'
|
|
13
|
+
import { NameTable } from '../../../names/index.ts'
|
|
14
|
+
import { PhotonHashtable } from '../hashtable/index.ts'
|
|
15
|
+
import { Kind } from '../kind/index.ts'
|
|
16
|
+
import { Shape } from '../shape/index.ts'
|
|
17
|
+
import { type PhotonData, PhotonValue } from '../value/index.ts'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Type codes of protocol 1.8
|
|
21
|
+
*/
|
|
22
|
+
const Code = {
|
|
23
|
+
/**
|
|
24
|
+
* Object in a dictionary header
|
|
25
|
+
*/
|
|
26
|
+
UNKNOWN: 0,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Bool with a payload byte
|
|
30
|
+
*/
|
|
31
|
+
BOOLEAN: 2,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Byte
|
|
35
|
+
*/
|
|
36
|
+
BYTE: 3,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Short
|
|
40
|
+
*/
|
|
41
|
+
SHORT: 4,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Float
|
|
45
|
+
*/
|
|
46
|
+
FLOAT: 5,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Double
|
|
50
|
+
*/
|
|
51
|
+
DOUBLE: 6,
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* String
|
|
55
|
+
*/
|
|
56
|
+
STRING: 7,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Null
|
|
60
|
+
*/
|
|
61
|
+
NULL: 8,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Int as a zigzag varint
|
|
65
|
+
*/
|
|
66
|
+
COMPRESSED_INT: 9,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Long as a zigzag varint
|
|
70
|
+
*/
|
|
71
|
+
COMPRESSED_LONG: 10,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Int from 1 to 255
|
|
75
|
+
*/
|
|
76
|
+
INT1: 11,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Int from -255 to -1
|
|
80
|
+
*/
|
|
81
|
+
INT1_NEGATIVE: 12,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Int from 256 to 65535
|
|
85
|
+
*/
|
|
86
|
+
INT2: 13,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Int from -65535 to -256
|
|
90
|
+
*/
|
|
91
|
+
INT2_NEGATIVE: 14,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Long from 1 to 255
|
|
95
|
+
*/
|
|
96
|
+
LONG1: 15,
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Long from -255 to -1
|
|
100
|
+
*/
|
|
101
|
+
LONG1_NEGATIVE: 16,
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Long from 256 to 65535
|
|
105
|
+
*/
|
|
106
|
+
LONG2: 17,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Long from -65535 to -256
|
|
110
|
+
*/
|
|
111
|
+
LONG2_NEGATIVE: 18,
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Custom type with its code in the next byte
|
|
115
|
+
*/
|
|
116
|
+
CUSTOM: 19,
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Dictionary
|
|
120
|
+
*/
|
|
121
|
+
DICTIONARY: 20,
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Hashtable
|
|
125
|
+
*/
|
|
126
|
+
HASHTABLE: 21,
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Object array
|
|
130
|
+
*/
|
|
131
|
+
OBJECT_ARRAY: 23,
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Operation request
|
|
135
|
+
*/
|
|
136
|
+
REQUEST: 24,
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Operation response
|
|
140
|
+
*/
|
|
141
|
+
RESPONSE: 25,
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Event
|
|
145
|
+
*/
|
|
146
|
+
EVENT: 26,
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Bool false
|
|
150
|
+
*/
|
|
151
|
+
BOOLEAN_FALSE: 27,
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Bool true
|
|
155
|
+
*/
|
|
156
|
+
BOOLEAN_TRUE: 28,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Short zero
|
|
160
|
+
*/
|
|
161
|
+
SHORT_ZERO: 29,
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Int zero
|
|
165
|
+
*/
|
|
166
|
+
INT_ZERO: 30,
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Long zero
|
|
170
|
+
*/
|
|
171
|
+
LONG_ZERO: 31,
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Float zero
|
|
175
|
+
*/
|
|
176
|
+
FLOAT_ZERO: 32,
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Double zero
|
|
180
|
+
*/
|
|
181
|
+
DOUBLE_ZERO: 33,
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Byte zero
|
|
185
|
+
*/
|
|
186
|
+
BYTE_ZERO: 34,
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Array of arrays
|
|
190
|
+
*/
|
|
191
|
+
ARRAY: 64,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Bool array
|
|
195
|
+
*/
|
|
196
|
+
BOOLEAN_ARRAY: 66,
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Byte array
|
|
200
|
+
*/
|
|
201
|
+
BYTE_ARRAY: 67,
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Short array
|
|
205
|
+
*/
|
|
206
|
+
SHORT_ARRAY: 68,
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Float array
|
|
210
|
+
*/
|
|
211
|
+
FLOAT_ARRAY: 69,
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Double array
|
|
215
|
+
*/
|
|
216
|
+
DOUBLE_ARRAY: 70,
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* String array
|
|
220
|
+
*/
|
|
221
|
+
STRING_ARRAY: 71,
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Int array
|
|
225
|
+
*/
|
|
226
|
+
COMPRESSED_INT_ARRAY: 73,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Long array
|
|
230
|
+
*/
|
|
231
|
+
COMPRESSED_LONG_ARRAY: 74,
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Array of one custom type
|
|
235
|
+
*/
|
|
236
|
+
CUSTOM_ARRAY: 83,
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Array of dictionaries
|
|
240
|
+
*/
|
|
241
|
+
DICTIONARY_ARRAY: 84,
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Array of hashtables
|
|
245
|
+
*/
|
|
246
|
+
HASHTABLE_ARRAY: 85,
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* First type byte of a custom type with a code up to 100
|
|
250
|
+
*/
|
|
251
|
+
CUSTOM_SLIM: 128,
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Last type byte of a custom type with a code up to 100
|
|
255
|
+
*/
|
|
256
|
+
CUSTOM_SLIM_LAST: 228,
|
|
257
|
+
} as const
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* GpBinary 1.8, the compact protocol PUN 2 clients speak
|
|
261
|
+
* @class
|
|
262
|
+
*/
|
|
263
|
+
export class Protocol18 extends BinaryProtocolAdapter {
|
|
264
|
+
/**
|
|
265
|
+
* Custom type codes below this go out in the slim form
|
|
266
|
+
*/
|
|
267
|
+
private static readonly slimLimit: number = 100
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Largest magnitude the 2 byte int and long forms carry
|
|
271
|
+
*/
|
|
272
|
+
private static readonly smallLimit: number = 65_535
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Name the client libraries know the protocol by
|
|
276
|
+
*/
|
|
277
|
+
public readonly name: string
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Major and minor version bytes
|
|
281
|
+
*/
|
|
282
|
+
public readonly version: readonly [major: number, minor: number]
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Byte order of a return code
|
|
286
|
+
*/
|
|
287
|
+
protected readonly endian: Endian
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Short strings read before
|
|
291
|
+
*/
|
|
292
|
+
private readonly names: NameTable
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Sets the protocol's fixed properties
|
|
296
|
+
*/
|
|
297
|
+
public constructor() {
|
|
298
|
+
super()
|
|
299
|
+
|
|
300
|
+
this.names = new NameTable()
|
|
301
|
+
this.name = 'GpBinaryV18'
|
|
302
|
+
this.version = [1, 8]
|
|
303
|
+
this.endian = 'little'
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Reads the 1 byte parameter count
|
|
308
|
+
* @param buffer bytes to read from
|
|
309
|
+
*/
|
|
310
|
+
protected decodeParameterCount(buffer: ByteBuf): number {
|
|
311
|
+
return buffer.readUint8()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Writes the 1 byte parameter count
|
|
316
|
+
* @param count number of parameters
|
|
317
|
+
* @param buffer where it goes
|
|
318
|
+
*/
|
|
319
|
+
protected encodeParameterCount(count: number, buffer: ByteBuf): void {
|
|
320
|
+
if (count > 255) throw new EncoderError('Too many parameters')
|
|
321
|
+
|
|
322
|
+
buffer.writeUint8(count)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Reads a count or length as a compressed unsigned integer
|
|
327
|
+
* @param buffer bytes to read from
|
|
328
|
+
*/
|
|
329
|
+
protected decodeCount(buffer: ByteBuf): number {
|
|
330
|
+
let result = 0
|
|
331
|
+
for (let shift = 0; shift < 35; shift += 7) {
|
|
332
|
+
const byte = buffer.readUint8()
|
|
333
|
+
result |= (byte & 127) << shift
|
|
334
|
+
if (byte < 128) break
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return result >>> 0
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Reads the value a type code announces
|
|
342
|
+
* @param code type code that was read
|
|
343
|
+
* @param buffer bytes to read from
|
|
344
|
+
*/
|
|
345
|
+
protected decodeCoded(code: number, buffer: ByteBuf): PhotonValue {
|
|
346
|
+
if (code >= Code.CUSTOM_SLIM && code <= Code.CUSTOM_SLIM_LAST) {
|
|
347
|
+
return PhotonValue.custom(
|
|
348
|
+
code - Code.CUSTOM_SLIM,
|
|
349
|
+
this.decodeBytes(buffer),
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
switch (code) {
|
|
354
|
+
case Code.NULL:
|
|
355
|
+
return PhotonValue.null()
|
|
356
|
+
case Code.BOOLEAN:
|
|
357
|
+
return PhotonValue.bool(buffer.readUint8() > 0)
|
|
358
|
+
case Code.BOOLEAN_FALSE:
|
|
359
|
+
return PhotonValue.bool(false)
|
|
360
|
+
case Code.BOOLEAN_TRUE:
|
|
361
|
+
return PhotonValue.bool(true)
|
|
362
|
+
case Code.BYTE:
|
|
363
|
+
return PhotonValue.byte(buffer.readUint8())
|
|
364
|
+
case Code.BYTE_ZERO:
|
|
365
|
+
return PhotonValue.byte(0)
|
|
366
|
+
case Code.SHORT:
|
|
367
|
+
return PhotonValue.short(buffer.readInt16('little'))
|
|
368
|
+
case Code.SHORT_ZERO:
|
|
369
|
+
return PhotonValue.short(0)
|
|
370
|
+
case Code.FLOAT:
|
|
371
|
+
return PhotonValue.float(buffer.readFloat32('little'))
|
|
372
|
+
case Code.FLOAT_ZERO:
|
|
373
|
+
return PhotonValue.float(0)
|
|
374
|
+
case Code.DOUBLE:
|
|
375
|
+
return PhotonValue.double(buffer.readFloat64('little'))
|
|
376
|
+
case Code.DOUBLE_ZERO:
|
|
377
|
+
return PhotonValue.double(0)
|
|
378
|
+
case Code.STRING:
|
|
379
|
+
return PhotonValue.string(this.decodeString(buffer))
|
|
380
|
+
case Code.BYTE_ARRAY:
|
|
381
|
+
return PhotonValue.bytes(this.decodeBytes(buffer))
|
|
382
|
+
case Code.CUSTOM:
|
|
383
|
+
return PhotonValue.custom(buffer.readUint8(), this.decodeBytes(buffer))
|
|
384
|
+
default:
|
|
385
|
+
return this.decodeNumber(code, buffer)
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Writes a value with its type code
|
|
391
|
+
* @param value what to write
|
|
392
|
+
* @param buffer where it goes
|
|
393
|
+
*/
|
|
394
|
+
protected encodeValue(value: PhotonValue, buffer: ByteBuf): void {
|
|
395
|
+
const data = value.data
|
|
396
|
+
|
|
397
|
+
switch (value.shape.kind) {
|
|
398
|
+
case Kind.NULL:
|
|
399
|
+
buffer.writeUint8(Code.NULL)
|
|
400
|
+
return
|
|
401
|
+
case Kind.BOOL:
|
|
402
|
+
buffer.writeUint8(
|
|
403
|
+
data === true ? Code.BOOLEAN_TRUE : Code.BOOLEAN_FALSE,
|
|
404
|
+
)
|
|
405
|
+
return
|
|
406
|
+
case Kind.BYTE:
|
|
407
|
+
this.encodeTagged(Code.BYTE, Code.BYTE_ZERO, value, buffer)
|
|
408
|
+
return
|
|
409
|
+
case Kind.SHORT:
|
|
410
|
+
this.encodeTagged(Code.SHORT, Code.SHORT_ZERO, value, buffer)
|
|
411
|
+
return
|
|
412
|
+
case Kind.INT:
|
|
413
|
+
this.encodeInt(data as number, buffer)
|
|
414
|
+
return
|
|
415
|
+
case Kind.LONG:
|
|
416
|
+
this.encodeLong(data as bigint, buffer)
|
|
417
|
+
return
|
|
418
|
+
case Kind.CUSTOM:
|
|
419
|
+
this.encodeCustom(value.shape.code ?? 0, data as Uint8Array, buffer)
|
|
420
|
+
return
|
|
421
|
+
case Kind.ARRAY:
|
|
422
|
+
this.encodeArray(
|
|
423
|
+
value.shape,
|
|
424
|
+
data as readonly PhotonData[],
|
|
425
|
+
true,
|
|
426
|
+
buffer,
|
|
427
|
+
)
|
|
428
|
+
return
|
|
429
|
+
default:
|
|
430
|
+
buffer.writeUint8(this.codeOf(value.shape))
|
|
431
|
+
this.encodeBare(value.shape, data, buffer)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Writes what a value holds, without its type code
|
|
437
|
+
* @param shape the value's type
|
|
438
|
+
* @param data what it holds
|
|
439
|
+
* @param buffer where it goes
|
|
440
|
+
*/
|
|
441
|
+
protected encodeBare(shape: Shape, data: PhotonData, buffer: ByteBuf): void {
|
|
442
|
+
switch (shape.kind) {
|
|
443
|
+
case Kind.ANY:
|
|
444
|
+
this.encodeValue(this.wrap(shape, data), buffer)
|
|
445
|
+
return
|
|
446
|
+
case Kind.NULL:
|
|
447
|
+
return
|
|
448
|
+
case Kind.BOOL:
|
|
449
|
+
buffer.writeUint8(data === true ? 1 : 0)
|
|
450
|
+
return
|
|
451
|
+
case Kind.BYTE:
|
|
452
|
+
buffer.writeUint8(data as number)
|
|
453
|
+
return
|
|
454
|
+
case Kind.SHORT:
|
|
455
|
+
buffer.writeInt16(data as number, 'little')
|
|
456
|
+
return
|
|
457
|
+
case Kind.INT:
|
|
458
|
+
this.encodeCount(this.zigzag(data as number), buffer)
|
|
459
|
+
return
|
|
460
|
+
case Kind.LONG:
|
|
461
|
+
this.encodeWide(this.zigzagWide(data as bigint), buffer)
|
|
462
|
+
return
|
|
463
|
+
case Kind.FLOAT:
|
|
464
|
+
buffer.writeFloat32(data as number, 'little')
|
|
465
|
+
return
|
|
466
|
+
case Kind.DOUBLE:
|
|
467
|
+
buffer.writeFloat64(data as number, 'little')
|
|
468
|
+
return
|
|
469
|
+
case Kind.STRING:
|
|
470
|
+
this.encodeString(data as string, buffer)
|
|
471
|
+
return
|
|
472
|
+
case Kind.BYTES:
|
|
473
|
+
this.encodeBytes(data as Uint8Array, buffer)
|
|
474
|
+
return
|
|
475
|
+
case Kind.CUSTOM:
|
|
476
|
+
buffer.writeUint8(shape.code ?? 0)
|
|
477
|
+
this.encodeBytes(data as Uint8Array, buffer)
|
|
478
|
+
return
|
|
479
|
+
default:
|
|
480
|
+
this.encodeNested(shape, data, buffer)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Reads an int, a long or a container
|
|
486
|
+
* @param code type code that was read
|
|
487
|
+
* @param buffer bytes to read from
|
|
488
|
+
*/
|
|
489
|
+
private decodeNumber(code: number, buffer: ByteBuf): PhotonValue {
|
|
490
|
+
switch (code) {
|
|
491
|
+
case Code.INT_ZERO:
|
|
492
|
+
return PhotonValue.int(0)
|
|
493
|
+
case Code.COMPRESSED_INT:
|
|
494
|
+
return PhotonValue.int(this.decodeInt(buffer))
|
|
495
|
+
case Code.INT1:
|
|
496
|
+
return PhotonValue.int(buffer.readUint8())
|
|
497
|
+
case Code.INT1_NEGATIVE:
|
|
498
|
+
return PhotonValue.int(0 - buffer.readUint8())
|
|
499
|
+
case Code.INT2:
|
|
500
|
+
return PhotonValue.int(buffer.readUint16('little'))
|
|
501
|
+
case Code.INT2_NEGATIVE:
|
|
502
|
+
return PhotonValue.int(0 - buffer.readUint16('little'))
|
|
503
|
+
case Code.LONG_ZERO:
|
|
504
|
+
return PhotonValue.long(0)
|
|
505
|
+
case Code.COMPRESSED_LONG:
|
|
506
|
+
return PhotonValue.long(this.decodeLong(buffer))
|
|
507
|
+
case Code.LONG1:
|
|
508
|
+
return PhotonValue.long(buffer.readUint8())
|
|
509
|
+
case Code.LONG1_NEGATIVE:
|
|
510
|
+
return PhotonValue.long(0 - buffer.readUint8())
|
|
511
|
+
case Code.LONG2:
|
|
512
|
+
return PhotonValue.long(buffer.readUint16('little'))
|
|
513
|
+
case Code.LONG2_NEGATIVE:
|
|
514
|
+
return PhotonValue.long(0 - buffer.readUint16('little'))
|
|
515
|
+
case Code.REQUEST:
|
|
516
|
+
return PhotonValue.request(this.decodeRequest(buffer))
|
|
517
|
+
case Code.RESPONSE:
|
|
518
|
+
return PhotonValue.response(this.decodeResponse(buffer))
|
|
519
|
+
case Code.EVENT:
|
|
520
|
+
return PhotonValue.event(this.decodeEvent(buffer))
|
|
521
|
+
default:
|
|
522
|
+
return this.decodeContainer(code, buffer)
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Reads an array, table or dictionary and tracks how deep it sits
|
|
528
|
+
* @param code type code that was read
|
|
529
|
+
* @param buffer bytes to read from
|
|
530
|
+
*/
|
|
531
|
+
private decodeContainer(code: number, buffer: ByteBuf): PhotonValue {
|
|
532
|
+
this.descend()
|
|
533
|
+
|
|
534
|
+
const value = this.decodeNested(code, buffer)
|
|
535
|
+
this.ascend()
|
|
536
|
+
|
|
537
|
+
return value
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Reads the array, table or dictionary a type code announces
|
|
542
|
+
* @param code type code that was read
|
|
543
|
+
* @param buffer bytes to read from
|
|
544
|
+
*/
|
|
545
|
+
private decodeNested(code: number, buffer: ByteBuf): PhotonValue {
|
|
546
|
+
switch (code) {
|
|
547
|
+
case Code.DICTIONARY:
|
|
548
|
+
return PhotonValue.dictionary(
|
|
549
|
+
this.decodeEntries(this.decodeHeader(buffer), buffer),
|
|
550
|
+
)
|
|
551
|
+
case Code.HASHTABLE:
|
|
552
|
+
return PhotonValue.hashtable(this.decodeHashtable(buffer))
|
|
553
|
+
case Code.OBJECT_ARRAY:
|
|
554
|
+
return this.decodeObjects(buffer)
|
|
555
|
+
case Code.ARRAY:
|
|
556
|
+
return this.decodeArrays(buffer)
|
|
557
|
+
case Code.BOOLEAN_ARRAY:
|
|
558
|
+
return this.decodeBooleans(buffer)
|
|
559
|
+
case Code.SHORT_ARRAY:
|
|
560
|
+
return this.decodeItems(Code.SHORT, 2, buffer)
|
|
561
|
+
case Code.FLOAT_ARRAY:
|
|
562
|
+
return this.decodeItems(Code.FLOAT, 4, buffer)
|
|
563
|
+
case Code.DOUBLE_ARRAY:
|
|
564
|
+
return this.decodeItems(Code.DOUBLE, 8, buffer)
|
|
565
|
+
case Code.STRING_ARRAY:
|
|
566
|
+
return this.decodeItems(Code.STRING, 1, buffer)
|
|
567
|
+
case Code.COMPRESSED_INT_ARRAY:
|
|
568
|
+
return this.decodeItems(Code.COMPRESSED_INT, 1, buffer)
|
|
569
|
+
case Code.COMPRESSED_LONG_ARRAY:
|
|
570
|
+
return this.decodeItems(Code.COMPRESSED_LONG, 1, buffer)
|
|
571
|
+
case Code.HASHTABLE_ARRAY:
|
|
572
|
+
return this.decodeItems(Code.HASHTABLE, 1, buffer)
|
|
573
|
+
case Code.CUSTOM_ARRAY:
|
|
574
|
+
return this.decodeCustoms(buffer)
|
|
575
|
+
case Code.DICTIONARY_ARRAY:
|
|
576
|
+
return this.decodeDictionaries(buffer)
|
|
577
|
+
default:
|
|
578
|
+
throw new DecoderError('Type code is unknown')
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Reads an int stored as a zigzag varint
|
|
584
|
+
* @param buffer bytes to read from
|
|
585
|
+
*/
|
|
586
|
+
private decodeInt(buffer: ByteBuf): number {
|
|
587
|
+
const raw = this.decodeCount(buffer)
|
|
588
|
+
|
|
589
|
+
return (raw >>> 1) ^ -(raw & 1)
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Reads a long stored as a zigzag varint
|
|
594
|
+
* @param buffer bytes to read from
|
|
595
|
+
*/
|
|
596
|
+
private decodeLong(buffer: ByteBuf): bigint {
|
|
597
|
+
let raw = 0n
|
|
598
|
+
for (let shift = 0n; shift < 70n; shift += 7n) {
|
|
599
|
+
const byte = buffer.readUint8()
|
|
600
|
+
raw |= BigInt(byte & 127) << shift
|
|
601
|
+
if (byte < 128) break
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
raw = BigInt.asUintN(64, raw)
|
|
605
|
+
|
|
606
|
+
return BigInt.asIntN(64, (raw >> 1n) ^ -(raw & 1n))
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Reads a string with its length
|
|
611
|
+
* @param buffer bytes to read from
|
|
612
|
+
*/
|
|
613
|
+
private decodeString(buffer: ByteBuf): string {
|
|
614
|
+
return this.names.read(this.size(this.decodeCount(buffer), buffer), buffer)
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Reads bytes with their length
|
|
619
|
+
* @param buffer bytes to read from
|
|
620
|
+
*/
|
|
621
|
+
private decodeBytes(buffer: ByteBuf): Uint8Array {
|
|
622
|
+
return buffer.readBytes(this.size(this.decodeCount(buffer), buffer))
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Reads an object array
|
|
627
|
+
* @param buffer bytes to read from
|
|
628
|
+
*/
|
|
629
|
+
private decodeObjects(buffer: ByteBuf): PhotonValue {
|
|
630
|
+
const count = this.size(this.decodeCount(buffer), buffer)
|
|
631
|
+
|
|
632
|
+
const items: PhotonValue[] = []
|
|
633
|
+
for (let index = 0; index < count; index++) {
|
|
634
|
+
items.push(this.decodeValue(buffer))
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
return PhotonValue.objects(items)
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Reads an array whose items are arrays
|
|
642
|
+
* @param buffer bytes to read from
|
|
643
|
+
*/
|
|
644
|
+
private decodeArrays(buffer: ByteBuf): PhotonValue {
|
|
645
|
+
const count = this.size(this.decodeCount(buffer), buffer)
|
|
646
|
+
|
|
647
|
+
const items: PhotonData[] = []
|
|
648
|
+
let element = Shape.unknown()
|
|
649
|
+
for (let index = 0; index < count; index++) {
|
|
650
|
+
const item = this.decodeValue(buffer)
|
|
651
|
+
if (item.kind !== Kind.ARRAY && item.kind !== Kind.BYTES) {
|
|
652
|
+
throw new DecoderError('Array item is not an array')
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
element = this.fit(element, item.shape)
|
|
656
|
+
items.push(item.data)
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (element.kind === Kind.UNKNOWN) element = Shape.array(element)
|
|
660
|
+
|
|
661
|
+
return PhotonValue.array(element, items)
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Reads a bit packed bool array
|
|
666
|
+
* @param buffer bytes to read from
|
|
667
|
+
*/
|
|
668
|
+
private decodeBooleans(buffer: ByteBuf): PhotonValue {
|
|
669
|
+
const count = this.decodeCount(buffer)
|
|
670
|
+
const packed = buffer.readBytes(this.size(Math.ceil(count / 8), buffer))
|
|
671
|
+
|
|
672
|
+
const items: boolean[] = []
|
|
673
|
+
for (let index = 0; index < count; index++) {
|
|
674
|
+
items.push((((packed[index >> 3] ?? 0) >> (index & 7)) & 1) === 1)
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return PhotonValue.array(Shape.bool(), items)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Reads array items that all go by one type code
|
|
682
|
+
* @param code type code of every item
|
|
683
|
+
* @param least fewest bytes one item takes
|
|
684
|
+
* @param buffer bytes to read from
|
|
685
|
+
*/
|
|
686
|
+
private decodeItems(
|
|
687
|
+
code: number,
|
|
688
|
+
least: number,
|
|
689
|
+
buffer: ByteBuf,
|
|
690
|
+
): PhotonValue {
|
|
691
|
+
const count = this.size(this.decodeCount(buffer), buffer, least)
|
|
692
|
+
|
|
693
|
+
const items: PhotonData[] = []
|
|
694
|
+
for (let index = 0; index < count; index++) {
|
|
695
|
+
items.push(this.decodeCoded(code, buffer).data)
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return PhotonValue.array(this.shapeOf(code), items)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Reads an array of one custom type
|
|
703
|
+
* @param buffer bytes to read from
|
|
704
|
+
*/
|
|
705
|
+
private decodeCustoms(buffer: ByteBuf): PhotonValue {
|
|
706
|
+
const count = this.size(this.decodeCount(buffer), buffer)
|
|
707
|
+
const code = buffer.readUint8()
|
|
708
|
+
|
|
709
|
+
const items: Uint8Array[] = []
|
|
710
|
+
for (let index = 0; index < count; index++) {
|
|
711
|
+
items.push(this.decodeBytes(buffer))
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
return PhotonValue.array(Shape.custom(code), items)
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Reads an array of dictionaries
|
|
719
|
+
* @param buffer bytes to read from
|
|
720
|
+
*/
|
|
721
|
+
private decodeDictionaries(buffer: ByteBuf): PhotonValue {
|
|
722
|
+
const header = this.decodeHeader(buffer)
|
|
723
|
+
const count = this.size(this.decodeCount(buffer), buffer)
|
|
724
|
+
|
|
725
|
+
const items: PhotonDictionary[] = []
|
|
726
|
+
let element = Shape.dictionary(header.key, header.value)
|
|
727
|
+
for (let index = 0; index < count; index++) {
|
|
728
|
+
const item = this.decodeEntries(header, buffer)
|
|
729
|
+
element = this.fit(element, Shape.dictionary(item.key, item.value))
|
|
730
|
+
items.push(item)
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return this.dictionaries(items, element)
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Reads a hashtable and drops entries with a null key
|
|
738
|
+
* @param buffer bytes to read from
|
|
739
|
+
*/
|
|
740
|
+
private decodeHashtable(buffer: ByteBuf): PhotonHashtable {
|
|
741
|
+
const table = PhotonHashtable.of()
|
|
742
|
+
|
|
743
|
+
const count = this.size(this.decodeCount(buffer), buffer, 2)
|
|
744
|
+
for (let index = 0; index < count; index++) {
|
|
745
|
+
const key = this.decodeValue(buffer)
|
|
746
|
+
const value = this.decodeValue(buffer)
|
|
747
|
+
if (key.kind !== Kind.NULL) table.set(key, value)
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return table
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Reads the key and value types a dictionary declares
|
|
755
|
+
* @param buffer bytes to read from
|
|
756
|
+
*/
|
|
757
|
+
private decodeHeader(buffer: ByteBuf): DictionaryHeader {
|
|
758
|
+
const keyCode = buffer.readUint8()
|
|
759
|
+
const valueCode = buffer.readUint8()
|
|
760
|
+
|
|
761
|
+
return {
|
|
762
|
+
keyCode,
|
|
763
|
+
valueCode: valueCode === Code.ARRAY ? Code.UNKNOWN : valueCode,
|
|
764
|
+
key: this.keyShape(keyCode),
|
|
765
|
+
value: this.valueShape(valueCode, buffer),
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* The declared key type behind a header's first type code
|
|
771
|
+
* @param code type code from the header
|
|
772
|
+
*/
|
|
773
|
+
private keyShape(code: number): Shape {
|
|
774
|
+
if (code === Code.UNKNOWN) return Shape.any()
|
|
775
|
+
|
|
776
|
+
const shape = this.shapeOf(code)
|
|
777
|
+
|
|
778
|
+
switch (shape.kind) {
|
|
779
|
+
case Kind.BOOL:
|
|
780
|
+
case Kind.BYTE:
|
|
781
|
+
case Kind.SHORT:
|
|
782
|
+
case Kind.INT:
|
|
783
|
+
case Kind.LONG:
|
|
784
|
+
case Kind.FLOAT:
|
|
785
|
+
case Kind.DOUBLE:
|
|
786
|
+
case Kind.STRING:
|
|
787
|
+
return shape
|
|
788
|
+
default:
|
|
789
|
+
throw new DecoderError('Dictionary key type is unsupported')
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* The declared value type behind a header's second type code
|
|
795
|
+
* @param code type code from the header
|
|
796
|
+
* @param buffer bytes the rest of the type comes from
|
|
797
|
+
*/
|
|
798
|
+
private valueShape(code: number, buffer: ByteBuf): Shape {
|
|
799
|
+
if (code === Code.UNKNOWN) return Shape.any()
|
|
800
|
+
if (code === Code.ARRAY) return this.arrayShape(buffer)
|
|
801
|
+
if (code !== Code.DICTIONARY) return this.shapeOf(code)
|
|
802
|
+
|
|
803
|
+
this.descend()
|
|
804
|
+
|
|
805
|
+
const nested = this.decodeHeader(buffer)
|
|
806
|
+
this.ascend()
|
|
807
|
+
|
|
808
|
+
return Shape.dictionary(nested.key, nested.value)
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* The array of arrays type a dictionary declares for its values
|
|
813
|
+
* @param buffer bytes the rest of the type comes from
|
|
814
|
+
*/
|
|
815
|
+
private arrayShape(buffer: ByteBuf): Shape {
|
|
816
|
+
this.descend()
|
|
817
|
+
|
|
818
|
+
const code = buffer.readUint8()
|
|
819
|
+
const inner =
|
|
820
|
+
code === Code.ARRAY ? this.arrayShape(buffer) : this.shapeOf(code)
|
|
821
|
+
if (inner.kind !== Kind.ARRAY && inner.kind !== Kind.BYTES) {
|
|
822
|
+
throw new DecoderError('Dictionary value type is unsupported')
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
this.ascend()
|
|
826
|
+
|
|
827
|
+
return Shape.array(inner)
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* The type a type code stands for
|
|
832
|
+
* @param code type code of an array element or dictionary side
|
|
833
|
+
*/
|
|
834
|
+
private shapeOf(code: number): Shape {
|
|
835
|
+
switch (code) {
|
|
836
|
+
case Code.BOOLEAN:
|
|
837
|
+
case Code.BOOLEAN_FALSE:
|
|
838
|
+
case Code.BOOLEAN_TRUE:
|
|
839
|
+
return Shape.bool()
|
|
840
|
+
case Code.BYTE:
|
|
841
|
+
case Code.BYTE_ZERO:
|
|
842
|
+
return Shape.byte()
|
|
843
|
+
case Code.SHORT:
|
|
844
|
+
case Code.SHORT_ZERO:
|
|
845
|
+
return Shape.short()
|
|
846
|
+
case Code.FLOAT:
|
|
847
|
+
case Code.FLOAT_ZERO:
|
|
848
|
+
return Shape.float()
|
|
849
|
+
case Code.DOUBLE:
|
|
850
|
+
case Code.DOUBLE_ZERO:
|
|
851
|
+
return Shape.double()
|
|
852
|
+
case Code.STRING:
|
|
853
|
+
return Shape.string()
|
|
854
|
+
case Code.COMPRESSED_INT:
|
|
855
|
+
case Code.INT1:
|
|
856
|
+
case Code.INT1_NEGATIVE:
|
|
857
|
+
case Code.INT2:
|
|
858
|
+
case Code.INT2_NEGATIVE:
|
|
859
|
+
case Code.INT_ZERO:
|
|
860
|
+
return Shape.int()
|
|
861
|
+
case Code.COMPRESSED_LONG:
|
|
862
|
+
case Code.LONG1:
|
|
863
|
+
case Code.LONG1_NEGATIVE:
|
|
864
|
+
case Code.LONG2:
|
|
865
|
+
case Code.LONG2_NEGATIVE:
|
|
866
|
+
case Code.LONG_ZERO:
|
|
867
|
+
return Shape.long()
|
|
868
|
+
default:
|
|
869
|
+
return this.containerShapeOf(code)
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* The container or message type a type code stands for
|
|
875
|
+
* @param code type code of an array element or dictionary side
|
|
876
|
+
*/
|
|
877
|
+
private containerShapeOf(code: number): Shape {
|
|
878
|
+
switch (code) {
|
|
879
|
+
case Code.HASHTABLE:
|
|
880
|
+
return Shape.hashtable()
|
|
881
|
+
case Code.OBJECT_ARRAY:
|
|
882
|
+
return Shape.array(Shape.any())
|
|
883
|
+
case Code.REQUEST:
|
|
884
|
+
return Shape.request()
|
|
885
|
+
case Code.RESPONSE:
|
|
886
|
+
return Shape.response()
|
|
887
|
+
case Code.EVENT:
|
|
888
|
+
return Shape.event()
|
|
889
|
+
case Code.BYTE_ARRAY:
|
|
890
|
+
return Shape.bytes()
|
|
891
|
+
case Code.BOOLEAN_ARRAY:
|
|
892
|
+
return Shape.array(Shape.bool())
|
|
893
|
+
case Code.SHORT_ARRAY:
|
|
894
|
+
return Shape.array(Shape.short())
|
|
895
|
+
case Code.FLOAT_ARRAY:
|
|
896
|
+
return Shape.array(Shape.float())
|
|
897
|
+
case Code.DOUBLE_ARRAY:
|
|
898
|
+
return Shape.array(Shape.double())
|
|
899
|
+
case Code.STRING_ARRAY:
|
|
900
|
+
return Shape.array(Shape.string())
|
|
901
|
+
case Code.COMPRESSED_INT_ARRAY:
|
|
902
|
+
return Shape.array(Shape.int())
|
|
903
|
+
case Code.COMPRESSED_LONG_ARRAY:
|
|
904
|
+
return Shape.array(Shape.long())
|
|
905
|
+
case Code.HASHTABLE_ARRAY:
|
|
906
|
+
return Shape.array(Shape.hashtable())
|
|
907
|
+
default:
|
|
908
|
+
throw new DecoderError('Dictionary type is unsupported')
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* The fixed type code of a value's type
|
|
914
|
+
* @param shape the value's type
|
|
915
|
+
*/
|
|
916
|
+
private codeOf(shape: Shape): number {
|
|
917
|
+
switch (shape.kind) {
|
|
918
|
+
case Kind.BOOL:
|
|
919
|
+
return Code.BOOLEAN
|
|
920
|
+
case Kind.BYTE:
|
|
921
|
+
return Code.BYTE
|
|
922
|
+
case Kind.SHORT:
|
|
923
|
+
return Code.SHORT
|
|
924
|
+
case Kind.INT:
|
|
925
|
+
return Code.COMPRESSED_INT
|
|
926
|
+
case Kind.LONG:
|
|
927
|
+
return Code.COMPRESSED_LONG
|
|
928
|
+
case Kind.FLOAT:
|
|
929
|
+
return Code.FLOAT
|
|
930
|
+
case Kind.DOUBLE:
|
|
931
|
+
return Code.DOUBLE
|
|
932
|
+
case Kind.STRING:
|
|
933
|
+
return Code.STRING
|
|
934
|
+
case Kind.BYTES:
|
|
935
|
+
return Code.BYTE_ARRAY
|
|
936
|
+
case Kind.HASHTABLE:
|
|
937
|
+
return Code.HASHTABLE
|
|
938
|
+
case Kind.DICTIONARY:
|
|
939
|
+
return Code.DICTIONARY
|
|
940
|
+
case Kind.REQUEST:
|
|
941
|
+
return Code.REQUEST
|
|
942
|
+
case Kind.RESPONSE:
|
|
943
|
+
return Code.RESPONSE
|
|
944
|
+
case Kind.EVENT:
|
|
945
|
+
return Code.EVENT
|
|
946
|
+
default:
|
|
947
|
+
throw new EncoderError('Value has no type')
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Writes a byte or short under its zero code or its plain code
|
|
953
|
+
* @param code type code for a value that isn't zero
|
|
954
|
+
* @param zero type code that stands for zero
|
|
955
|
+
* @param value what to write
|
|
956
|
+
* @param buffer where it goes
|
|
957
|
+
*/
|
|
958
|
+
private encodeTagged(
|
|
959
|
+
code: number,
|
|
960
|
+
zero: number,
|
|
961
|
+
value: PhotonValue,
|
|
962
|
+
buffer: ByteBuf,
|
|
963
|
+
): void {
|
|
964
|
+
if (value.data === 0) {
|
|
965
|
+
buffer.writeUint8(zero)
|
|
966
|
+
return
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
buffer.writeUint8(code)
|
|
970
|
+
this.encodeBare(value.shape, value.data, buffer)
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Writes an int in the shortest form that holds it
|
|
975
|
+
* @param value what to write
|
|
976
|
+
* @param buffer where it goes
|
|
977
|
+
*/
|
|
978
|
+
private encodeInt(value: number, buffer: ByteBuf): void {
|
|
979
|
+
if (this.encodeSmall(value, Code.INT_ZERO, Code.INT1, buffer)) return
|
|
980
|
+
|
|
981
|
+
buffer.writeUint8(Code.COMPRESSED_INT)
|
|
982
|
+
this.encodeCount(this.zigzag(value), buffer)
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Writes a long in the shortest form that holds it
|
|
987
|
+
* @param value what to write
|
|
988
|
+
* @param buffer where it goes
|
|
989
|
+
*/
|
|
990
|
+
private encodeLong(value: bigint, buffer: ByteBuf): void {
|
|
991
|
+
const small = Number(BigInt.asIntN(32, value))
|
|
992
|
+
if (
|
|
993
|
+
BigInt(small) === value &&
|
|
994
|
+
this.encodeSmall(small, Code.LONG_ZERO, Code.LONG1, buffer)
|
|
995
|
+
) {
|
|
996
|
+
return
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
buffer.writeUint8(Code.COMPRESSED_LONG)
|
|
1000
|
+
this.encodeWide(this.zigzagWide(value), buffer)
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Writes a number in a 1 or 2 byte form and says whether it fitted
|
|
1005
|
+
* @param value what to write
|
|
1006
|
+
* @param zero type code that stands for zero
|
|
1007
|
+
* @param first type code of the 1 byte positive form
|
|
1008
|
+
* @param buffer where it goes
|
|
1009
|
+
*/
|
|
1010
|
+
private encodeSmall(
|
|
1011
|
+
value: number,
|
|
1012
|
+
zero: number,
|
|
1013
|
+
first: number,
|
|
1014
|
+
buffer: ByteBuf,
|
|
1015
|
+
): boolean {
|
|
1016
|
+
const size = Math.abs(value)
|
|
1017
|
+
if (size > Protocol18.smallLimit) return false
|
|
1018
|
+
|
|
1019
|
+
if (size === 0) {
|
|
1020
|
+
buffer.writeUint8(zero)
|
|
1021
|
+
return true
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
const sign = value < 0 ? 1 : 0
|
|
1025
|
+
if (size <= 255) {
|
|
1026
|
+
buffer.writeUint8(first + sign).writeUint8(size)
|
|
1027
|
+
return true
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
buffer.writeUint8(first + 2 + sign).writeUint16(size, 'little')
|
|
1031
|
+
return true
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Writes a custom value in the slim or the full form
|
|
1036
|
+
* @param code what the type was registered under
|
|
1037
|
+
* @param payload bytes its serialiser produced
|
|
1038
|
+
* @param buffer where it goes
|
|
1039
|
+
*/
|
|
1040
|
+
private encodeCustom(
|
|
1041
|
+
code: number,
|
|
1042
|
+
payload: Uint8Array,
|
|
1043
|
+
buffer: ByteBuf,
|
|
1044
|
+
): void {
|
|
1045
|
+
if (code < Protocol18.slimLimit) {
|
|
1046
|
+
buffer.writeUint8(Code.CUSTOM_SLIM + code)
|
|
1047
|
+
} else {
|
|
1048
|
+
buffer.writeUint8(Code.CUSTOM).writeUint8(code)
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
this.encodeBytes(payload, buffer)
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* An int in zigzag form
|
|
1056
|
+
* @param value signed 32 bit integer
|
|
1057
|
+
*/
|
|
1058
|
+
private zigzag(value: number): number {
|
|
1059
|
+
return ((value << 1) ^ (value >> 31)) >>> 0
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* A long in zigzag form
|
|
1064
|
+
* @param value signed 64 bit integer
|
|
1065
|
+
*/
|
|
1066
|
+
private zigzagWide(value: bigint): bigint {
|
|
1067
|
+
return BigInt.asUintN(64, (value << 1n) ^ (value >> 63n))
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Writes a compressed unsigned integer of up to 32 bits
|
|
1072
|
+
* @param value unsigned 32 bit integer
|
|
1073
|
+
* @param buffer where it goes
|
|
1074
|
+
*/
|
|
1075
|
+
private encodeCount(value: number, buffer: ByteBuf): void {
|
|
1076
|
+
let rest = value >>> 0
|
|
1077
|
+
while (rest > 127) {
|
|
1078
|
+
buffer.writeUint8((rest & 127) | 128)
|
|
1079
|
+
rest >>>= 7
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
buffer.writeUint8(rest)
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* Writes a compressed unsigned integer of up to 64 bits
|
|
1087
|
+
* @param value unsigned 64 bit integer
|
|
1088
|
+
* @param buffer where it goes
|
|
1089
|
+
*/
|
|
1090
|
+
private encodeWide(value: bigint, buffer: ByteBuf): void {
|
|
1091
|
+
let rest = value
|
|
1092
|
+
while (rest > 127n) {
|
|
1093
|
+
buffer.writeUint8(Number(rest & 127n) | 128)
|
|
1094
|
+
rest >>= 7n
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
buffer.writeUint8(Number(rest))
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Writes a string with its length
|
|
1102
|
+
* @param text what to write
|
|
1103
|
+
* @param buffer where it goes
|
|
1104
|
+
*/
|
|
1105
|
+
private encodeString(text: string, buffer: ByteBuf): void {
|
|
1106
|
+
this.encodeCount(Buffer.byteLength(text), buffer)
|
|
1107
|
+
buffer.writeString(text)
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Writes bytes with their length
|
|
1112
|
+
* @param bytes what to write
|
|
1113
|
+
* @param buffer where it goes
|
|
1114
|
+
*/
|
|
1115
|
+
private encodeBytes(bytes: Uint8Array, buffer: ByteBuf): void {
|
|
1116
|
+
this.encodeCount(bytes.length, buffer)
|
|
1117
|
+
buffer.writeBytes(bytes)
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Writes a container or nested message, without its type code
|
|
1122
|
+
* @param shape the value's type
|
|
1123
|
+
* @param data what it holds
|
|
1124
|
+
* @param buffer where it goes
|
|
1125
|
+
*/
|
|
1126
|
+
private encodeNested(shape: Shape, data: PhotonData, buffer: ByteBuf): void {
|
|
1127
|
+
switch (shape.kind) {
|
|
1128
|
+
case Kind.ARRAY:
|
|
1129
|
+
this.encodeArray(shape, data as readonly PhotonData[], false, buffer)
|
|
1130
|
+
return
|
|
1131
|
+
case Kind.HASHTABLE:
|
|
1132
|
+
this.encodeHashtable(data as PhotonHashtable, buffer)
|
|
1133
|
+
return
|
|
1134
|
+
case Kind.DICTIONARY:
|
|
1135
|
+
this.encodeHeader(shape, buffer)
|
|
1136
|
+
this.encodeEntries(data as PhotonDictionary, buffer)
|
|
1137
|
+
return
|
|
1138
|
+
default:
|
|
1139
|
+
this.encodeMessage(data, buffer)
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Writes a hashtable's count and typed entries
|
|
1145
|
+
* @param table what to write
|
|
1146
|
+
* @param buffer where it goes
|
|
1147
|
+
*/
|
|
1148
|
+
private encodeHashtable(table: PhotonHashtable, buffer: ByteBuf): void {
|
|
1149
|
+
this.encodeCount(table.size, buffer)
|
|
1150
|
+
|
|
1151
|
+
for (const [key, value] of table.entries()) {
|
|
1152
|
+
this.encodeValue(key, buffer)
|
|
1153
|
+
this.encodeValue(value, buffer)
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* Writes an array in the form its element type calls for
|
|
1159
|
+
* @param shape the array's type
|
|
1160
|
+
* @param items what it holds
|
|
1161
|
+
* @param typed whether the type code goes out too
|
|
1162
|
+
* @param buffer where it goes
|
|
1163
|
+
*/
|
|
1164
|
+
private encodeArray(
|
|
1165
|
+
shape: Shape,
|
|
1166
|
+
items: readonly PhotonData[],
|
|
1167
|
+
typed: boolean,
|
|
1168
|
+
buffer: ByteBuf,
|
|
1169
|
+
): void {
|
|
1170
|
+
const element = shape.element ?? Shape.unknown()
|
|
1171
|
+
|
|
1172
|
+
switch (element.kind) {
|
|
1173
|
+
case Kind.UNKNOWN:
|
|
1174
|
+
throw new EncoderError('Array type is unknown')
|
|
1175
|
+
case Kind.BYTE:
|
|
1176
|
+
case Kind.NULL:
|
|
1177
|
+
throw new EncoderError('Array type is unsupported')
|
|
1178
|
+
case Kind.ARRAY:
|
|
1179
|
+
case Kind.BYTES:
|
|
1180
|
+
this.encodeTyped(Code.ARRAY, element, items, buffer)
|
|
1181
|
+
return
|
|
1182
|
+
case Kind.DICTIONARY:
|
|
1183
|
+
this.encodeDictionaries(element, items, buffer)
|
|
1184
|
+
return
|
|
1185
|
+
case Kind.ANY:
|
|
1186
|
+
case Kind.REQUEST:
|
|
1187
|
+
case Kind.RESPONSE:
|
|
1188
|
+
case Kind.EVENT:
|
|
1189
|
+
if (typed) buffer.writeUint8(Code.OBJECT_ARRAY)
|
|
1190
|
+
break
|
|
1191
|
+
case Kind.CUSTOM:
|
|
1192
|
+
if (typed) buffer.writeUint8(Code.CUSTOM_ARRAY)
|
|
1193
|
+
break
|
|
1194
|
+
default:
|
|
1195
|
+
if (typed) buffer.writeUint8(Code.ARRAY | this.codeOf(element))
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
this.encodeItems(element, items, buffer)
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Writes an array's count and items, without its type code
|
|
1203
|
+
* @param element what every item is
|
|
1204
|
+
* @param items what the array holds
|
|
1205
|
+
* @param buffer where it goes
|
|
1206
|
+
*/
|
|
1207
|
+
private encodeItems(
|
|
1208
|
+
element: Shape,
|
|
1209
|
+
items: readonly PhotonData[],
|
|
1210
|
+
buffer: ByteBuf,
|
|
1211
|
+
): void {
|
|
1212
|
+
this.encodeCount(items.length, buffer)
|
|
1213
|
+
|
|
1214
|
+
if (element.kind === Kind.BOOL) {
|
|
1215
|
+
this.encodeBooleans(items, buffer)
|
|
1216
|
+
return
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
if (element.kind === Kind.CUSTOM) buffer.writeUint8(element.code ?? 0)
|
|
1220
|
+
|
|
1221
|
+
for (const item of items) {
|
|
1222
|
+
this.encodeItem(element, item, buffer)
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* Writes one array item
|
|
1228
|
+
* @param element what every item is
|
|
1229
|
+
* @param item what to write
|
|
1230
|
+
* @param buffer where it goes
|
|
1231
|
+
*/
|
|
1232
|
+
private encodeItem(element: Shape, item: PhotonData, buffer: ByteBuf): void {
|
|
1233
|
+
switch (element.kind) {
|
|
1234
|
+
case Kind.CUSTOM:
|
|
1235
|
+
this.encodeBytes(item as Uint8Array, buffer)
|
|
1236
|
+
return
|
|
1237
|
+
case Kind.REQUEST:
|
|
1238
|
+
case Kind.RESPONSE:
|
|
1239
|
+
case Kind.EVENT:
|
|
1240
|
+
this.encodeValue(this.wrap(element, item), buffer)
|
|
1241
|
+
return
|
|
1242
|
+
default:
|
|
1243
|
+
this.encodeBare(element, item, buffer)
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Writes an array whose items each carry their own type code
|
|
1249
|
+
* @param code type code of the array
|
|
1250
|
+
* @param element what every item is
|
|
1251
|
+
* @param items what the array holds
|
|
1252
|
+
* @param buffer where it goes
|
|
1253
|
+
*/
|
|
1254
|
+
private encodeTyped(
|
|
1255
|
+
code: number,
|
|
1256
|
+
element: Shape,
|
|
1257
|
+
items: readonly PhotonData[],
|
|
1258
|
+
buffer: ByteBuf,
|
|
1259
|
+
): void {
|
|
1260
|
+
buffer.writeUint8(code)
|
|
1261
|
+
this.encodeCount(items.length, buffer)
|
|
1262
|
+
|
|
1263
|
+
for (const item of items) {
|
|
1264
|
+
this.encodeValue(this.wrap(element, item), buffer)
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Writes bools packed 8 to a byte, lowest bit first
|
|
1270
|
+
* @param items the bools
|
|
1271
|
+
* @param buffer where it goes
|
|
1272
|
+
*/
|
|
1273
|
+
private encodeBooleans(items: readonly PhotonData[], buffer: ByteBuf): void {
|
|
1274
|
+
const packed = new Uint8Array(Math.ceil(items.length / 8))
|
|
1275
|
+
for (const [index, item] of items.entries()) {
|
|
1276
|
+
if (item === true) {
|
|
1277
|
+
packed[index >> 3] = (packed[index >> 3] ?? 0) | (1 << (index & 7))
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
buffer.writeBytes(packed)
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Writes an array of dictionaries with its type code
|
|
1286
|
+
* @param element dictionary type of every item
|
|
1287
|
+
* @param items the dictionaries
|
|
1288
|
+
* @param buffer where it goes
|
|
1289
|
+
*/
|
|
1290
|
+
private encodeDictionaries(
|
|
1291
|
+
element: Shape,
|
|
1292
|
+
items: readonly PhotonData[],
|
|
1293
|
+
buffer: ByteBuf,
|
|
1294
|
+
): void {
|
|
1295
|
+
buffer.writeUint8(Code.DICTIONARY_ARRAY)
|
|
1296
|
+
this.encodeHeader(element, buffer)
|
|
1297
|
+
this.encodeCount(items.length, buffer)
|
|
1298
|
+
|
|
1299
|
+
for (const item of items) {
|
|
1300
|
+
const dictionary = item as PhotonDictionary
|
|
1301
|
+
if (!Shape.dictionary(dictionary.key, dictionary.value).equals(element)) {
|
|
1302
|
+
throw new EncoderError('Dictionary types differ')
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
this.encodeEntries(dictionary, buffer)
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Writes the key and value types a dictionary declares
|
|
1311
|
+
* @param shape the dictionary's type
|
|
1312
|
+
* @param buffer where it goes
|
|
1313
|
+
*/
|
|
1314
|
+
private encodeHeader(shape: Shape, buffer: ByteBuf): void {
|
|
1315
|
+
buffer.writeUint8(this.keyCode(shape.key ?? Shape.any()))
|
|
1316
|
+
|
|
1317
|
+
for (const code of this.valueCodes(shape.value ?? Shape.any())) {
|
|
1318
|
+
buffer.writeUint8(code)
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* The header code for the key side, or zero
|
|
1324
|
+
* @param key declared type of the keys
|
|
1325
|
+
*/
|
|
1326
|
+
private keyCode(key: Shape): number {
|
|
1327
|
+
switch (key.kind) {
|
|
1328
|
+
case Kind.BYTE:
|
|
1329
|
+
case Kind.SHORT:
|
|
1330
|
+
case Kind.INT:
|
|
1331
|
+
case Kind.LONG:
|
|
1332
|
+
case Kind.FLOAT:
|
|
1333
|
+
case Kind.DOUBLE:
|
|
1334
|
+
case Kind.STRING:
|
|
1335
|
+
return this.codeOf(key)
|
|
1336
|
+
default:
|
|
1337
|
+
return Code.UNKNOWN
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* The header codes for the value side
|
|
1343
|
+
* @param value declared type of the values
|
|
1344
|
+
*/
|
|
1345
|
+
private valueCodes(value: Shape): readonly number[] {
|
|
1346
|
+
switch (value.kind) {
|
|
1347
|
+
case Kind.BOOL:
|
|
1348
|
+
case Kind.BYTE:
|
|
1349
|
+
case Kind.SHORT:
|
|
1350
|
+
case Kind.INT:
|
|
1351
|
+
case Kind.LONG:
|
|
1352
|
+
case Kind.FLOAT:
|
|
1353
|
+
case Kind.DOUBLE:
|
|
1354
|
+
case Kind.STRING:
|
|
1355
|
+
case Kind.BYTES:
|
|
1356
|
+
case Kind.HASHTABLE:
|
|
1357
|
+
case Kind.REQUEST:
|
|
1358
|
+
case Kind.RESPONSE:
|
|
1359
|
+
case Kind.EVENT:
|
|
1360
|
+
return [this.codeOf(value)]
|
|
1361
|
+
case Kind.DICTIONARY:
|
|
1362
|
+
return [
|
|
1363
|
+
Code.DICTIONARY,
|
|
1364
|
+
this.keyCode(value.key ?? Shape.any()),
|
|
1365
|
+
...this.valueCodes(value.value ?? Shape.any()),
|
|
1366
|
+
]
|
|
1367
|
+
case Kind.ARRAY:
|
|
1368
|
+
return this.arrayCodes(value) ?? [Code.UNKNOWN]
|
|
1369
|
+
default:
|
|
1370
|
+
return [Code.UNKNOWN]
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* The header codes for an array value type, or null
|
|
1376
|
+
* @param shape the array's type
|
|
1377
|
+
*/
|
|
1378
|
+
private arrayCodes(shape: Shape): readonly number[] | null {
|
|
1379
|
+
const element = shape.element ?? Shape.unknown()
|
|
1380
|
+
|
|
1381
|
+
switch (element.kind) {
|
|
1382
|
+
case Kind.ANY:
|
|
1383
|
+
return [Code.OBJECT_ARRAY]
|
|
1384
|
+
case Kind.BOOL:
|
|
1385
|
+
case Kind.SHORT:
|
|
1386
|
+
case Kind.INT:
|
|
1387
|
+
case Kind.LONG:
|
|
1388
|
+
case Kind.FLOAT:
|
|
1389
|
+
case Kind.DOUBLE:
|
|
1390
|
+
case Kind.STRING:
|
|
1391
|
+
case Kind.HASHTABLE:
|
|
1392
|
+
return [Code.ARRAY | this.codeOf(element)]
|
|
1393
|
+
case Kind.BYTES:
|
|
1394
|
+
return [Code.ARRAY, Code.BYTE_ARRAY]
|
|
1395
|
+
case Kind.ARRAY:
|
|
1396
|
+
return this.nestedCodes(element)
|
|
1397
|
+
default:
|
|
1398
|
+
return null
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* The header codes for an array of arrays value type, or null
|
|
1404
|
+
* @param element the inner array's type
|
|
1405
|
+
*/
|
|
1406
|
+
private nestedCodes(element: Shape): readonly number[] | null {
|
|
1407
|
+
const inner = this.arrayCodes(element)
|
|
1408
|
+
|
|
1409
|
+
return inner === null ? null : [Code.ARRAY, ...inner]
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Writes a dictionary's count and entries
|
|
1414
|
+
* @param dictionary what to write
|
|
1415
|
+
* @param buffer where it goes
|
|
1416
|
+
*/
|
|
1417
|
+
private encodeEntries(dictionary: PhotonDictionary, buffer: ByteBuf): void {
|
|
1418
|
+
const typedKeys = this.keyCode(dictionary.key) === Code.UNKNOWN
|
|
1419
|
+
const first = this.valueCodes(dictionary.value)[0]
|
|
1420
|
+
const typedValues = first === Code.UNKNOWN || first === Code.ARRAY
|
|
1421
|
+
this.encodeCount(dictionary.size, buffer)
|
|
1422
|
+
|
|
1423
|
+
for (const [key, value] of dictionary.entries()) {
|
|
1424
|
+
this.encodeSide(dictionary.key, key, typedKeys, buffer)
|
|
1425
|
+
this.encodeSide(dictionary.value, value, typedValues, buffer)
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
}
|