0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 03:52:17 +02:00
libsignal/node/Address.ts
Jordan Rose ad5166e814 node: Factor out loading the native module into its own file
This logic is a bit finicky and it's better not to repeat it.
2021-11-01 11:46:52 -07:00

32 lines
771 B
TypeScript

//
// Copyright 2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
import * as Native from './Native';
import NativeImpl from './NativeImpl';
export class ProtocolAddress {
readonly _nativeHandle: Native.ProtocolAddress;
private constructor(handle: Native.ProtocolAddress) {
this._nativeHandle = handle;
}
static _fromNativeHandle(handle: Native.ProtocolAddress): ProtocolAddress {
return new ProtocolAddress(handle);
}
static new(name: string, deviceId: number): ProtocolAddress {
return new ProtocolAddress(NativeImpl.ProtocolAddress_New(name, deviceId));
}
name(): string {
return NativeImpl.ProtocolAddress_Name(this);
}
deviceId(): number {
return NativeImpl.ProtocolAddress_DeviceId(this);
}
}