Built files from Bizgaze WebServer
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

notificationhub.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Automation;
  6. (function (Automation) {
  7. let Hubs;
  8. (function (Hubs) {
  9. class NotificationHub {
  10. constructor(huburl) {
  11. this.server = {
  12. Connect: function (packet, callback) {
  13. Unibase.Platform.Automation.Hubs.NotificationHub.Instance(_appsettings.notification_url()).invoke("Connect", packet, callback);
  14. }
  15. };
  16. this.huburl = huburl;
  17. this.connection = new window['signalR'].HubConnectionBuilder()
  18. .withUrl(this.huburl).withAutomaticReconnect()
  19. .build();
  20. }
  21. getConnection() {
  22. return this.connection;
  23. }
  24. connect(callback) {
  25. this.getConnection().start().then(function () {
  26. callback();
  27. });
  28. }
  29. register(eventname, actionmethod) {
  30. this.getConnection().on(eventname, actionmethod);
  31. }
  32. invoke(methodname, params, callback) {
  33. Unibase.Platform.Automation.Hubs.NotificationHub.Instance(_appsettings.notification_url()).getConnection().invoke(methodname, params).catch(function (err) {
  34. return console.error(err.toString());
  35. });
  36. }
  37. static Instance(huburl) {
  38. if (this.instance === undefined) {
  39. this.instance = new NotificationHub(huburl);
  40. }
  41. return this.instance;
  42. }
  43. }
  44. Hubs.NotificationHub = NotificationHub;
  45. })(Hubs = Automation.Hubs || (Automation.Hubs = {}));
  46. })(Automation = Platform.Automation || (Platform.Automation = {}));
  47. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  48. })(Unibase || (Unibase = {}));