mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Type definitions for modesl
This commit is contained in:
Vendored
+107
@@ -0,0 +1,107 @@
|
||||
// Type definitions for modesl 1.1
|
||||
// Project: https://github.com/englercj/node-esl
|
||||
// Definitions by: Nischit Ranganath <https://github.com/neeschit>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import EventEmitter = NodeJS.EventEmitter;
|
||||
export class Connection extends EventEmitter {
|
||||
constructor(...args: any[]);
|
||||
|
||||
api(command: any, args: string[], cb?: () => void): void;
|
||||
|
||||
auth(cb: () => void): void;
|
||||
|
||||
bgapi(command: any, args: string[], jobid?: any, cb?: () => void): void;
|
||||
|
||||
connected(): any;
|
||||
|
||||
disconnect(): void;
|
||||
|
||||
events(type: 'json' | 'plain' | 'xml', events: string, cb?: () => void): void;
|
||||
|
||||
execute(app: any, arg?: string, uuid?: string, cb?: () => void): any;
|
||||
|
||||
executeAsync(app: any, arg?: string, uuid?: string, cb?: () => void): any;
|
||||
|
||||
filter(header: any, value: any, cb?: () => void): void;
|
||||
|
||||
filterDelete(header: any, value: any, cb?: () => void): void;
|
||||
|
||||
getInfo(): any;
|
||||
|
||||
message(options: any, cb?: () => void): void;
|
||||
|
||||
originate(options: any, cb?: () => void): void;
|
||||
|
||||
recvEvent(cb?: () => void): void;
|
||||
|
||||
recvEventTimed(ms: any, cb?: () => void): void;
|
||||
|
||||
send(command: any, args: any): void;
|
||||
|
||||
sendEvent(event: any, cb?: () => void): void;
|
||||
|
||||
sendRecv(command: any, args: any, cb?: () => void): void;
|
||||
|
||||
setAsyncExecute(value: any): void;
|
||||
|
||||
setEventLock(value: any): void;
|
||||
|
||||
show(item: any, format: any, cb?: () => void): void;
|
||||
|
||||
socketDescriptor(): any;
|
||||
|
||||
subscribe(events: any, cb?: () => void): void;
|
||||
}
|
||||
|
||||
export interface Header {
|
||||
name: string;
|
||||
|
||||
value: string;
|
||||
}
|
||||
|
||||
export class Event {
|
||||
constructor(type: any, subclass: any);
|
||||
|
||||
headers: Header[];
|
||||
|
||||
addBody(value: any): any;
|
||||
|
||||
addHeader(name: any, value: any): any;
|
||||
|
||||
delHeader(name: any): any;
|
||||
|
||||
firstHeader(): any;
|
||||
|
||||
getBody(): any;
|
||||
|
||||
getHeader(name: any): string;
|
||||
|
||||
getType(): any;
|
||||
|
||||
nextHeader(): any;
|
||||
|
||||
serialize(format: any): any;
|
||||
|
||||
setPriority(priority: any): void;
|
||||
|
||||
static PRIORITY: {
|
||||
HIGH: string;
|
||||
LOW: string;
|
||||
NORMAL: string;
|
||||
};
|
||||
}
|
||||
export class Parser {
|
||||
constructor(socket: any);
|
||||
}
|
||||
export class Server extends EventEmitter {
|
||||
constructor(opts: any, readycb?: () => void);
|
||||
|
||||
close(callback: any): void;
|
||||
}
|
||||
export function eslSetLogLevel(level: any): void;
|
||||
|
||||
export function setLogLevel(level: any): void;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import * as modesl from 'modesl';
|
||||
|
||||
const freeswitchListener = new modesl.Server(() => {
|
||||
// console.log('Server listening on localhost at port 8022');
|
||||
});
|
||||
|
||||
|
||||
const freeswitchConnection = new modesl.Connection("freeswitch-host", 8021, 'password', () => {
|
||||
// console.log('connection initialized');
|
||||
|
||||
freeswitchConnection.api('conference', ['confname', 'dial', 'user/1006'])
|
||||
|
||||
freeswitchConnection.bgapi('conference', ['confname', 'dial', 'user/1006'], 'job-id', () => {
|
||||
// console.log('action queued');
|
||||
});
|
||||
|
||||
freeswitchConnection.events('json', 'all');
|
||||
|
||||
freeswitchConnection.subscribe('all');
|
||||
|
||||
freeswitchConnection.on('esl::event::*::*', (event: modesl.Event) => {
|
||||
const headerValue = event.getHeader('header');
|
||||
|
||||
const body = event.getBody();
|
||||
|
||||
const headers = event.headers;
|
||||
|
||||
headers.forEach((header: modesl.Header) => {
|
||||
const headerName = header.name;
|
||||
const headerValue = header.value;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"modesl-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user