@kevin_men/websocket
Version:
TDengine Connector for nodejs and browser using WebSocket.
77 lines (76 loc) • 2.44 kB
JavaScript
"use strict";
/**
* define ws Response type|class, for query?
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.WSConnResponse = exports.WSFetchBlockResponse = exports.WSFetchResponse = exports.WSQueryResponse = exports.WSVersionResponse = void 0;
class WSVersionResponse {
constructor(resp) {
this.version = resp.msg.version;
this.code = resp.msg.code;
this.message = resp.msg.message;
this.action = resp.msg.action;
this.totalTime = resp.totalTime;
}
}
exports.WSVersionResponse = WSVersionResponse;
class WSQueryResponse {
constructor(resp) {
this.totalTime = resp.totalTime;
this.initMsg(resp.msg);
}
initMsg(msg) {
this.code = msg.code;
this.message = msg.message;
this.action = msg.action;
this.req_id = msg.req_id;
this.timing = BigInt(msg.timing);
if (msg.id) {
this.id = BigInt(msg.id);
}
else {
this.id = BigInt(0);
}
this.is_update = msg.is_update;
this.affected_rows = msg.affected_rows;
this.fields_count = msg.fields_count;
this.fields_names = msg.fields_names;
this.fields_types = msg.fields_types;
this.fields_lengths = msg.fields_lengths;
this.precision = msg.precision;
}
}
exports.WSQueryResponse = WSQueryResponse;
class WSFetchResponse {
constructor(resp) {
this.totalTime = resp.totalTime;
this.code = resp.msg.code;
this.message = resp.msg.message;
this.action = resp.msg.action;
this.req_id = resp.msg.req_id;
this.timing = BigInt(resp.msg.timing);
this.id = BigInt(resp.msg.id);
this.completed = resp.msg.completed;
this.length = resp.msg.length;
this.rows = resp.msg.rows;
}
}
exports.WSFetchResponse = WSFetchResponse;
class WSFetchBlockResponse {
constructor(msg) {
this.timing = new DataView(msg, 0, 8).getBigUint64(0, true);
this.id = new DataView(msg, 8, 8).getBigUint64(0, true);
this.data = msg.slice(16);
}
}
exports.WSFetchBlockResponse = WSFetchBlockResponse;
class WSConnResponse {
constructor(msg) {
this.code = msg.code;
this.message = msg.message;
this.action = msg.action;
this.req_id = msg.req_id;
this.timing = BigInt(msg.timing);
}
}
exports.WSConnResponse = WSConnResponse;