voryx / thruway.js Goto Github PK
View Code? Open in Web Editor NEWRxJS WAMPv2 Client
License: MIT License
RxJS WAMPv2 Client
License: MIT License
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?
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?
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").
I'd need to get some connection state events, like in autobahn with onopen
and onclose
. Is this already possible with thruway?
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
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) ?
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?
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.
Currently there is angular 12. There has been no updates for months.
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);
}
}
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;
Look into doing something similar to recompose's setobservableconfig.
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?
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!
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 :)
Just wondering if this library has been tested with react-native or if you plan to do it.
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;
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!
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.
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();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.