Skip to content

Commit

Permalink
feat: add raw ipc event
Browse files Browse the repository at this point in the history
  • Loading branch information
Deivu committed Jul 2, 2023
1 parent 3adf944 commit d7d1e25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Indomitable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export declare interface Indomitable {
* @eventProperty
*/
on(event: 'clientReady', listener: (event: ShardEventData) => void): this;
/**
* Emitted on every ipc message the handler receives
* @eventProperty
*/
on(event: 'raw', listener: (event: unknown) => void): this;
once(event: 'debug', listener: (message: string, data?: unknown) => void): this;
once(event: 'message', listener: (message: Message|unknown) => void): this;
once(event: 'error', listener: (error: unknown) => void): this;
Expand All @@ -115,6 +120,7 @@ export declare interface Indomitable {
once(event: 'shardResume', listener: (event: ShardEventData) => void): this;
once(event: 'shardDisconnect', listener: (event: ShardEventData) => void): this;
once(event: 'clientReady', listener: (event: ShardEventData) => void): this;
once(event: 'raw', listener: (event: unknown) => void): this;
off(event: 'debug', listener: (message: string, data?: unknown) => void): this;
off(event: 'message', listener: (message: Message|unknown) => void): this;
off(event: 'error', listener: (error: unknown) => void): this;
Expand All @@ -126,6 +132,7 @@ export declare interface Indomitable {
off(event: 'shardResume', listener: (event: ShardEventData) => void): this;
off(event: 'shardDisconnect', listener: (event: ShardEventData) => void): this;
off(event: 'clientReady', listener: (event: ShardEventData) => void): this;
off(event: 'raw', listener: (event: unknown) => void): this;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export enum LibraryEvents {
SHARD_RECONNECT = 'shardReconnect',
SHARD_RESUME = 'shardResume',
SHARD_DISCONNECT = 'shardDisconnect',
CLIENT_READY = 'clientReady'
CLIENT_READY = 'clientReady',
RAW = 'raw'
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/ipc/BaseIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export abstract class BaseIpc {
*/
public async handleRawResponse(data: Serializable, errorCallback: (error: unknown) => any): Promise<boolean|void> {
try {
this.manager.emit(LibraryEvents.RAW, data);
if (!(data as any).internal)
return this.manager.emit(LibraryEvents.MESSAGE, data);
switch((data as RawIpcMessage).type) {
Expand Down

0 comments on commit d7d1e25

Please sign in to comment.