websocket

websocket support module

To use it:

var websocket = require('websocket');

Summary

Type Method and Description
const Integer public const Integer CONTINUECONTINUECONTINUE

Specifies the message type 0 of websocket, which is a continue frame.

const Integer public const Integer TEXTTEXTTEXT

Specifies the message type 1 of websocket, which is a text frame.

const Integer public const Integer BINARYBINARYBINARY

Specifies the message type 2 of websocket, which is a binary frame.

const Integer public const Integer CLOSECLOSECLOSE

Specifies the message type 8 of websocket, which means connection closed.

const Integer public const Integer PINGPINGPING

Specifies the message type 9 of websocket, which is a ping frame.

const Integer public const Integer PONGPONGPONG

Specifies the message type 10 of websocket, which is a pong frame.

WebSocketMessage new Message()

Create one websocket message object, refer WebSocketMessage.

WebSocketHandler new Handler()

Create one websocket packet protocol conversion processor, refer WebSocketHandler.

Stream connect(String url)

Create one websocket connection, and return a completed connection Stream object.

Method Detail

CONTINUE

const Integer public const Integer CONTINUECONTINUECONTINUE

Specifies the message type 0 of websocket, which is a continue frame.

TEXT

const Integer public const Integer TEXTTEXTTEXT

Specifies the message type 1 of websocket, which is a text frame.

BINARY

const Integer public const Integer BINARYBINARYBINARY

Specifies the message type 2 of websocket, which is a binary frame.

CLOSE

const Integer public const Integer CLOSECLOSECLOSE

Specifies the message type 8 of websocket, which means connection closed.

PING

const Integer public const Integer PINGPINGPING

Specifies the message type 9 of websocket, which is a ping frame.

PONG

const Integer public const Integer PONGPONGPONG

Specifies the message type 10 of websocket, which is a pong frame.

Message

WebSocketMessage new Message()

Create one websocket message object, refer WebSocketMessage.

Handler

WebSocketHandler new Handler()

Create one websocket packet protocol conversion processor, refer WebSocketHandler.

connect

Stream connect(String url)

Create one websocket connection, and return a completed connection Stream object.

Parameters

  • url Specifies the connection url,support ws:// and wss:// protocol

Returns

Return a completed connection Stream object, which can be Socket or SslSocket