Skip to content

Commit

Permalink
Types: Add listen function
Browse files Browse the repository at this point in the history
+ Replace any with proper types.
  • Loading branch information
orgads committed Jan 23, 2025
1 parent 3b61b05 commit eb12116
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ declare namespace Srf {
type Via = { version: string; protocol: string; host: string; port: string; };

export interface SrfConfig {
apiSecret?: string;
host?: string;
port?: number;
secret?: string;
logger?: (message: string) => void;
}

interface ParseUriResult {
Expand Down Expand Up @@ -60,9 +60,9 @@ declare namespace Srf {
callId: string;
from: string;
headers: Record<string, string>;
msg: any;
msg: SipMessage;
sdp: string;
srf: any;
srf: Srf;
to: string;
uri: string;
registration?: {
Expand Down Expand Up @@ -93,7 +93,7 @@ declare namespace Srf {
end(): void;
}

export interface Dialog {
export class Dialog extends EventEmitter {
sip: { callId: string; localTag: string; remoteTag: string; };
onHold: boolean;
other: Dialog;
Expand All @@ -106,19 +106,18 @@ declare namespace Srf {
modify(opts: { noAck: boolean }): Promise<string>;
modify(sdp: string, opts?: { noAck: boolean }, callback?: (err: any, msg: SrfResponse) => void): void;
modify(opts: { noAck: boolean }, callback?: (err: any, resp?: string, resAck?: (sdp: string) => void) => void): void;
on(messageType: "ack", callback: (msg: SrfRequest) => void): void;
on(messageType: "destroy", callback: (msg: SrfRequest) => void): void;
on(messageType: "info", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "message", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "modify", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "notify", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "options", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "refer", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "refresh", callback: (msg: SrfRequest) => void): void;
on(messageType: "update", callback: (req: SrfRequest, res: SrfResponse) => void): void;
on(messageType: "modify", callback: (req: SrfRequest, res: SrfResponse) => void): void;
once(messageType: string, callback: (msg: SrfResponse) => void): void;
listeners(messageType: string): any[];
on(messageType: "ack", callback: (msg: SrfRequest) => void): this;
on(messageType: "destroy", callback: (msg: SrfRequest) => void): this;
on(messageType: "info", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "message", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "modify", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "notify", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "options", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "refer", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "refresh", callback: (msg: SrfRequest) => void): this;
on(messageType: "update", callback: (req: SrfRequest, res: SrfResponse) => void): this;
on(messageType: "modify", callback: (req: SrfRequest, res: SrfResponse) => void): this;
once(messageType: string, callback: (msg: SrfResponse) => void): this;
request(opts?: SrfRequest): Promise<SrfResponse>;
request(opts: SrfRequest, callback?: (err: any, msg: SrfResponse) => void): void;
}
Expand Down Expand Up @@ -155,6 +154,7 @@ declare class Srf extends EventEmitter {
constructor();
constructor(tags: string | string[]);
connect(config?: Srf.SrfConfig): Promise<void>;
listen(opts?: Srf.SrfConfig): Promise<void>;
disconnect(): void;
use(callback: (req: Srf.SrfRequest, res: Srf.SrfResponse, next: Function) => void): void;
use(messageType: string, callback: (req: Srf.SrfRequest, res: Srf.SrfResponse, next: Function) => void): void;
Expand Down

0 comments on commit eb12116

Please sign in to comment.