@dcl/ecs 7.0.6-3824930139.commit-9bd6c05 → 7.0.6-3832097301.commit-4e46b20

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.
@@ -1,41 +0,0 @@
1
- /**
2
- * The wire message is the top-level message that can be packed
3
- * inside it can contain a data with another structure or protocol
4
- *
5
- * Each wire message has three primitive property that it'll never change
6
- * ---> length uint32 (message size up to 4,294,967,295)
7
- * ---> version uint32 (for now just a number which is zero)
8
- * ---> message type uint32
9
- * The length indicates how many bytes are above self, the version in
10
- * combination with message type defines the set of handlers that will be
11
- * available to process the message
12
- *
13
- */
14
- import { ComponentDefinition, Entity } from '../engine';
15
- import { ByteBuffer } from './ByteBuffer';
16
- export declare namespace WireMessage {
17
- type Uint32 = number;
18
- enum Enum {
19
- RESERVED = 0,
20
- PUT_COMPONENT = 1,
21
- DELETE_COMPONENT = 2,
22
- MAX_MESSAGE_TYPE = 3
23
- }
24
- /**
25
- * @param length - Uint32 the length of all message (including the header)
26
- * @param type - define the function which handles the data
27
- */
28
- type Header = {
29
- length: Uint32;
30
- type: Uint32;
31
- };
32
- const HEADER_LENGTH = 8;
33
- /**
34
- * Validate if the message incoming is completed
35
- * @param buf - ByteBuffer
36
- */
37
- function validate(buf: ByteBuffer): boolean;
38
- function readHeader(buf: ByteBuffer): Header | null;
39
- function getType(component: ComponentDefinition<unknown>, entity: Entity): Enum;
40
- }
41
- export default WireMessage;
@@ -1,56 +0,0 @@
1
- /**
2
- * The wire message is the top-level message that can be packed
3
- * inside it can contain a data with another structure or protocol
4
- *
5
- * Each wire message has three primitive property that it'll never change
6
- * ---> length uint32 (message size up to 4,294,967,295)
7
- * ---> version uint32 (for now just a number which is zero)
8
- * ---> message type uint32
9
- * The length indicates how many bytes are above self, the version in
10
- * combination with message type defines the set of handlers that will be
11
- * available to process the message
12
- *
13
- */
14
- export var WireMessage;
15
- (function (WireMessage) {
16
- let Enum;
17
- (function (Enum) {
18
- Enum[Enum["RESERVED"] = 0] = "RESERVED";
19
- // Component Operation
20
- Enum[Enum["PUT_COMPONENT"] = 1] = "PUT_COMPONENT";
21
- Enum[Enum["DELETE_COMPONENT"] = 2] = "DELETE_COMPONENT";
22
- Enum[Enum["MAX_MESSAGE_TYPE"] = 3] = "MAX_MESSAGE_TYPE";
23
- })(Enum = WireMessage.Enum || (WireMessage.Enum = {}));
24
- WireMessage.HEADER_LENGTH = 8;
25
- /**
26
- * Validate if the message incoming is completed
27
- * @param buf - ByteBuffer
28
- */
29
- function validate(buf) {
30
- const rem = buf.remainingBytes();
31
- if (rem < WireMessage.HEADER_LENGTH) {
32
- return false;
33
- }
34
- const messageLength = buf.getUint32(buf.currentReadOffset());
35
- if (rem < messageLength) {
36
- return false;
37
- }
38
- return true;
39
- }
40
- WireMessage.validate = validate;
41
- function readHeader(buf) {
42
- if (!validate(buf)) {
43
- return null;
44
- }
45
- return {
46
- length: buf.readUint32(),
47
- type: buf.readUint32()
48
- };
49
- }
50
- WireMessage.readHeader = readHeader;
51
- function getType(component, entity) {
52
- return component.has(entity) ? Enum.PUT_COMPONENT : Enum.DELETE_COMPONENT;
53
- }
54
- WireMessage.getType = getType;
55
- })(WireMessage || (WireMessage = {}));
56
- export default WireMessage;