Guest User

Untitled

a guest
Nov 23rd, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. index d6f7254..314644e 100644
  2. --- a/wampy.js
  3. +++ b/home/grizmio/forked/wampy.js/src/wampy.js
  4. @@ -413,7 +413,9 @@ class Wampy {
  5. * @private
  6. */
  7. _validateURI (uri) {
  8. - const re = /^([0-9a-zA-Z_]+\.)*([0-9a-zA-Z_]+)$/;
  9. + // const re = /^([0-9a-zA-Z_]+\.)*([0-9a-zA-Z_]+)$/;
  10. + // {1,2} para soportar {match: wildcard} foo.bar..baz
  11. + const re = /^([0-9a-zA-Z_]+\.{1,2})*([0-9a-zA-Z_]+)$/;
  12. return !(!re.test(uri) || uri.indexOf('wamp') === 0);
  13. }
  14.  
  15. @@ -1115,16 +1117,21 @@ class Wampy {
  16. * { onSuccess: will be called when subscribe would be confirmed
  17. * onError: will be called if subscribe would be aborted
  18. * onEvent: will be called on receiving published event }
  19. + * @param {object} options options like { match: wildcard }
  20. *
  21. * @returns {Wampy}
  22. */
  23. - subscribe (topicURI, callbacks) {
  24. + subscribe (topicURI, callbacks, options) {
  25. let reqId;
  26.  
  27. if (!this._preReqChecks(topicURI, 'broker', callbacks)) {
  28. return this;
  29. }
  30.  
  31. + if ( typeof options === 'undefined' ){
  32. + options = {};
  33. + }
  34. +
  35. if (typeof callbacks === 'function') {
  36. callbacks = { onEvent: callbacks };
  37. } else if (!this._isPlainObject(callbacks) || typeof (callbacks.onEvent) === 'undefined') {
  38. @@ -1148,7 +1155,7 @@ class Wampy {
  39. };
  40.  
  41. // WAMP SPEC: [SUBSCRIBE, Request|id, Options|dict, Topic|uri]
  42. - this._send([WAMP_MSG_SPEC.SUBSCRIBE, reqId, {}, topicURI]);
  43. + this._send([WAMP_MSG_SPEC.SUBSCRIBE, reqId, options, topicURI]);
  44.  
  45. } else { // already have subscription to this topic
  46. // There is no such callback yet
Add Comment
Please, Sign In to add comment