-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52b2bfb
commit 6651154
Showing
6 changed files
with
71 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
protocol/src/main/resources/ecmascript/ProtocolClassTemplate.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,4 @@ | ||
${protocol_note} | ||
class ${protocol_name} { | ||
${protocol_field_definition} | ||
|
||
static PROTOCOL_ID = ${protocol_id}; | ||
|
||
protocolId() { | ||
return ${protocol_name}.PROTOCOL_ID; | ||
} | ||
|
||
static write(buffer, packet) { | ||
if (packet === null) { | ||
buffer.writeInt(0); | ||
return; | ||
} | ||
${protocol_write_serialization} | ||
} | ||
|
||
static read(buffer) { | ||
const length = buffer.readInt(); | ||
if (length === 0) { | ||
return null; | ||
} | ||
const beforeReadIndex = buffer.getReadOffset(); | ||
const packet = new ${protocol_name}(); | ||
${protocol_read_deserialization} | ||
if (length > 0) { | ||
buffer.setReadOffset(beforeReadIndex + length); | ||
} | ||
return packet; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
protocol/src/main/resources/ecmascript/ProtocolRegistrationTemplate.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export class ${protocol_name}Registration { | ||
protocolId() { | ||
return ${protocol_id}; | ||
} | ||
|
||
write(buffer, packet) { | ||
if (packet === null) { | ||
buffer.writeInt(0); | ||
return; | ||
} | ||
${protocol_write_serialization} | ||
} | ||
|
||
read(buffer) { | ||
const length = buffer.readInt(); | ||
if (length === 0) { | ||
return null; | ||
} | ||
const beforeReadIndex = buffer.getReadOffset(); | ||
const packet = new ${protocol_name}(); | ||
${protocol_read_deserialization} | ||
if (length > 0) { | ||
buffer.setReadOffset(beforeReadIndex + length); | ||
} | ||
return packet; | ||
} | ||
} |
32 changes: 2 additions & 30 deletions
32
protocol/src/main/resources/ecmascript/ProtocolTemplate.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
${protocol_note} | ||
class ${protocol_name} { | ||
${protocol_field_definition} | ||
${protocol_class} | ||
|
||
static PROTOCOL_ID = ${protocol_id}; | ||
${protocol_registration} | ||
|
||
protocolId() { | ||
return ${protocol_name}.PROTOCOL_ID; | ||
} | ||
|
||
static write(buffer, packet) { | ||
if (packet === null) { | ||
buffer.writeInt(0); | ||
return; | ||
} | ||
${protocol_write_serialization} | ||
} | ||
|
||
static read(buffer) { | ||
const length = buffer.readInt(); | ||
if (length === 0) { | ||
return null; | ||
} | ||
const beforeReadIndex = buffer.getReadOffset(); | ||
const packet = new ${protocol_name}(); | ||
${protocol_read_deserialization} | ||
if (length > 0) { | ||
buffer.setReadOffset(beforeReadIndex + length); | ||
} | ||
return packet; | ||
} | ||
} | ||
export default ${protocol_name}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
class Protocols { | ||
} | ||
|
||
${protocol_class} | ||
|
||
${protocol_registration} | ||
|
||
export default Protocols; | ||
${protocol_registration} |