Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fishpi

Package Overview
Dependencies
Maintainers
0
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fishpi - npm Package Compare versions

Comparing version 0.0.57 to 0.0.58

196

lib/chatroom.js

@@ -489,102 +489,110 @@ "use strict";

ChatRoom.prototype.reconnect = function (_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.url, url = _c === void 0 ? "wss://".concat(utils_1.domain, "/chat-room-channel") : _c, _d = _b.timeout, timeout = _d === void 0 ? 10 : _d, _e = _b.error, error = _e === void 0 ? function (ev) { } : _e, _f = _b.close, close = _f === void 0 ? function (ev) { } : _f;
var _b = _a === void 0 ? {} : _a, _c = _b.url, url = _c === void 0 ? "" : _c, _d = _b.timeout, timeout = _d === void 0 ? 10 : _d, _e = _b.error, error = _e === void 0 ? function (ev) { } : _e, _f = _b.close, close = _f === void 0 ? function (ev) { } : _f;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_g) {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var _a, _b, _c, _d;
var _e;
var _this = this;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
if (this._rws)
return [2 /*return*/, resolve(this._rws.reconnect())];
_a = this;
_b = reconnecting_websocket_1.default.bind;
_c = [void 0, "".concat(url, "?apiKey=").concat(this._apiKey), []];
_e = {};
if (!utils_1.isBrowse) return [3 /*break*/, 1];
_d = window.WebSocket;
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('ws')); })];
case 2:
_d = (_f.sent()).WebSocket;
_f.label = 3;
case 3:
_a._rws = new (_b.apply(reconnecting_websocket_1.default, _c.concat([(
// eslint-disable-next-line @typescript-eslint/naming-convention
_e.WebSocket = _d,
_e.connectionTimeout = 1000 * timeout,
_e)])))();
this._rws.onopen = function (e) {
if (_this._wsTimer) {
clearInterval(_this._wsTimer);
}
_this._wsTimer = setInterval(function () {
var _a;
(_a = _this._rws) === null || _a === void 0 ? void 0 : _a.send('-hb-');
}, 1000 * 60 * 3);
resolve(e);
};
this._rws.onmessage = function (e) { return __awaiter(_this, void 0, void 0, function () {
var msg, data, barragerContent, userAvatarURL, userAvatarURL20, userNickname, barragerColor, userName, userAvatarURL210, userAvatarURL48, userOId, oId, time, userName, userNickname, userAvatarURL, content, md, client, data_1, oId, count, got, whoGive, whoGot;
return __generator(this, function (_a) {
msg = JSON.parse(e.data);
data = null;
switch (msg.type) {
case 'online': {
this._onlines = msg.users;
this._discusse = msg.discussing;
data = this._onlines;
break;
}
case 'discussChanged': {
data = msg.newDiscuss;
break;
}
case 'revoke': {
data = msg.oId;
break;
}
case 'barrager': {
barragerContent = msg.barragerContent, userAvatarURL = msg.userAvatarURL, userAvatarURL20 = msg.userAvatarURL20, userNickname = msg.userNickname, barragerColor = msg.barragerColor, userName = msg.userName, userAvatarURL210 = msg.userAvatarURL210, userAvatarURL48 = msg.userAvatarURL48;
data = { barragerContent: barragerContent, userAvatarURL: userAvatarURL, userAvatarURL20: userAvatarURL20, userNickname: userNickname, barragerColor: barragerColor, userName: userName, userAvatarURL210: userAvatarURL210, userAvatarURL48: userAvatarURL48 };
break;
}
case 'msg': {
userOId = msg.userOId, oId = msg.oId, time = msg.time, userName = msg.userName, userNickname = msg.userNickname, userAvatarURL = msg.userAvatarURL, content = msg.content, md = msg.md, client = msg.client;
try {
data_1 = JSON.parse(content);
content = data_1;
msg.type = data_1.msgType;
switch (_g.label) {
case 0:
if (!!url) return [3 /*break*/, 2];
return [4 /*yield*/, this.getNode()];
case 1:
url = _g.sent();
_g.label = 2;
case 2: return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var _a, _b, _c, _d;
var _e;
var _this = this;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
if (this._rws)
return [2 /*return*/, resolve(this._rws.reconnect())];
_a = this;
_b = reconnecting_websocket_1.default.bind;
_c = [void 0, "".concat(url, "?apiKey=").concat(this._apiKey), []];
_e = {};
if (!utils_1.isBrowse) return [3 /*break*/, 1];
_d = window.WebSocket;
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('ws')); })];
case 2:
_d = (_f.sent()).WebSocket;
_f.label = 3;
case 3:
_a._rws = new (_b.apply(reconnecting_websocket_1.default, _c.concat([(
// eslint-disable-next-line @typescript-eslint/naming-convention
_e.WebSocket = _d,
_e.connectionTimeout = 1000 * timeout,
_e)])))();
this._rws.onopen = function (e) {
if (_this._wsTimer) {
clearInterval(_this._wsTimer);
}
_this._wsTimer = setInterval(function () {
var _a;
(_a = _this._rws) === null || _a === void 0 ? void 0 : _a.send('-hb-');
}, 1000 * 60 * 3);
resolve(e);
};
this._rws.onmessage = function (e) { return __awaiter(_this, void 0, void 0, function () {
var msg, data, barragerContent, userAvatarURL, userAvatarURL20, userNickname, barragerColor, userName, userAvatarURL210, userAvatarURL48, userOId, oId, time, userName, userNickname, userAvatarURL, content, md, client, data_1, oId, count, got, whoGive, whoGot;
return __generator(this, function (_a) {
msg = JSON.parse(e.data);
data = null;
switch (msg.type) {
case 'online': {
this._onlines = msg.users;
this._discusse = msg.discussing;
data = this._onlines;
break;
}
catch (e) { }
data = { userOId: userOId, oId: oId, time: time, userName: userName, userNickname: userNickname, userAvatarURL: userAvatarURL, content: content, md: md, client: client, via: (0, utils_1.clientToVia)(client) };
break;
case 'discussChanged': {
data = msg.newDiscuss;
break;
}
case 'revoke': {
data = msg.oId;
break;
}
case 'barrager': {
barragerContent = msg.barragerContent, userAvatarURL = msg.userAvatarURL, userAvatarURL20 = msg.userAvatarURL20, userNickname = msg.userNickname, barragerColor = msg.barragerColor, userName = msg.userName, userAvatarURL210 = msg.userAvatarURL210, userAvatarURL48 = msg.userAvatarURL48;
data = { barragerContent: barragerContent, userAvatarURL: userAvatarURL, userAvatarURL20: userAvatarURL20, userNickname: userNickname, barragerColor: barragerColor, userName: userName, userAvatarURL210: userAvatarURL210, userAvatarURL48: userAvatarURL48 };
break;
}
case 'msg': {
userOId = msg.userOId, oId = msg.oId, time = msg.time, userName = msg.userName, userNickname = msg.userNickname, userAvatarURL = msg.userAvatarURL, content = msg.content, md = msg.md, client = msg.client;
try {
data_1 = JSON.parse(content);
content = data_1;
msg.type = data_1.msgType;
}
catch (e) { }
data = { userOId: userOId, oId: oId, time: time, userName: userName, userNickname: userNickname, userAvatarURL: userAvatarURL, content: content, md: md, client: client, via: (0, utils_1.clientToVia)(client) };
break;
}
case 'redPacketStatus': {
oId = msg.oId, count = msg.count, got = msg.got, whoGive = msg.whoGive, whoGot = msg.whoGot;
data = { oId: oId, count: count, got: got, whoGive: whoGive, whoGot: whoGot };
break;
}
case 'customMessage': {
data = msg.message;
break;
}
}
case 'redPacketStatus': {
oId = msg.oId, count = msg.count, got = msg.got, whoGive = msg.whoGive, whoGot = msg.whoGot;
data = { oId: oId, count: count, got: got, whoGive: whoGive, whoGot: whoGot };
break;
}
case 'customMessage': {
data = msg.message;
break;
}
}
this._wsCallbacks.forEach(function (call) { return call(Object.assign(__assign(__assign({}, e), { msg: { type: msg.type, data: data } }))); });
return [2 /*return*/];
this._wsCallbacks.forEach(function (call) { return call(Object.assign(__assign(__assign({}, e), { msg: { type: msg.type, data: data } }))); });
return [2 /*return*/];
});
}); };
this._rws.onerror = error || (function (e) {
console.error(e);
});
}); };
this._rws.onerror = error || (function (e) {
console.error(e);
});
this._rws.onclose = close || (function (e) {
console.log(e);
});
return [2 /*return*/];
}
});
}); })];
this._rws.onclose = close || (function (e) {
console.log(e);
});
return [2 /*return*/];
}
});
}); })];
}
});

@@ -591,0 +599,0 @@ });

{
"name": "fishpi",
"version": "0.0.57",
"version": "0.0.58",
"description": "A Package to use API of fishpi.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc