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

websocket-front

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket-front - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

8

dist/index.d.ts

@@ -21,3 +21,7 @@ interface EventParams {

}
declare class Socket {
interface SocketInterface {
send: (message: string | ArrayBufferLike | Blob | ArrayBufferView) => void;
close: () => void;
}
declare class Socket implements SocketInterface {
url: string;

@@ -48,2 +52,2 @@ opts: SocketOpts;

export { SocketOptions, Socket as default };
export { SocketInterface, SocketOptions, Socket as default };
{
"name": "websocket-front",
"version": "1.0.5",
"version": "1.0.6",
"description": "WebSocket client for browser with reconnect and heartbeat",
"main": "./dist/index.esm.js",
"types": "./dist/index.d.ts",
"types": "dist/index.d.ts",
"scripts": {

@@ -18,3 +18,6 @@ "test": "echo \"Error: no test specified\" && exit 1",

"native",
"websocket"
"websocket",
"web、front",
"js",
"前端"
],

@@ -21,0 +24,0 @@ "author": "yanquanmei",

@@ -32,2 +32,11 @@ # websocket-front

import Socket from 'websocket-front';
const receiveMessage = (message: Event) => {
console.log('接收到的消息:', message)
}
const errorCallback = (error: Event) => {
console.log('错误信息', error)
}
const closeCallback = (event: Event) => {
console.log('关闭了', event)
}
const socket = new Socket('ws://127.0.0.1:3001', {

@@ -39,3 +48,3 @@ // 重连

// 心跳检测
isHeartbeat: true
isHeartbeat: true,
pingMsg: JSON.stringify({

@@ -52,11 +61,2 @@ messageType: "0",

})
const receiveMessage = (message: Event) => {
console.log('接收到的消息:', message)
}
const errorCallback = (error: Event) => {
console.log('错误信息', event)
}
const closeCallback = (event: Event) => {
console.log('关闭了')
}
```

@@ -63,0 +63,0 @@

@@ -18,3 +18,2 @@ interface EventParams {

pongTimeout: number; // 多长时间没有收到返回的心跳就重启
// 页面unload时关闭
protocols?: string[];

@@ -34,3 +33,8 @@ }

class Socket {
export interface SocketInterface {
send: (message: string | ArrayBufferLike | Blob | ArrayBufferView) => void;
close: () => void;
}
class Socket implements SocketInterface {
url: string;

@@ -37,0 +41,0 @@ opts: SocketOpts;

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