How to use the events.inherits function in events

To help you get started, we’ve selected a few events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ylianst / MeshAgent / modules / amt-lme.js View on Github external
function lme_heci(options) {
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('error');
    emitterUtils.createEvent('connect');
    emitterUtils.createEvent('notify');
    emitterUtils.createEvent('bind');
    
    if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode

    var heci = require('heci');
    this.INITIAL_RXWINDOW_SIZE = 4096;
    
    this._ObjectID = "lme";
    this._LME = heci.create();
    this._LME._binded = {};
    this._LME.LMS = this;
    this._LME.on('error', function (e) { this.LMS.emit('error', e); });
    this._LME.on('connect', function () {
github Ylianst / MeshAgent / modules / upnpcp.js View on Github external
function upnpcp(search)
{
    this.searchString = search;
    if (!search.startsWith('ssdp:') && !search.startsWith('upnp:') && !search.startsWith('uuid:') && !search.startsWith('urn:'))
    {
        // Search by Friendly Name
        search = 'upnp:rootdevice';
    }

    var MSEARCH = 'M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nST: ' + search + '\r\nMAN: "ssdp:discover"\r\nMX: 5\r\nContent-Length: 0\r\n\r\n';
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('device');

    this.searchSocket = dgram.createSocket({ type: 'udp4' });
    this.searchSocket.cp = this;
    this.searchSocket.bind({ port: 0, address:'0.0.0.0' });
    this.deviceTable = {};

    this.searchSocket.on('message', upnpcp_onSearch);

    var interfaces = os.networkInterfaces();
    for(var name in interfaces)
    {
        for (var i in interfaces[name])
        {
            if (interfaces[name][i].family == 'IPv4' && interfaces[name][i].status == 'up')
            {
github Ylianst / MeshCentral / agents / modules_meshcmd / amt-lme.js View on Github external
function stream_bufferedWrite() {
    var emitterUtils = require('events').inherits(this);
    this.buffer = [];
    this._readCheckImmediate = undefined;
    this._ObjectID = "bufferedWriteStream";
    // Writable Events
    emitterUtils.createEvent('close');
    emitterUtils.createEvent('drain');
    emitterUtils.createEvent('error');
    emitterUtils.createEvent('finish');
    emitterUtils.createEvent('pipe');
    emitterUtils.createEvent('unpipe');
    
    // Readable Events
    emitterUtils.createEvent('readable');
    this.isEmpty = function () {
        return (this.buffer.length == 0);
    };
github Ylianst / MeshAgent / modules / amt-lme.js View on Github external
function stream_bufferedWrite() {
    var emitterUtils = require('events').inherits(this);
    this.buffer = [];
    this._readCheckImmediate = undefined;
    this._ObjectID = "bufferedWriteStream";
    // Writable Events
    emitterUtils.createEvent('close');
    emitterUtils.createEvent('drain');
    emitterUtils.createEvent('error');
    emitterUtils.createEvent('finish');
    emitterUtils.createEvent('pipe');
    emitterUtils.createEvent('unpipe');
    
    // Readable Events
    emitterUtils.createEvent('readable');
    this.isEmpty = function () {
        return (this.buffer.length == 0);
    };
github Ylianst / MeshAgent / modules / amt_heci.js View on Github external
function amt_heci() {
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('error');
    emitterUtils.createEvent('connect');

    var heci = require('heci');

    this._amt = heci.create();
    this._amt.BiosVersionLen = 65;
    this._amt.UnicodeStringLen = 20;

    this._amt.rq = new Q();
    this._amt.Parent = this;
    this._amt.on('error', function (e) { this.Parent.emit('error', e); });
    this._amt.on('connect', function () {
        this.Parent.emit('connect');
        this.on('data', function (chunk) {
            //console.log("Received: " + chunk.length + " bytes");
github Ylianst / MeshCentral / agents / modules_meshcore / amt_heci.js View on Github external
function amt_heci() {
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('error');
    emitterUtils.createEvent('connect');

    var heci = require('heci');

    this._amt = heci.create();
    this._amt.BiosVersionLen = 65;
    this._amt.UnicodeStringLen = 20;

    this._amt.rq = new Q();
    this._amt.Parent = this;
    this._amt.on('error', function (e) { this.Parent.emit('error', e); });
    this._amt.on('connect', function () {
        this.Parent.emit('connect');
        this.on('data', function (chunk) {
            //console.log("Received: " + chunk.length + " bytes");
github Ylianst / MeshCentral / agents / modules_meshcore / toaster.js View on Github external
this.Toast = function Toast(title, caption)
    {
        var retVal = {};
        var emitter = require('events').inherits(retVal);
        emitter.createEvent('Dismissed');

        retVal.title = title;
        retVal.caption = caption;

        if (process.platform == 'win32')
        {
            emitter.createEvent('Clicked');

            var session = require('user-sessions').Current();
            for (var i in session) {
                console.log(session[i]);
            }
            try {
                console.log('Attempting Toast Mechanism 1');
                retVal._child = require('ScriptContainer').Create({ processIsolation: true, sessionId: session.Active[0].SessionId });
github Ylianst / MeshAgent / modules / service-host.js View on Github external
function serviceHost(serviceName)
{
    this._ObjectID = 'service-host';
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('serviceStart');
    emitterUtils.createEvent('serviceStop');
    emitterUtils.createEvent('normalStart');
    emitterUtils.createEvent('session');
    emitterUtils.createEvent('powerStateChange');

    if (process.platform == 'win32')
    {
        this.GM = require('_GenericMarshal');
        this.Advapi = this.GM.CreateNativeProxy('Advapi32.dll');
        this.Advapi.CreateMethod({ method: 'StartServiceCtrlDispatcherA', threadDispatch: 1 });
        this.Advapi.CreateMethod('RegisterServiceCtrlHandlerExA');
        this.Advapi.CreateMethod('SetServiceStatus');
        this.Kernel32 = this.GM.CreateNativeProxy('Kernel32.dll');
        this.Kernel32.CreateMethod('GetLastError');
github Ylianst / MeshCentral / agents / modules_meshcore / WifiScanner.js View on Github external
function WiFiScanner()
{
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('accessPoint');

    this.hasWireless = function ()
    {
        var retVal = false;
        var interfaces = require('os').networkInterfaces();
        for (var name in interfaces)
        {
            if (interfaces[name][0].type == 'wireless') { retVal = true; break; }
        }
        return (retVal);
    };

    this.Scan = function ()
    {
        if (process.platform == 'win32')
github Ylianst / MeshAgent / modules / win-message-pump.js View on Github external
function WindowsMessagePump(options)
{
    this._ObjectID = 'win-message-pump';
    this._options = options;
    var emitterUtils = require('events').inherits(this);
    emitterUtils.createEvent('hwnd');
    emitterUtils.createEvent('error');
    emitterUtils.createEvent('message');
    emitterUtils.createEvent('exit');

    this._msg = GM.CreateVariable(GM.PointerSize == 4 ? 28 : 48);
    this._kernel32 = GM.CreateNativeProxy('Kernel32.dll');
    this._kernel32.mp = this;
    this._kernel32.CreateMethod('GetLastError');
    this._kernel32.CreateMethod('GetModuleHandleA');

    this._user32 = GM.CreateNativeProxy('User32.dll');
    this._user32.mp = this;
    this._user32.CreateMethod('CreateWindowExA');
    this._user32.CreateMethod('DefWindowProcA');
    this._user32.CreateMethod('DestroyWindow');