From 642bfd825a15117bfa38c5dd90159b144367c8ab Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Wed, 9 Apr 2025 20:16:51 +0300 Subject: [PATCH] usync: add lid protocol --- src/WAUSync/Protocols/UsyncLIDProtocol.ts | 25 +++++++++++++++++++++++ src/WAUSync/USyncQuery.ts | 4 ++++ 2 files changed, 29 insertions(+) create mode 100644 src/WAUSync/Protocols/UsyncLIDProtocol.ts diff --git a/src/WAUSync/Protocols/UsyncLIDProtocol.ts b/src/WAUSync/Protocols/UsyncLIDProtocol.ts new file mode 100644 index 0000000..54508ea --- /dev/null +++ b/src/WAUSync/Protocols/UsyncLIDProtocol.ts @@ -0,0 +1,25 @@ +import { USyncQueryProtocol } from '../../Types/USync' +import { BinaryNode } from '../../WABinary' + +export class USyncLIDProtocol implements USyncQueryProtocol { + name = 'lid' + + getQueryElement(): BinaryNode { + return { + tag: 'lid', + attrs: {}, + } + } + + getUserElement(): null { + return null + } + + parser(node: BinaryNode): string | null { + if(node.tag === 'lid') { + return node.attrs.val + } + + return null + } +} diff --git a/src/WAUSync/USyncQuery.ts b/src/WAUSync/USyncQuery.ts index 18753b4..c52cbba 100644 --- a/src/WAUSync/USyncQuery.ts +++ b/src/WAUSync/USyncQuery.ts @@ -108,4 +108,8 @@ export class USyncQuery { return this } + withLIDProtocol() { + this.protocols.push(new USyncLIDProtocol()) + return this + } }