@hytopia.com/server-protocol 1.0.60 → 1.0.61

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -23,6 +23,7 @@ export enum PacketId {
23
23
  DEBUG_CONFIG = 1,
24
24
  INPUT = 2,
25
25
  STATE_REQUEST = 3,
26
+ MESSAGE_SEND = 4,
26
27
 
27
28
  // Standard Outbound Packet Types: 32 - 127 range
28
29
  SYNC_RESPONSE = 32,
@@ -33,6 +34,7 @@ export enum PacketId {
33
34
  ENTITY = 37,
34
35
  SIMULATION = 38,
35
36
  WORLD = 39,
37
+ MESSAGE = 40,
36
38
 
37
39
  // Debug Inbound Packet Types: 128 - 191 range
38
40
  // NONE atm, start at 128
@@ -0,0 +1,11 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { messageSchema } from '../../schemas/Message';
4
+ import type { MessageSchema } from '../../schemas/Message';
5
+
6
+ export type MessageSendPacket = IPacket<typeof PacketId.MESSAGE_SEND, MessageSchema>;
7
+
8
+ export const messageSendPacketDefinition = definePacket(
9
+ PacketId.MESSAGE_SEND,
10
+ messageSchema
11
+ );
@@ -1,5 +1,6 @@
1
1
  export * from './DebugConfig';
2
2
  export * from './SyncRequest';
3
3
  export * from './Input';
4
+ export * from './MessageSend';
4
5
  export * from './StateRequest';
5
6
  export * from './SyncRequest';
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { messageSchema } from '../../schemas/Message';
4
+ import type { MessageSchema } from '../../schemas/Message';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type MessagePacket = IPacket<typeof PacketId.MESSAGE, MessageSchema> & [WorldTick];
8
+
9
+ export const messagePacketDefinition = definePacket(
10
+ PacketId.MESSAGE,
11
+ messageSchema,
12
+ );
@@ -3,6 +3,7 @@ export * from './BlockTypeRegistry';
3
3
  export * from './BlockType';
4
4
  export * from './Chunk';
5
5
  export * from './Entity';
6
+ export * from './Message';
6
7
  export * from './PhysicsDebugRender';
7
8
  export * from './Simulation';
8
9
  export * from './SyncResponse';
@@ -0,0 +1,14 @@
1
+ import { JSONSchemaType } from 'ajv';
2
+
3
+ export type MessageSchema = {
4
+ m: string; // message
5
+ }
6
+
7
+ export const messageSchema: JSONSchemaType<MessageSchema> = {
8
+ type: 'object',
9
+ properties: {
10
+ m: { type: 'string' },
11
+ },
12
+ required: ['m'],
13
+ additionalProperties: false,
14
+ }