open-index/open-npm huggingface dataset:
npm package: @geckos.io/client
Description: Real-time client/server communication over UDP using WebRTC and Node.js
Author: Yannick Deubel
Latest version: 3.1.0

<a href="http://geckos.io">
<img src="https://github.com/geckosio/geckos.io/raw/master/readme/logo-256.png" alt="logo" width="128">
</a>

# @geckos.io/client

[![NPM version](https://img.shields.io/npm/v/@geckos.io/client.svg?style=flat-square)](https://www.npmjs.com/package/@geckos.io/client)
[![Downloads](https://img.shields.io/npm/dm/@geckos.io/client.svg?style=flat-square)](https://www.npmjs.com/package/@geckos.io/client)
![Node version](https://img.shields.io/node/v/@geckos.io/client.svg?style=flat-square)
[![Minified bundle](https://img.shields.io/github/size/geckosio/geckos.io/bundles/latest/geckos.io-client.latest.min.js.svg?label=minified%20bundle&style=flat-square)](https://github.com/geckosio/geckos.io/tree/master/bundles)
![Snyk Vulnerabilities for GitHub Repo (Specific Manifest)](https://img.shields.io/snyk/vulnerabilities/github/geckosio/geckos.io/packages/client/package.json.svg?style=flat-square)
![NPM](https://img.shields.io/npm/l/@geckos.io/client.svg?style=flat-square)
[![Codecov](https://img.shields.io/codecov/c/github/geckosio/geckos.io?logo=codecov&style=flat-square)](https://codecov.io/gh/geckosio/geckos.io)
[![ES Modules Badge](https://img.shields.io/badge/Node.js-ES%20Modules-F7DF1E?style=flat-square)](https://github.com/yandeu/yandeu/blob/main/posts/2020-05-28-esm-for-nodejs.md)

Real-time client/server communication over UDP using **WebRTC** and **Node.js**.

This framework fits perfectly with your next **HTML5 real-time multiplayer games** or chat app.

Read the [documentation](https://github.com/geckosio/geckos.io) for more information.

## Install

```console
npm install @geckos.io/client
```

## Use

```js
import geckos from '@geckos.io/client'

// or add a minified version to your index.html file
// https://github.com/geckosio/geckos.io/tree/master/bundles/versions

const channel = geckos()

channel.onConnect(error => {
  if (error) {
    console.error(error.message)
    return
  }

  channel.on('chat message', data => {
    console.log(`You got the message ${data}`)
  })

  channel.emit('chat message', 'a short message sent to the server')
})
```
npm package: @geckos.io/common
Description: The common module for @geckos.io/server and @geckos.io/client.
Author: Yannick Deubel
Latest version: 3.1.0

# @geckos.io/common

> This is the common module used by [@geckos.io/client](https://www.npmjs.com/package/@geckos.io/client) and [@geckos.io/server](https://www.npmjs.com/package/@geckos.io/server).

Read the [geckos.io documentation](https://github.com/geckosio/geckos.io) for more information.
npm package: @geckos.io/server
Description: Real-time client/server communication over UDP using WebRTC and Node.js
Author: Yannick Deubel
Latest version: 3.1.0

<a href="http://geckos.io">
<img src="https://github.com/geckosio/geckos.io/raw/master/readme/logo-256.png" alt="logo" width="128">
</a>

# @geckos.io/server

[![NPM version](https://img.shields.io/npm/v/@geckos.io/server.svg?style=flat-square)](https://www.npmjs.com/package/@geckos.io/server)
[![Downloads](https://img.shields.io/npm/dm/@geckos.io/server.svg?style=flat-square)](https://www.npmjs.com/package/@geckos.io/server)
![Node version](https://img.shields.io/node/v/@geckos.io/server.svg?style=flat-square)
![Snyk Vulnerabilities for GitHub Repo (Specific Manifest)](https://img.shields.io/snyk/vulnerabilities/github/geckosio/geckos.io/packages/server/package.json.svg?style=flat-square)
![NPM](https://img.shields.io/npm/l/@geckos.io/server.svg?style=flat-square)
[![Codecov](https://img.shields.io/codecov/c/github/geckosio/geckos.io?logo=codecov&style=flat-square)](https://codecov.io/gh/geckosio/geckos.io)
[![ES Modules Badge](https://img.shields.io/badge/Node.js-ES%20Modules-F7DF1E?style=flat-square)](https://github.com/yandeu/yandeu/blob/main/posts/2020-05-28-esm-for-nodejs.md)

Real-time client/server communication over UDP using **WebRTC** and **Node.js**.

This framework fits perfectly with your next **HTML5 real-time multiplayer games** or chat app.

Read the [documentation](https://github.com/geckosio/geckos.io) for more information.

## Install

```console
npm install @geckos.io/server
```

## How to use

```js
import geckos from '@geckos.io/server'

const io = geckos()

io.listen()

io.onConnection(channel => {
  channel.onDisconnect(() => {
    console.log(`${channel.id} got disconnected`)
  })

  channel.on('chat message', data => {
    console.log(`got ${data} from "chat message"`)
    // emit the "chat message" data to all channels in the same room
    io.room(channel.roomId).emit('chat message', data)
  })
})
```