Giter Site home page Giter Site logo

thruway.js's People

Contributors

27leaves avatar aaronbonneau avatar davidwdan avatar dependabot[bot] avatar h0schi avatar mbonneau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

thruway.js's Issues

WebSocket reconecting after client close

Hi. In my project I need to close WebSocket session until user fills required data. When i am doing that using Client "close" method, it is again trying to reconnect. Can i disable reconnect option?

There is no way to change Client authid

In my app I need first to start anonymous connection. After that i get access token, which one i use as authid. So far i haven't seen a way to change authid for a client.
Currently i am recreating client with new authid. Is there better way?

Angular 8 compability: rxjs 6.5.3

When i tried to upgrade my angular app from version 7.x to version 8.x, this error occured: Package "thruway.js" has an incompatible peer dependency to "rxjs" (requires "^5.5.12", would install "6.5.3").

Connection events

I'd need to get some connection state events, like in autobahn with onopen and onclose. Is this already possible with thruway?

CALL with progressive Result, value in last progress=false message are lost by takeWhile filter

Hello,

I evaluate the thruway.js WAMP Client (Angular2) and noticed that the last CALL Result's are missing if a CALL is progressive.

Szenario:
CALLER -(CALL)-> DEALER
CALLER <-(RESULT progress=true)- DEALER
CALLER <-(RESULT progress=true)- DEALER
CALLER <-(RESULT progress=true)- DEALER
CALLER <-(RESULT )- DEALER

I noticed in CallObservable.js Line 57 CallObservable.prototype._subscribe

      const resultMsg = msg
            .takeWhile(m => m.details.progress || false)
            .finally(() => this.completed = true)
              .share();

The TakeWhile seems not to be inclusive ... the last message is not forwarded to next(value) on subscribers. Perhaps the problem is at a different point... but adding a workaround after a 5-minute-rxjs-tutorial is adding this:

 var resultMsg = msg
            .do (function (m) { 
                if (m && ! m.details.progress || false)
                {
                        this.next(null);
                }
            })
            .takeWhile(function (m) { 
                return m /*&& m.details.progress || false*/; 
            })
            .finally(function () { return _this.completed = true; })
            .share();

I hope this is right: next(null) will inject an empty message -> which will stop takeWhile.....

Any Comments ? I don't know exact if this is a 'good' solution ;)

Update:
used '1.3.0-beta2': '2018-02-22T13:13:37.287Z' installed by npm

RxJs 6 / Angular 6 Compatibility

Hi,
First of all, thank you for the nice job you've done with this library !
I was wondering if you're planning to release a version based on RxJs 6 (as Angular 6 just did) ?

How to unsubscribe (code 34) from subscribed topic?

Hello,

subscribed successfully to a topic and getting messages from server into the angular app.

Now, after "successfully" unsubscribing via the "takeUntil" trick in Angular, no more messages arrive in the App, but the server still sends the subscribed topic. There is / was no code "34" for unsubscribe send to the server by thruway.js.

