@heycharles/browser-sdk
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -0,1 +1,8 @@ | ||
# [2.1.0](https://github.com/c-commerce/charles-browser-sdk/compare/v2.0.1...v2.1.0) (2020-02-24) | ||
### Features | ||
* **messaging:** add Message ([b765776](https://github.com/c-commerce/charles-browser-sdk/commit/b765776d93204b304b54d93c8d282489df232a4e)) | ||
## [2.0.1](https://github.com/c-commerce/charles-browser-sdk/compare/v2.0.0...v2.0.1) (2020-02-24) | ||
@@ -2,0 +9,0 @@ |
@@ -19,2 +19,9 @@ /// <reference types="node" /> | ||
} | ||
export interface RealtimeMessageMessage extends RealtimeMessage { | ||
payload: { | ||
message: { | ||
[key: string]: any; | ||
}; | ||
}; | ||
} | ||
export interface RealtimeLastMessageReference { | ||
@@ -40,3 +47,3 @@ mqttClientId: RealtimeMessage['mqttClientId']; | ||
} | ||
export declare type OnMessageCallback = (message: RealtimeMessage) => void; | ||
export declare type OnMessageCallback = (message: RealtimeMessage | RealtimeMessageMessage) => void; | ||
export declare interface RealtimeClient { | ||
@@ -43,0 +50,0 @@ on(event: 'raw-error' | 'error', cb: (error: Error) => void): this; |
@@ -47,3 +47,10 @@ import { Readable } from 'readable-stream'; | ||
private subscibeDefaults; | ||
/** | ||
* | ||
* Parsing and routing logic is being handled here. We take extensive decisions about type and destionations here. | ||
*/ | ||
private handleMessage; | ||
/** | ||
* Safe access the mqtt client. This has a conequence that all the methods that use it need to be aware that they might throw. | ||
*/ | ||
private getMqttClient; | ||
@@ -50,0 +57,0 @@ create(options: IUniverseOptions): Universe; |
@@ -15,2 +15,13 @@ "use strict"; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -52,5 +63,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -63,8 +71,12 @@ if (mod && mod.__esModule) return mod; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var readable_stream_1 = require("readable-stream"); | ||
var status_1 = require("./status"); | ||
var realtime_1 = require("../realtime"); | ||
var realtime = __importStar(require("../realtime")); | ||
var errors_1 = require("../errors"); | ||
var topics_1 = __importDefault(require("./topics")); | ||
var messaging_1 = require("../messaging"); | ||
var uuid = __importStar(require("../helpers/uuid")); | ||
@@ -132,3 +144,3 @@ var Universe = /** @class */ (function (_super) { | ||
}; | ||
this.mqtt = new realtime_1.RealtimeClient(realtimeOpts); | ||
this.mqtt = new realtime.RealtimeClient(realtimeOpts); | ||
this.mqtt.on('message', function (msg) { | ||
@@ -143,2 +155,6 @@ _this.handleMessage(msg); | ||
}; | ||
/** | ||
* | ||
* Parsing and routing logic is being handled here. We take extensive decisions about type and destionations here. | ||
*/ | ||
Universe.prototype.handleMessage = function (msg) { | ||
@@ -153,3 +169,7 @@ // each arming message will cause an unsubscription | ||
if (topics_1.default.api.message.isTopic(msg.topic)) { | ||
this.emit('universe:message', msg); | ||
var message = void 0; | ||
if (msg.payload.message) { | ||
message = messaging_1.Message.deserialize(msg.payload.message); | ||
} | ||
this.emit('universe:message', __assign(__assign({}, msg), { message: message })); | ||
return; | ||
@@ -159,2 +179,5 @@ } | ||
}; | ||
/** | ||
* Safe access the mqtt client. This has a conequence that all the methods that use it need to be aware that they might throw. | ||
*/ | ||
Universe.prototype.getMqttClient = function () { | ||
@@ -161,0 +184,0 @@ if (this.mqtt) |
{ | ||
"name": "@heycharles/browser-sdk", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "The Browser SDK for the Charles APIs.", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
797000
62
20341