0.1.3 • Published 3 years ago
neptune-msgsocket v0.1.3
neptune-msgsocket
Summary:
-= Vue.js + TypeScript + Websocket + Protobuf + Msgpack =-
- Support multiple content format (Plain Text/ Json/ Msgpack/ Protobuf)
- Support heart beat
- Support automatic reconnect
- ...
Usage:
yarn add neptune-msgsocket
new Socket().getInstance({
wsUrl: "ws://",
callback: this.holdOnMessage,
closeCallback: this.holdOnClose,
openCallback: this.holdOnOpen,
timeoutSeconds: 10,
isReconnect: true,
isHeartbeat: false,
}).then(socket => {
this.socket = socket;
}).catch(reason => {
console.log(reason);
})
// Protobuf Core Defination
message Message {
enum Method {
DELIVER = 0; // BiWard delivery (Default)
CONNECTED = 1; // Downward connection
KEEPALIVE = 2; // BiWard heartbeat
CLOSE = 3; // BiWard close
ACTION = 4; // BiWard command action
}
enum Format {
EMPTY = 0; // Empty package (Default)
BINARY = 1; // Binary package
TEXT = 2; // Text package
JSON = 3; // Json format package
MSGPACK = 4; // Msgpack format package
PROTOBUF = 5; // Protobuf format package
}
enum Logic {
SYSTEM = 0; // System level (Default)
COMMAND = 1; // Command level
ENVELOPE = 2; // Envelope level
SERVER_CERT = 3; // Server cert
CLIENT_CERT = 4; // Client cert
}
Method method = 1; // Core method
bytes content = 2; // Content (Format )
Format format = 3; // Formet
Logic logic = 4; // Logic
}