diff --git a/src/core/client.ts b/src/core/client.ts index b4a879d..f66909b 100644 --- a/src/core/client.ts +++ b/src/core/client.ts @@ -3,7 +3,7 @@ import Long from 'long'; import path from 'path'; import tls from 'tls'; import net from 'net'; -import { load, Root } from 'protobufjs'; +import protobuf from 'protobufjs'; import { EVENTS } from './events.d.js'; import { checkIn, type CheckInOptions } from './gcm/index.js'; @@ -15,7 +15,7 @@ const HOST = 'mtalk.google.com'; const PORT = 5228; const MAX_RETRY_TIMEOUT = 15; -let proto: Root | null = null; +let proto: protobuf.Root | null = null; export interface Credentials { gcm: { @@ -57,7 +57,7 @@ export class Client extends EventEmitter { if (proto) { return; } - proto = await load(path.resolve(__dirname, 'utils', 'mcs.proto')); + proto = await protobuf.load(path.resolve(__dirname, 'utils', 'mcs.proto')); } constructor(credentials: ClientCredentials, persistentIds: string[]) { diff --git a/src/core/utils/parser.ts b/src/core/utils/parser.ts index 246083a..ccebf82 100644 --- a/src/core/utils/parser.ts +++ b/src/core/utils/parser.ts @@ -1,6 +1,6 @@ import EventEmitter from 'events'; import path from 'path'; -import { load, BufferReader, Root } from 'protobufjs'; +import protobuf from 'protobufjs'; import { ProcessingState, kVersionPacketLen, @@ -13,7 +13,7 @@ import { const DEBUG_ENABLED = false; const DEBUG = DEBUG_ENABLED ? console.log : (log: string): void => {}; -let proto: Root | null = null; +let proto: protobuf.Root | null = null; // Parser parses wire data from gcm. // This takes the role of WaitForData in the chromium connection handler. @@ -39,7 +39,7 @@ export default class Parser extends EventEmitter { if (proto) { return; } - proto = await load(path.resolve(__dirname, 'mcs.proto')); + proto = await protobuf.load(path.resolve(__dirname, 'mcs.proto')); } constructor(socket: any) { @@ -149,7 +149,7 @@ export default class Parser extends EventEmitter { private _onGotMessageSize(): void { let incompleteSizePacket = false; - const reader = new BufferReader(this._data); + const reader = new protobuf.BufferReader(this._data); try { this._messageSize = reader.int32();