voryx / angular-wamp

An AngularJS library for AutobahnJS (WAMP v2)
MIT License
133 stars 28 forks source link

Multiple connections, returned functions use options from last connection #49

Open LupusUmbrae opened 8 years ago

LupusUmbrae commented 8 years ago

Hard to explain exactly what i meant, but the returned methods (open, setAuthId, ect) use options from the $wampProvider scope rather than using the options set on the current connection (on the $get scope)

this leads to some errors, for me my second connection has "wampcra" with an authid set after the first connection is opened.

The line i'm seeing the error is here: https://github.com/voryx/angular-wamp/blob/master/src/angular-wamp.js#L381

I think options from here needs to be moved to this level

I put a breakpoint in chrome and used the console to print options and connection._options:

> connection._options
Object {url: "ws://localhost:8080/ws", realm: "realm1", authid: "", transports: Array[1]}
> options
Object {url: "ws://localhost:8080/ws", realm: "realm1", prefix: "$wampAuth", authmethods: Array[1], transports: Array[1]}