Code Monkey home page Code Monkey logo

js-adapter's Introduction

Hadouken Node.js adapter Build Status

Allows the use of the Hadouken API from node.js.

Requirements

  • Node.js LTS ^6.9

Install as dependency

$ npm install -S hadouken-js-adapter

Usage

Connecting to an already running runtime

const { connect, Identity } = require("hadouken-js-adapter");

async function launchApp() {
    const fin  = await connect({
        address: "ws://localhost:9696",
        uuid: "my-uuid-123"
    });

    const version = await fin.System.getVersion();
    console.log("Connected to Hadouken version", version);

    await fin.Application.start({
        name: "adapter-test-app",
        url: 'http://hadouken.io/',
        uuid: "adapter-test-app",
        autoShow: true,
        nonPersistent : true
    });
}

launchApp().then(() => {
    console.log("success");
}).catch((err) => {
    console.log("Error trying to connect,", err.message);
    console.log(err.stack);
});

Launching a runtime and connecting

const { connect, Identity } = require("hadouken-js-adapter");

async function launchApp() {
    const fin  = await connect({
        uuid: "my-uuid-123",
        runtime: {
            version: 'stable'
        }
    });

    const version = await fin.System.getVersion();
    console.log("Connected to Hadouken version", version);

    await fin.Application.start({
        name: "adapter-test-app",
        url: 'http://hadouken.io/',
        uuid: "adapter-test-app",
        autoShow: true,
        nonPersistent : true
    });
}

launchApp().then(() => {
    console.log("success");
}).catch((err) => {
    console.log("Error trying to connect,", err.message);
    console.log(err.stack);
});

Note that either an address or a runtime object with version are required to connect

Mac and Linux Environment settings

In order to configure system policies, the js adapter respects the following group policy settings when set as environment variables on Mac and Linux:

  • assetsUrl
  • runtimeArgs
  • runtimeDirectory

Local build

npm run build

Test

npm test -- --ver=alpha

Only executing tests that pattern match "Application"

npm test -- --ver=alpha --grep="Application"

Executing tests that do not pattern match "System"

npm test -- --ver=alpha --invert --grep="System"

Test with core

npm test -- --ver=alpha --build-core --core=~/core

or without specifying the core path (core will be cloned from GH into core directory):

npm test -- --ver=alpha --build-core

Repl

To start the read-eval-print loop:

npm run repl -- --ver=alpha

Generated documentation

We use JSDoc for documentation and generating the documentation will require our custom JSDoc template. Use the following commands to execute the docs task:

git submodule init
git submodule update
npm run doc

Contributing

  1. Fork it (https://github.com/HadoukenIO/js-adapter/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Read our contribution guidelines and Community Code of Conduct
  4. Commit your changes (git commit -am 'Add some fooBar')
  5. Push to the branch (git push origin feature/fooBar)
  6. Create a new Pull Request

NOTE: Commits and pull requests to FINOS repositories will only be accepted from those contributors with an active, executed Individual Contributor License Agreement (ICLA) with FINOS OR who are covered under an existing and active Corporate Contribution License Agreement (CCLA) executed with FINOS. Commits from individuals not covered under an ICLA or CCLA will be flagged and blocked by the FINOS Clabot tool. Please note that some CCLAs require individuals/employees to be explicitly named on the CCLA.

Need an ICLA? Unsure if you are covered under an existing CCLA? Email [email protected]

License

The code in this repository is distributed under the Apache License, Version 2.0

However, if you run this code, it may call on the OpenFin RVM or OpenFin Runtime, which are covered by OpenFin's Developer, Community, and Enterprise licenses. You can learn more about OpenFin licensing at the links listed below or just email us at [email protected] with questions.

Copyright 2018-2019 OpenFin

https://openfin.co/developer-agreement/

https://openfin.co/licensing/

js-adapter's People

Contributors

agitana avatar andregarvin avatar anguslim avatar aziz512 avatar ben-drebing avatar bschwinn avatar chuckdoerr avatar datamadic avatar dcchuck avatar dhamberlin avatar harsimransingh avatar licui3936 avatar luiemilio avatar michaelmcoates avatar ngunday avatar nikoganev avatar ottah avatar pbaize avatar rdepena avatar sbloodgood avatar stevenebarbaro avatar tgoc99 avatar tomer-openfin avatar vp2177 avatar wenjunche avatar whyn07m3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-adapter's Issues

Websocket connection closed over time. "Expected websocket state OPEN but found CLOSED"

hadouken-js-adapter version: 1.44.1

Our application opens a connection to an openfin runtime to subscribe to messages on the InterApplication bus and to check if an app with a given uuid exists.

However, if some time passes after calling connect, we get the following error: Expected websocket state OPEN but found CLOSED.

For example:

      const fin = await connect({
        uuid: uuidV4(),
        runtime: {
          version: 'stable'
        }
      });

...
// elsewhere in the code a few seconds later
fin.System.resolveUuid('1234');
// error thrown: Expected websocket state OPEN but found CLOSED

Notes:

  • Seeing the same behaviour in hadouken-js-adapter version 0.42.2
  • For context, nonPersistent is set to false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.