@hytopia.com/server-protocol 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packets/PacketCore.ts +9 -8
- package/packets/inbound/SyncRequest.ts +11 -0
- package/packets/inbound/index.ts +4 -2
- package/packets/outbound/SyncResponse.ts +12 -0
- package/packets/outbound/index.ts +1 -0
- package/schemas/SyncResponse.ts +16 -0
- package/schemas/index.ts +2 -1
- package/packets/inbound/Heartbeat.ts +0 -11
- /package/schemas/{Heartbeat.ts → SyncRequest.ts} +0 -0
package/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -19,19 +19,20 @@ import type { JSONSchemaType, ValidateFunction } from 'ajv';
|
|
|
19
19
|
|
|
20
20
|
export enum PacketId {
|
|
21
21
|
// Standard Inbound Packet Types: 0 - 31 range
|
|
22
|
-
|
|
22
|
+
SYNC_REQUEST = 0,
|
|
23
23
|
DEBUG_CONFIG = 1,
|
|
24
24
|
INPUT = 2,
|
|
25
25
|
STATE_REQUEST = 3,
|
|
26
26
|
|
|
27
27
|
// Standard Outbound Packet Types: 32 - 127 range
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
SYNC_RESPONSE = 32,
|
|
29
|
+
BLOCK = 33,
|
|
30
|
+
BLOCK_TYPE_REGISTRY = 34,
|
|
31
|
+
BLOCK_TYPE = 35,
|
|
32
|
+
CHUNK = 36,
|
|
33
|
+
ENTITY = 37,
|
|
34
|
+
SIMULATION = 38,
|
|
35
|
+
WORLD = 39,
|
|
35
36
|
|
|
36
37
|
// Debug Inbound Packet Types: 128 - 191 range
|
|
37
38
|
// NONE atm, start at 128
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { syncRequestSchema } from '../../schemas/SyncRequest';
|
|
4
|
+
import type { SyncRequestSchema } from '../../schemas/SyncRequest';
|
|
5
|
+
|
|
6
|
+
export type SyncRequestPacket = IPacket<typeof PacketId.SYNC_REQUEST, SyncRequestSchema>;
|
|
7
|
+
|
|
8
|
+
export const syncRequestPacketDefinition = definePacket(
|
|
9
|
+
PacketId.SYNC_REQUEST,
|
|
10
|
+
syncRequestSchema
|
|
11
|
+
);
|
package/packets/inbound/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { syncResponseSchema } from '../../schemas/SyncResponse';
|
|
4
|
+
import type { SyncResponseSchema } from '../../schemas/SyncResponse';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type SyncResponsePacket = IPacket<typeof PacketId.SYNC_RESPONSE, SyncResponseSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const syncResponsePacketDefinition = definePacket(
|
|
10
|
+
PacketId.SYNC_RESPONSE,
|
|
11
|
+
syncResponseSchema,
|
|
12
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSONSchemaType } from 'ajv';
|
|
2
|
+
|
|
3
|
+
export type SyncResponseSchema = {
|
|
4
|
+
s: number; // server time
|
|
5
|
+
nt: number; // time until next server tick, relative to server time
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const syncResponseSchema: JSONSchemaType<SyncResponseSchema> = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
s: { type: 'number' },
|
|
12
|
+
nt: { type: 'number' },
|
|
13
|
+
},
|
|
14
|
+
required: [ 's', 'nt' ],
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
}
|
package/schemas/index.ts
CHANGED
|
@@ -5,12 +5,13 @@ export * from './Chunk';
|
|
|
5
5
|
export * from './Collider';
|
|
6
6
|
export * from './ColliderDesc';
|
|
7
7
|
export * from './Entity';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './SyncRequest';
|
|
9
9
|
export * from './Input';
|
|
10
10
|
export * from './PhysicsDebugRender';
|
|
11
11
|
export * from './Quaternion';
|
|
12
12
|
export * from './RigidBody';
|
|
13
13
|
export * from './Shape';
|
|
14
|
+
export * from './Simulation';
|
|
14
15
|
export * from './Vector';
|
|
15
16
|
export * from './VectorBoolean';
|
|
16
17
|
export * from './World';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
-
import type { IPacket } from '../PacketCore';
|
|
3
|
-
import { heartbeatSchema } from '../../schemas/Heartbeat';
|
|
4
|
-
import type { HeartbeatSchema } from '../../schemas/Heartbeat';
|
|
5
|
-
|
|
6
|
-
export type HeartbeatPacket = IPacket<typeof PacketId.HEARTBEAT, HeartbeatSchema>;
|
|
7
|
-
|
|
8
|
-
export const heartbeatPacketDefinition = definePacket(
|
|
9
|
-
PacketId.HEARTBEAT,
|
|
10
|
-
heartbeatSchema
|
|
11
|
-
);
|
|
File without changes
|