Code Monkey home page Code Monkey logo

php-websocket's Introduction

PHP WebSocket

Simple WebSocket server for PHP

Version: 1.0.0

A simple websocket server for PHP 5.3, using streams.

Features

  • Supports websocket draft hybi-10,13 (Currently tested with Chrome 18 and Firefox 11).
  • Supports origin-check.
  • Supports various security/performance settings.
  • Supports binary frames. (Currently receive only)
  • Supports wss. (Needs valid certificate in Firefox.)

Backward compatibility

The public API of the server should remain compatible with early versions of php-websocket. The WebSocket namespace begins in the /server/lib directory. The client-side libraries are deprecated and may be removed in future: the exist as an example. You're free to use whatever client-side libraries you'd like with the server.

Installation

The library is PSR-0 compatible, with a vendor name of WebSocket (note the capital S). An SplClassLoader is bundled for convenience.

Usage

This creates a server on 127.0.0.1:8000 with one Application that listens on ws://localhost:8000/demo:

// $interface, $port, $ssl
$server = new \WebSocket\Server(127.0.0.1', 8000, false);

// Origin checking is supported
$server->setCheckOrigin(true);
$server->setAllowedOrigin('example.org')

// As is basic rate limiting
$server->setMaxClients(100);
$server->setMaxConnectionsPerIp(20);
$server->setMaxRequestsPerMinute(1000);

$server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance());
$server->run();

Authors

The original maintainer and author was @nicokaiser. Plentiful improvements were contributed by @lemmingzshadow and @mazhack. The server is licensed under the WTFPL, a free software compatible license.

Bugs/Todos/Hints

  • Add support for fragmented frames.
  • To report issues, see the issue tracker.

Examples

  • Jitt.li, a Twitter API sample project.

php-websocket's People

Contributors

dominics avatar mazhack avatar nekudo avatar nicokaiser avatar

Watchers

 avatar  avatar

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.