promise-ws

WebJar for promise-ws

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

promise-ws
Последняя версия

Последняя версия

1.0.0-1
Дата

Дата

Тип

Тип

jar
Описание

Описание

promise-ws
WebJar for promise-ws
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/cantonjs/promise-ws

Скачать promise-ws

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/promise-ws/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>promise-ws</artifactId>
    <version>1.0.0-1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/promise-ws/
implementation 'org.webjars.npm:promise-ws:1.0.0-1'
// https://jarcasting.com/artifacts/org.webjars.npm/promise-ws/
implementation ("org.webjars.npm:promise-ws:1.0.0-1")
'org.webjars.npm:promise-ws:jar:1.0.0-1'
<dependency org="org.webjars.npm" name="promise-ws" rev="1.0.0-1">
  <artifact name="promise-ws" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='promise-ws', version='1.0.0-1')
)
libraryDependencies += "org.webjars.npm" % "promise-ws" % "1.0.0-1"
[org.webjars.npm/promise-ws "1.0.0-1"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm : pify jar [3.0.0,4)
org.webjars.npm : ws jar [6.0.0,7)

Модули Проекта

Данный проект не имеет модулей.

promise-ws

Build Status CircleCI Build status Coverage Status PRs Welcome License

A promise based WebSocket implementation for Node.js. Built on top of ws

Table of Contents

Usage examples

Simple client

import WebSocket from "promise-ws";

(async function() {
  const ws = await WebSocket.create("ws://www.host.com/path");

  ws.on("message", function incoming(data) {
    console.log(data);
  });

  await ws.send("something");
})();

Simple server

import WebSocket from "promise-ws";

(async function() {
  const wss = await WebSocket.Server.create({ port: 8080 });

  wss.on("connection", async function connection(ws) {
    ws.on("message", function incoming(message) {
      console.log("received: %s", message);
    });

    await ws.send("something");
  });
})();

Installation

$ npm install promise-ws

API Reference

promise-ws API is almost the same with ws except that:

  • websocket.ping([data[, mask]]) returns a promise
  • websocket.pong([data[, mask]]) returns a promise
  • websocket.send(data[, options]) returns a promise
  • 🆕 WebSocket.Server.create(options), returns a promise of listened WebSocket.Server instance
  • 🆕 WebSocket.create(options), returns a promise of opened WebSocket instance

For more WebSocket API, please checkout the API doc.

License

MIT

org.webjars.npm
undefined

Версии библиотеки

Версия
1.0.0-1