2.0.7-5 • Published 12 months ago

guruway v2.0.7-5

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Build Status

Thruway.js

This project is a WAMP v2 client written in TypeScript that uses RxJS v5 Observables instead of promises and event emitters. It's designed to work with modern frontend frameworks like Angular v2/4 as well as node.js.

If you don't know what WAMP is, you should read up on it.

If you don't know what RxJS or ReactiveExtensions is, you're missing out...

note: This library is stable, but may not have all of the WAMP features implemented. Since this project originated as an internal project for Voryx, the features are limited to only the ones that were needed.

Installation

npm install thruway.js
npm install rxjs
npm install ws // only when using with Node

Usage

import {Client} from "thruway.js";

const wamp = new Client('ws://localhost:9090', 'realm1');

Call

wamp.call('add.rpc', [1, 2])
    .map((r: ResultMessage) => r.args[0])
    .subscribe(r => console.log(r));

Register

wamp.register('add.rpc', (a, b) => a + b).subscribe();

If you need keyword arguments, you can set the extended option.

wamp.register('add.rpc', (args, argskw) => argskw.a + argskw.b, {extended: true}).subscribe();

Publish to topic

wamp.publish('example.topic', 'some value');
wamp.publish('example.topic', Observable.interval(1000)); // you can also publish an observable

Subscribe to topic

wamp.topic('example.topic').subscribe((v)=>console.log(v));

Angular Example

Create a wamp service

import {Injectable} from '@angular/core';
import {Client} from 'thruway.js';

@Injectable()
export class WampService extends Client {
    constructor() {
        super('wss://demo.crossbar.io/ws', 'realm1');
    }
}

Inject and use the service in your component

import {Component} from '@angular/core';
import {WampService} from '../wamp.service';
import {Observable} from 'rxjs/Observable';
import {EventMessage} from 'thruway.js/src/Messages/EventMessage';

@Component({
    selector: 'app-counter',
    template: '<span>{{counter | async}}</span>'
})
export class CounterComponent {
    counter: Observable<number> = this.wamp
        .topic('com.myapp.counter')
        .map((r: EventMessage) => r.args[0]);

    constructor(private wamp: WampService) {}
}

Node Example

const Thruway = require("thruway.js");
const Rx = require("rxjs");

const wamp = new Thruway.Client('wss://demo.crossbar.io/ws', 'realm1');

wamp.publish('com.myapp.counter', Rx.Observable.interval(1000));

PHP Example

Install the RxThruway Client

composer require rx/thruway-client
<?php

use Rx\Observable;
use Rx\Thruway\Client;

require __DIR__ . '/vendor/autoload.php';

$wamp = new Client('wss://demo.crossbar.io/ws', 'realm1');

