fix function signature for createserver (#45386)

This commit is contained in:
Tamas Mezei 2020-06-23 21:16:35 +02:00 committed by GitHub
parent ec066e7aa9
commit 461ecd94e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -46,8 +46,8 @@ declare module 'xmlrpc' {
function createClient(options: string | ClientOptions): Client;
function createSecureClient(options: string | ClientOptions): Client;
function createServer(options: string | ServerOptions, callback: () => void): Server;
function createSecureServer(options: string | TlsOptions, callback: () => void): Server;
function createServer(options: string | ServerOptions, callback?: () => void): Server;
function createSecureServer(options: string | TlsOptions, callback?: () => void): Server;
interface Client {
options: ClientOptions;

View File

@ -5,12 +5,14 @@ const serverOpts = {
port: 9000
};
const server = xmlrpc.createServer(serverOpts, () => {
server.on('NotFound', method => {
const serverWithOutCallback = xmlrpc.createServer(serverOpts);
const serverWithCallback = xmlrpc.createServer(serverOpts, () => {
serverWithCallback.on('NotFound', method => {
console.log(`Method ${method} not found`);
})
server.on('hello', (err, params, cb) => {
serverWithCallback.on('hello', (err, params, cb) => {
cb(null, `Hello, ${params[0]}!`);
});