-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving things out of main server file
- Loading branch information
Showing
4 changed files
with
87 additions
and
62 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import assert from 'assert'; | ||
import { Flap } from './types'; | ||
|
||
/** | ||
* @see https://en.wikipedia.org/wiki/OSCAR_protocol#FLAP_header | ||
*/ | ||
export function parseFlap(msg: Buffer): Flap { | ||
const id = msg.readUInt8(0); | ||
assert(id === 0x2a, 'Unexpected Flap ID'); | ||
|
||
return { | ||
channel: msg.readUInt8(1), | ||
sequence: msg.readUInt16BE(2), | ||
byteLength: msg.readUInt16BE(4), | ||
data: msg.subarray(6), | ||
}; | ||
} |
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,13 @@ | ||
/** | ||
* @see http://web.archive.org/web/20080308233204/http://dev.aol.com/aim/oscar/#FLAP__SIGNON_FRAME | ||
*/ | ||
export function signonFlap() { | ||
const buf = Buffer.alloc(7); | ||
buf.writeUInt8(0x2a, 0); // start byte | ||
buf.writeUInt8(0x1, 1); // flap channel | ||
buf.writeUInt16BE(0x1, 2); // sequence number | ||
buf.writeUInt16BE(0x1, 4); // data size (flap version) | ||
buf.writeUInt8(0x1, 6); // flap version | ||
|
||
return buf; | ||
} |
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,9 @@ | ||
/** | ||
* @see http://web.archive.org/web/20080308233204/http://dev.aol.com/aim/oscar/#FLAP | ||
*/ | ||
export interface Flap { | ||
channel: number; | ||
sequence: number; | ||
byteLength: number; | ||
data: Buffer; | ||
} |