$wamp->publish('com.myapp.counter', Observable::interval(1000));
acornajvajv-errorsajv-keywordsansi-colorsansi-regexansi-stylesanymatchaprobaargparsearr-diffarr-flattenarr-unionarray-filterarray-maparray-reducearray-uniquearrifyasapasn1.jsassertassertion-errorassign-symbolsasync-eachasync-limiteratobbabel-code-framebalanced-matchbasebase64-jsbig.jsbinary-extensionsbluebirdbn.jsbrace-expansionbracesbrorandbrowser-stdoutbrowserify-aesbrowserify-cipherbrowserify-desbrowserify-rsabrowserify-signbrowserify-zlibbufferbuffer-frombuffer-xorbuiltin-modulesbuiltin-status-codescacachecache-basecamelcasechalkchokidarchownrchrome-trace-eventcipher-baseclass-utilscliuicollection-visitcolor-convertcolor-namecommandercommondircomponent-emitterconcat-mapconcat-streamconsole-browserifyconstants-browserifycopy-concurrentlycopy-descriptorcore-util-iscreate-ecdhcreate-hashcreate-hmaccross-spawncrypto-browserifycyclistdate-nowdebugdecamelizedecode-uri-componentdeep-eqldefine-propertiesdefine-propertydes.jsdetect-filediffdiffie-hellmandomain-browserduplexerduplexifyellipticemoji-regexemojis-listend-of-streamenhanced-resolveerrnoerror-exes-abstractes-to-primitiveeslint-scopeesprimaesrecurseestraverseesutilsevent-streameventsevp_bytestokeyexecaexpand-bracketsexpand-tildeextend-shallowextglobfast-deep-equalfast-json-stable-stringifyfiggy-puddingfill-rangefind-cache-dirfind-upfindup-syncflatflush-write-streamfor-informatiofragment-cachefromfrom2fs-write-stream-atomicfs.realpathfunction-bindget-caller-fileget-streamget-valueglobglob-parentglobal-modulesglobal-prefixgraceful-fsgrowlhashas-ansihas-flaghas-symbolshas-valuehas-valueshash-basehash.jshehmac-drbghomedir-polyfillhosted-git-infohttps-browserifyieee754iferrimport-localimurmurhashinfer-ownerinflightinheritsiniinterpretinvert-kvis-accessor-descriptoris-arrayishis-binary-pathis-bufferis-builtin-moduleis-callableis-data-descriptoris-date-objectis-descriptoris-extendableis-extglobis-fullwidth-code-pointis-globis-numberis-plain-objectis-regexis-streamis-symbolis-utf8is-windowsis-wslisarrayisexeisobjectjs-tokensjs-yamljson-parse-better-errorsjson-schema-traversejson5jsonifykind-oflcidload-json-fileloader-runnerloader-utilslocate-pathlodash.debouncelog-symbolslolexlru-cachemake-dirmake-errormamacromap-age-cleanermap-cachemap-streammap-visitmd5.jsmemmemory-fsmicromatchmiller-rabinmimic-fnminimalistic-assertminimalistic-crypto-utilsminimatchminimistmississippimixin-deepmkdirpmove-concurrentlymsnanomatchnative-promise-onlyneo-asyncnice-trynode-environment-flagsnode-libs-browsernormalize-package-datanormalize-pathnpm-run-pathobject-assignobject-copyobject-inspectobject-keysobject-visitobject.assignobject.getownpropertydescriptorsobject.pickonceos-browserifyos-localep-deferp-finallyp-is-promisep-limitp-locatep-trypakoparallel-transformparse-asn1parse-jsonparse-passwdpascalcasepath-browserifypath-dirnamepath-existspath-is-absolutepath-keypath-parsepath-to-regexppath-typepause-streampbkdf2picomatchpifypinkiepinkie-promisepkg-dirposix-character-classesprocessprocess-nextick-argspromise-inflightprrps-treepseudomappublic-encryptpumppumpifypunycodequerystringquerystring-es3randombytesrandomfillread-pkgread-pkg-upreadable-streamreaddirprechoirregex-notremove-trailing-separatorrepeat-elementrepeat-stringrequire-directoryrequire-main-filenameresolveresolve-cwdresolve-dirresolve-fromresolve-urlretrimrafripemd160run-queuesafe-buffersafe-regexsamsamschema-utilssemverserialize-javascriptset-blockingset-immediate-shimset-valuesetimmediatesha.jsshebang-commandshebang-regexshell-quoteshelljssignal-exitsnapdragonsnapdragon-nodesnapdragon-utilsource-list-mapsource-mapsource-map-resolvesource-map-supportsource-map-urlspdx-correctspdx-exceptionsspdx-expression-parsespdx-license-idssplitsplit-stringsprintf-jsssristatic-extendstream-browserifystream-combinerstream-eachstream-httpstream-shiftstring_decoderstring-widthstring.prototype.padendstring.prototype.trimleftstring.prototype.trimrightstrip-ansistrip-bomstrip-eofstrip-json-commentssupports-colortapableterserterser-webpack-plugintext-encodingthroughthrough2timers-browserifyto-arraybufferto-object-pathto-regexto-regex-rangetsconfigtslibtsutilstty-browserifytype-detecttypedarrayunion-valueunique-filenameunique-slugunset-valueupathuri-jsurixurluseutilutil-deprecatev8-compile-cachev8flagsvalidate-npm-package-licensevm-browserifywatchpackwebpack-sourceswhichwhich-modulewide-alignworker-farmwrap-ansiwrappyxtendy18nyallistyargsyargs-parseryargs-unparseryn
2.0.7-5

12 months ago

2.0.7-4

12 months ago