forked from DelxHQ/Xenia-WebServices
-
Notifications
You must be signed in to change notification settings - Fork 17
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
ad1e7da
commit 0399157
Showing
11 changed files
with
156 additions
and
23 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
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,13 +1,11 @@ | ||
import Property from 'src/domain/value-objects/Property'; | ||
import SessionId from 'src/domain/value-objects/SessionId'; | ||
import TitleId from 'src/domain/value-objects/TitleId'; | ||
|
||
export class AddSessionPropertyCommand { | ||
constructor( | ||
public readonly titleId: TitleId, | ||
public readonly sessionId: SessionId, | ||
public readonly properties: Map< | ||
number, | ||
{ propertyId: number; value: number } | ||
>, | ||
public readonly properties: Array<Property>, | ||
) {} | ||
} |
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
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
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,83 @@ | ||
import { TinyTypeOf } from 'tiny-types'; | ||
|
||
export default class Property extends TinyTypeOf<string>() { | ||
buffer: Buffer<ArrayBuffer>; | ||
data: Buffer<ArrayBuffer>; | ||
|
||
id_hex: string = ''; | ||
id: number = 0; | ||
size: number = 0; | ||
type: number = 0; | ||
|
||
public constructor(base64: string) { | ||
super(base64); | ||
|
||
this.buffer = Buffer.from(base64, 'base64'); | ||
|
||
// Check if base64 is valid | ||
if (this.buffer.toString('base64') !== base64) { | ||
throw new Error('Invalid base64'); | ||
} | ||
|
||
this.id = this.buffer.readInt32LE(0); | ||
this.type = (this.buffer.readInt32BE(0) & 0xff) >> 4; | ||
this.size = this.buffer.readInt32LE(4); | ||
|
||
const offset: number = 8; | ||
this.data = this.buffer.subarray(offset, offset + this.size); | ||
this.id_hex = this.id.toString(16); | ||
} | ||
|
||
getUTF16() { | ||
if (this.type != 4) { | ||
return ''; | ||
} | ||
|
||
const decoder = new TextDecoder('utf-16be'); | ||
|
||
let size = 0; | ||
while (size < this.data.length) { | ||
const value = this.data.readUInt16BE(size); | ||
|
||
// TextDecoder doesn't support null terminator so we need to find it | ||
if (value === 0) { | ||
break; | ||
} | ||
|
||
size += 2; | ||
} | ||
|
||
const unicode_buffer = this.data.subarray(0, size); | ||
const decoded_unicode: string = decoder.decode(unicode_buffer); | ||
|
||
return decoded_unicode; | ||
} | ||
|
||
getData() { | ||
return this.data; | ||
} | ||
|
||
getType() { | ||
return this.type; | ||
} | ||
|
||
getID() { | ||
return this.id; | ||
} | ||
|
||
getIDString() { | ||
return this.id_hex; | ||
} | ||
|
||
getSize() { | ||
return this.size; | ||
} | ||
|
||
toString(): string { | ||
return this.value; | ||
} | ||
|
||
toStringPretty() { | ||
return `ID: ${this.getIDString()} Type: ${this.getType()} Size: ${this.getSize()}`; | ||
} | ||
} |
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
src/infrastructure/presentation/responses/SessionPropertyResponse.ts
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,3 +1,3 @@ | ||
export interface SessionPropertyResponse { | ||
properties: Map<number, number>; | ||
properties: Array<string>; | ||
} |