The code looks like this:
("Angular unsubscribe" from here: https://stackoverflow.com/questions/38008334/angular-rxjs-when-should-i-unsubscribe-from-subscription/41177163#41177163)

  private unsubscribe: Subject<void> = new Subject<void>()
  plan = [];

  planasync$ = this.wampService
    .topic('sendplan')
    .takeUntil(this.unsubscribe)
    .subscribe(
      res => { 
        let tm = new TableMap();
        this.plan = tm.tableToMap(res.argskw).filter((m) => m.area === 1);
      },
      err => console.log("res err", err),
      () => console.log("res complete"));

  constructor(private wampService: WampService) { }

  ngOnDestroy() {
    this.unsubscribe.next();
    this.unsubscribe.complete();
  }

How to send an "unsubscribe" also to the server?
Am I missing something?

Getting all messages from socket

Hello.
How can i subscribe on all socket messages to get some data out of them?
node_modules/thruway.js/src/Transport/WebSocketTransport.js
image
it seems like there is no way to do it, because output field of transport is private.

es2015 support for Angular 8, 9

So far Thruway is only package in my project, which one needs es5. It would be great if there will be support for es2015, cause now already Angular 9 is out. And for better build times it would be great, if there won't be needed code conversion.

Connection only allows one call

Hi!

I'm still on trying to get this to run. Maybe it needs a little more documentation or it is a bug, but I currently have the problem that only the first call() will return results. Maybe you can guide me to get a proper setup? Thanks :)

My current setup:

@Injectable()
export class WampService {
  wampClient: Client;
  token: String;
  constructor(private store: Store<fromAuth.State>) {

    const url = (environment.production) ?
      'wss://' + location.host + '/router/' :
      'wss://mydevelopserver.com/router/';

      // I work with ngrx store and save the token in there if the user is logged in,
      // so I have to change the authmethods according to the state
      store
      .select(fromAuth.getUser)
      .take(1)
      .do((user) => console.log('store.select user', user))
      .subscribe(user => this.setupClient(url, user ? user.token : undefined));
  }

  setupClient (url: string, token: string) {
    let options: WampOptions = {};
    if (token) {
      options = {
        authmethods: ['ticket']
      };
    }
    this.wampClient = new Client(url, 'gateway', options);
    this.wampClient.onChallenge(function (challenge) {
      challenge.subscribe((msg) => {
    //   if (method === 'ticket') {
    //     return this.accessToken;
    //   } else {
    //     throw 'don\'t know how to authenticate via "' + method + '"';
      });
      return challenge;
    });
  }

  public call(uri: string, args?: Array<any>, argskw?: Object, options?: {}): Observable<any> {
    console.log('call', uri, args, argskw, options);
    return this.wampClient.call(uri, args, argskw, options);
  }

  public register(uri: string, callback: Function, options?: {}): Observable<any> {
    return this.wampClient.register(uri, callback, options);
  }


}

Many errors in v2.0.7

ERROR in ../node_modules/thruway.js/src/Client.d.ts:67:9 - error TS1086: An accessor cannot be declared in an ambient context.

67     get onOpen(): Observable<SessionData>;
           ~~~~~~
../node_modules/thruway.js/src/Client.d.ts:68:9 - error TS1086: An accessor cannot be declared in an ambient context.

68     get onClose(): Observable<IMessage>;
           ~~~~~~~
../node_modules/thruway.js/src/Client.d.ts:69:9 - error TS1086: An accessor cannot be declared in an ambient context.

69     get onError(): Observable<Error>;
           ~~~~~~~
../node_modules/thruway.js/src/Messages/ChallengeMessage.d.ts:8:9 - error TS1086: An accessor cannot be declared in an ambient context.

8     get authMethod(): string;
          ~~~~~~~~~~
../node_modules/thruway.js/src/Messages/ChallengeMessage.d.ts:9:9 - error TS1086: An accessor cannot be declared in an ambient context.

9     get extra(): Object;
          ~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:14:9 - error TS1086: An accessor cannot be declared in an ambient context.

14     get errorMsgCode(): number;
           ~~~~~~~~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:15:9 - error TS1086: An accessor cannot be declared in an ambient context.  

15     get errorRequestId(): number;
           ~~~~~~~~~~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:16:9 - error TS1086: An accessor cannot be declared in an ambient context.  

16     get details(): Object;
           ~~~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:17:9 - error TS1086: An accessor cannot be declared in an ambient context.  

17     get errorURI(): string;
           ~~~~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:18:9 - error TS1086: An accessor cannot be declared in an ambient context.  

18     get args(): Array<any>;
           ~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:19:9 - error TS1086: An accessor cannot be declared in an ambient context.  

19     get argskw(): Object;
           ~~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:20:9 - error TS1086: An accessor cannot be declared in an ambient context.

20     set details(value: Object);
           ~~~~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:21:9 - error TS1086: An accessor cannot be declared in an ambient context.

21     set args(value: Array<any>);
           ~~~~
../node_modules/thruway.js/src/Messages/ErrorMessage.d.ts:22:9 - error TS1086: An accessor cannot be declared in an ambient context.  

22     set argskw(value: Object);
           ~~~~~~
../node_modules/thruway.js/src/Messages/EventMessage.d.ts:11:9 - error TS1086: An accessor cannot be declared in an ambient context.  

11     get subscriptionId(): number;
           ~~~~~~~~~~~~~~
../node_modules/thruway.js/src/Messages/EventMessage.d.ts:12:9 - error TS1086: An accessor cannot be declared in an ambient context.  

12     get publicationId(): number;
           ~~~~~~~~~~~~~
../node_modules/thruway.js/src/Messages/EventMessage.d.ts:13:9 - error TS1086: An accessor cannot be declared in an ambient context.  

13     get details(): Object;
           ~~~~~~~
../node_modules/thruway.js/src/Messages/EventMessage.d.ts:14:9 - error TS1086: An accessor cannot be declared in an ambient context.  

14     get args(): Array<any>;
           ~~~~
../node_modules/thruway.js/src/Messages/EventMessage.d.ts:15:9 - error TS1086: An accessor cannot be declared in an ambient context.

15     get argskw(): Object;
           ~~~~~~
../node_modules/thruway.js/src/Messages/InvocationMessage.d.ts:12:9 - error TS1086: An accessor cannot be declared in an ambient context.

12     get requestId(): number;
           ~~~~~~~~~
../node_modules/thruway.js/src/Messages/InvocationMessage.d.ts:13:9 - error TS1086: An accessor cannot be declared in an ambient context.

13     get registrationId(): number;
           ~~~~~~~~~~~~~~
../node_modules/thruway.js/src/Messages/InvocationMessage.d.ts:14:9 - error TS1086: An accessor cannot be declared in an ambient context.

14     get details(): Object;
           ~~~~~~~
../node_modules/thruway.js/src/Messages/InvocationMessage.d.ts:15:9 - error TS1086: An accessor cannot be declared in an ambient context.

15     get args(): Array<any>;
           ~~~~
../node_modules/thruway.js/src/Messages/InvocationMessage.d.ts[0m:16:9 - error TS1086: An accessor cannot be declared in an ambient context.

16     get argskw(): Object;
           ~~~~~~
../node_modules/thruway.js/src/Messages/RegisteredMessage.d.ts:9:9 - error TS1086: An accessor cannot be declared in an ambient context.

9     get requestId(): number;
          ~~~~~~~~~
../node_modules/thruway.js/src/Messages/RegisteredMessage.d.ts:10:9 - error TS1086: An accessor cannot be declared in an ambient context.

10     get registrationId(): number;
           ~~~~~~~~~~~~~~
../node_modules/thruway.js/src/Messages/ResultMessage.d.ts:11:9 - error TS1086: An accessor cannot be declared in an ambient context. 

11     get requestId(): number;
           ~~~~~~~~~
../node_modules/thruway.js/src/Messages/ResultMessage.d.ts:12:9 - error TS1086: An accessor cannot be declared in an ambient context. 

12     get details(): Object | any;
           ~~~~~~~
../node_modules/thruway.js/src/Messages/ResultMessage.d.ts:13:9 - error TS1086: An accessor cannot be declared in an ambient context. 

13     get args(): Array<any>;
           ~~~~
../node_modules/thruway.js/src/Messages/ResultMessage.d.ts:14:9 - error TS1086: An accessor cannot be declared in an ambient context. 

14     get argskw(): {};
           ~~~~~~
../node_modules/thruway.js/src/Messages/UnregisteredMessage.d.ts:8:9 - error TS1086: An accessor cannot be declared in an ambient context.

8     get requestId(): number;
          ~~~~~~~~~
96m../node_modules/thruway.js/src/Messages/WelcomeMessage.d.ts:8:9 - error TS1086: An accessor cannot be declared in an ambient context.

8     get sessionId(): number;
          ~~~~~~~~~
../node_modules/thruway.js/src/Messages/WelcomeMessage.d.ts:9:9 - error TS1086: An accessor cannot be declared in an ambient context. 

9     get details(): any;

Cookie authentication method

Hi there!

We use Crossbar as a WAMP router and trying to switch to ThruwayJS from AutobahnJS.

One thing which I can't seem to find in ThruwayJS sources is the Cookie authentication, which is a cool feature of Crossbar (Docs).

Am I right that its not supported?

Support passing in WebSocket implementation

A lot of implementations that wrap websockets allow passing in a websocket implementation instead of hard coding it. See here and here

Would you consider a PR that includes support for that on the WebSocketTransport. Perhaps via a static create.

Best way to throw an exception inside a registered function

When I try to throw an Exception like

async function trySomething(a, b) {
  // try something
  throw(new Error('hello'));
}

wamp.register('add.rpc', trySomething).subscribe();

then the Error I get on the other side is

Error {
  error: 'thruway.error.invocation_exception',
  args: [],
  kwargs: {}
}

Is there a way to raise another error or provide details about the Error on side that calls the function?

Thanks!

.call argskw expected to be an array?

Thank you very much for this library! Just came to check it out and try the first steps. On Client.call I think there is a mistake, because the library expects argskw to be an array.

But thanks, seems to be very promising for using Wamp with Angular :)

react-native support

Just wondering if this library has been tested with react-native or if you plan to do it.

Configurable reconnecting options

Hello, is possible to make these variables configurable by options, when new Client() is called?

From Client.js:

            var maxRetryDelay = 300000;
            var initialRetryDelay = 1500;
            var retryDelayGrowth = 1.5;
            var maxRetries = 550;

suggested changes:

        var options = this.options;
        this.messages = this.transport.retryWhen(function (attempts) {
            var maxRetryDelay = options.maxRetryDelay || 300000;
            var initialRetryDelay = options.initialRetryDelay || 1500;
            var retryDelayGrowth = options.retryDelayGrowth || 1.5;
            var maxRetries = options.maxRetries || 550;

Registering async functions

In autobahnjs, I have the possibility to return a promise, and the function session.call will only be called when the promise resolves.

  async function add2(args, kwargs) {
    //await whatever, database calls etc
    return args[0] + args[1];
  }
  session.register('com.example.add2', add2);

In autobahn, it returns the result, in thruway it only returns an empty object. Is there a way to do this?

Thanks!

Warning after upgrading project from Angular 9 to 10

I updated my Angular project from Angular 9 to 10 and then after build this warning appeared:

WARNING in /mnt/c/app/angular-latest-smartmex/smartmex-web/src/app/factories/WampService.ts depends on 'thruway.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Maybe it is possible to use package without CommonJS.

thruway.auth.invalid_response_to_hello

Hey,

can anyone help me with the wampcra auth method?
Why I'm getting an "thruway.auth.invalid_response_to_hello" response?

Send:
[1,"project",{"authmethods":["wampcra"],"roles":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true,"call_canceling":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"progressive_call_results":true,"registration_revocation":true,"call_canceling":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscription_revocation":true}}}}]

Receive: [3,{},"thruway.auth.invalid_response_to_hello"]

My code (clientside):

// Thruway.js
@Injectable()
export class WebsocketService extends Client {

  constructor() {
    super(((environment.production) ? 'wss://' : 'ws://') + window.location.host + ':' + 1337 + '/', 'project', {
      authmethods: ['wampcra']
    });
    this.onChallenge((challenge: Observable<ChallengeMessage>) => {
      return new Observable<string>(observer => observer.next(localStorage.getItem('auth')));
    });
  }

}

My code (serverside):

        // Thruway
        $this->loop = Factory::create();
        $this->router = new Router($this->loop);

        $this->websocket = new RatchetTransportProvider('0.0.0.0', WS_PORT);
        $this->router->addTransportProvider($this->websocket);

        $this->authManager = new AuthenticationManager();
        $this->router->registerModule($this->authManager);

        $this->authProvider = new WampCraAuthProvider(['project'], $this->loop);
        $this->authProvider->setUserDb(new AuthDb());

        $this->router->addInternalClient($this->authProvider);

        $this->router->getRealmManager()->addRealm(new Realm('project'));
        $this->router->getRealmManager()->setAllowRealmAutocreate(true);

        $this->router->start();

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.