mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-01 11:50:54 +08:00
add: type definitions for wake_on_lan
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/// <reference path="wake_on_lan.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import wol = require('wake_on_lan');
|
||||
|
||||
wol.wake("20:DE:20:DE:20:DE");
|
||||
|
||||
let errFunc:wol.ErrorCallback = function(error:any) {
|
||||
if (error) {
|
||||
// handle error
|
||||
} else {
|
||||
// done sending packets
|
||||
}
|
||||
};
|
||||
|
||||
var opts:wol.WakeOptions = { address: "192.168.1.1" };
|
||||
var opts1:wol.WakeOptions = { address: "192.168.1.1", num_packets: 3 };
|
||||
var opts2:wol.WakeOptions = { address: "192.168.1.1", num_packets: 3, interval: 4 };
|
||||
var opts3:wol.WakeOptions = { address: "192.168.1.1", num_packets: 3, interval: 4, port: 5 };
|
||||
var opts4:wol.WakeOptions = { address: "192.168.1.1" };
|
||||
var opts5:wol.WakeOptions = { address: "192.168.1.1", interval: 4 };
|
||||
var opts6:wol.WakeOptions = { address: "192.168.1.1", port: 5 };
|
||||
var opts7:wol.WakeOptions = { address: "192.168.1.1", interval: 4, port: 5 };
|
||||
var opts8:wol.WakeOptions = { num_packets: 3 };
|
||||
var opts9:wol.WakeOptions = { num_packets: 3, interval: 4 };
|
||||
var opts10:wol.WakeOptions = { num_packets: 3, port: 5 };
|
||||
var opts11:wol.WakeOptions = { num_packets: 3, interval: 4, port: 5 };
|
||||
var opts12:wol.WakeOptions = { interval: 4 };
|
||||
var opts13:wol.WakeOptions = { interval: 4, port: 5 };
|
||||
var opts14:wol.WakeOptions = { port: 5 };
|
||||
var opts15:wol.WakeOptions = { };
|
||||
|
||||
wol.wake('20:DE:20:DE:20:DE');
|
||||
wol.wake('20:DE:20:DE:20:DE', opts);
|
||||
wol.wake('20:DE:20:DE:20:DE', errFunc);
|
||||
wol.wake('20:DE:20:DE:20:DE', opts, errFunc);
|
||||
|
||||
|
||||
var magic_packet:Buffer = wol.createMagicPacket('20:DE:20:DE:20:DE');
|
||||
Vendored
+74
@@ -0,0 +1,74 @@
|
||||
// Type definitions for wake_on_lan
|
||||
// Project: https://github.com/agnat/node_wake_on_lan
|
||||
// Definitions by: Tobias Kahlert <https://github.com/SrTobi>
|
||||
// Definitions: https://github.com/SrTobi/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
declare module wol {
|
||||
|
||||
export interface WakeOptions {
|
||||
|
||||
/**
|
||||
* The ip address to which the packet is send (default: 255.255.255.255)
|
||||
*/
|
||||
address?:string;
|
||||
|
||||
/**
|
||||
* Number of packets to send (default: 3)
|
||||
*/
|
||||
num_packets?:number;
|
||||
|
||||
/**
|
||||
* The interval between packets (default: 100ms)
|
||||
*/
|
||||
interval?:number;
|
||||
|
||||
/**
|
||||
* The port to send to (default: 9)
|
||||
*/
|
||||
port?:number;
|
||||
}
|
||||
|
||||
type ErrorCallback = (Error:any) => void;
|
||||
|
||||
export interface Wol {
|
||||
/**
|
||||
* Send a sequence of Wake-on-LAN magic packets to the given MAC address.
|
||||
*
|
||||
* @param {string} macAddress the mac address of the target device
|
||||
*/
|
||||
wake(macAddress:string):void;
|
||||
|
||||
/**
|
||||
* Send a sequence of Wake-on-LAN magic packets to the given MAC address.
|
||||
*
|
||||
* @param {string} macAddress the mac address of the target device
|
||||
* @param {ErrorCallback} callback is called when all packets have been sent or an error occurs.
|
||||
*/
|
||||
wake(macAddress:string, callback:ErrorCallback):void;
|
||||
|
||||
/**
|
||||
* Send a sequence of Wake-on-LAN magic packets to the given MAC address.
|
||||
*
|
||||
* @param {string} macAddress the mac address of the target device
|
||||
* @param {WakeOptions} opts additional options to send the packet
|
||||
* @param {ErrorCallback} callback is called when all packets have been sent or an error occurs.
|
||||
*/
|
||||
wake(macAddress:string, opts:WakeOptions, callback?:Function):void;
|
||||
|
||||
/**
|
||||
* Creates a buffer with a magic packet for the given MAC address.
|
||||
*
|
||||
* @param {string} macAddress mac address of the target device
|
||||
* @return {Buffer} the magic packet
|
||||
*/
|
||||
createMagicPacket(macAddress:string):Buffer;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'wake_on_lan' {
|
||||
var wol: wol.Wol;
|
||||
export = wol;
|
||||
}
|
||||
Reference in New Issue
Block a user