Skip to content

Commit

Permalink
refactor: split constructor and parsing for Message implementations
Browse files Browse the repository at this point in the history
first pass
  • Loading branch information
AlCalzone committed Oct 22, 2024
1 parent 62e6cfd commit 18a179e
Show file tree
Hide file tree
Showing 47 changed files with 2,701 additions and 1,243 deletions.
5 changes: 3 additions & 2 deletions packages/cc/src/lib/CommandClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export class CCRaw {
return new CCRaw(this.ccId, this.ccCommand, payload);
}

// FIXME: Use this?
public serialize(): Buffer {
const ccIdLength = this.ccId >= 0xf100 ? 2 : 1;
const data = Buffer.allocUnsafe(ccIdLength + 1 + this.payload.length);
Expand Down Expand Up @@ -226,10 +227,10 @@ export class CommandClass implements CCId {
}

public static parse(
payload: Buffer,
data: Buffer,
ctx: CCParsingContext,
): CommandClass {
const raw = CCRaw.parse(payload);
const raw = CCRaw.parse(data);

// Find the correct subclass constructor to invoke
const CCConstructor = getCCConstructor(raw.ccId);
Expand Down
Loading

0 comments on commit 18a179e

Please sign in to comment.