mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
Update mosca. (#41180)
* Add Server constructor options define. * Add detailed event callback define. * Add more test.
This commit is contained in:
Vendored
+29
-1
@@ -2,8 +2,33 @@
|
||||
// Project: https://github.com/mcollina/mosca
|
||||
// Definitions by: Joao Gabriel Gouveia <https://github.com/GabrielGouv>
|
||||
// Jerray Fu <https://github.com/jerray>
|
||||
// Ran <https://github.com/ranto2012>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TODO add detailed definition.
|
||||
// http://www.mosca.io/docs/lib/server.js.html#Server currently has no more description about this.
|
||||
export interface ServerOptions {
|
||||
port?: number;
|
||||
host?: string;
|
||||
backend?: any;
|
||||
ascoltatore?: any;
|
||||
maxInflightMessages?: number;
|
||||
logger?: any;
|
||||
persistence?: any;
|
||||
secure?: {
|
||||
port: number;
|
||||
keyPath: string;
|
||||
certPath: string;
|
||||
};
|
||||
allowNonSecure?: boolean;
|
||||
http?: {
|
||||
port: number;
|
||||
};
|
||||
bundle?: any;
|
||||
static?: any;
|
||||
stats?: any;
|
||||
}
|
||||
|
||||
export class Server {
|
||||
id: string;
|
||||
opts: any;
|
||||
@@ -11,9 +36,12 @@ export class Server {
|
||||
clients: any;
|
||||
closed: boolean;
|
||||
|
||||
constructor(opts: any, callback?: () => void);
|
||||
constructor(opts: ServerOptions, callback?: () => void);
|
||||
|
||||
on(when: string, callback: (() => void) | ((client: Client) => void) | ((packet: Packet, client: Client) => void)): void;
|
||||
on(when: 'clientConnected' | 'clientDisconnecting' | 'clientDisconnected', callback: (client: Client) => void): void;
|
||||
on(when: 'subscribed' | 'unsubscribed', callback: (topic: string, client: Client) => void): void;
|
||||
on(when: 'published', callback: (packet: Packet, client: Client) => void): void;
|
||||
once(when: string, callback: () => void): void;
|
||||
toString(): string;
|
||||
subscribe(topic: string, callback: () => void, done: () => void): void;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Server, Client, Packet } from 'mosca';
|
||||
import { Server, Client, Packet, ServerOptions } from 'mosca';
|
||||
|
||||
const settings = {
|
||||
const settings: ServerOptions = {
|
||||
port: 1883,
|
||||
host: '0.0.0.0'
|
||||
};
|
||||
@@ -14,3 +14,5 @@ server.on('clientConnected', (client: Client) => {});
|
||||
server.on('clientDisconnected', (client: Client) => {});
|
||||
|
||||
server.on('published', (packet: Packet, client: Client) => {});
|
||||
|
||||
server.on('subscribed', (topic: string, client: Client) => {});
|
||||
|
||||
Reference in New Issue
Block a user