Code Monkey home page Code Monkey logo

netlib's Introduction

The Poki Networking Library   

The Poki Networking Library is a peer-to-peer library for web games, using WebRTC datachannels to provide UDP connections between players directly. Like the Steam Networking Library, but for web. Netlib tries to make WebRTC as simple to use as the WebSocket interface (for game development).

Project Status: alpha

This library is still under heavy development and considered in alpha. The library API can and will change without warning and without bumping the major version. Make sure to get in touch if you want to go live with this netlib.

One missing feature that is next on the roadmap is lobby listing and discovery. Currently you can only connect peers by having players share a lobby code externally.

Library main advantages:

  • peer-to-peer (p2p)
    Clients connected to each other using this netlib will be connected directly without a central server in between (unless using the fallback TURN server). This has three main advantages:
    1. No server costs, there is no server running the game.
    2. No double implementation of the game. You don't need to write your game logic twice (for the client and the server).
    3. When players are living close by the latency is often a lot lower than when connected via a server
  • UDP
    Most web games rely on WebSockets or HTTP for communication which is always a TCP connection, but for realtime multiplayer games the UDP protocol is preferred. The main reason is:
    When one packet is slow or dropped UDP doesn't pause new, already received, packets, this is great for things like position updates. The Poki netlib also supplies a reliable data channel useful for chat or npc spawn events.

Setup

First add @poki/netlib as a dependency to your project:

# either using yarn:
yarn add @poki/netlib
# or using npm:
npm i @poki/netlib

Then you can import and create a Network interface:

import { Network } from '@poki/netlib'
const network = new Network('<your-game-id-here>')

(any random UUID is a valid game-id, but if your game is hosted at Poki you should use Poki's game-id)

Next up: read the basic usage guide and make sure to checkout the example code.

STUN, TURN & Signaling Backend

The netlib is a peer-to-peer networking library which means players are connected directly to each other and data send between them is never send to a server.
That said, to setup these connections we need a signaling service. This backend and STUN/TURN servers are hosted by Poki for free. You can however always decide to host the backend yourself.

Main Contributors

netlib's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.