Download the PHP package nusje2000/websockets without Composer

On this page you can find all versions of the php package nusje2000/websockets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package websockets

Websocket server

Almost fully compatible with https://tools.ietf.org/html/rfc6455

Simple version can be found here: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers

Data framing

The following data frame was used to parse messages from and to the clients.

Opcodes
hex int text const control
0x0 0 Continuation OpcodeEnum::CONTINUE true
0x1 1 Text OpcodeEnum::TEXT false
0x2 2 Binary OpcodeEnum::BIN false
0x3 3 No meaning OpcodeEnum::OPCODE_3 false
0x4 4 No meaning OpcodeEnum::OPCODE_4 false
0x5 5 No meaning OpcodeEnum::OPCODE_5 false
0x6 6 No meaning OpcodeEnum::OPCODE_6 false
0x7 7 No meaning OpcodeEnum::OPCODE_7 false
0x8 8 Close OpcodeEnum::CLOSE true
0x9 9 Ping OpcodeEnum::PING true
0xA 10 Pong OpcodeEnum::PONG true
0xB 11 No meaning OpcodeEnum::OPCODE_11 true
0xC 12 No meaning OpcodeEnum::OPCODE_12 true
0xD 13 No meaning OpcodeEnum::OPCODE_13 true
0xE 14 No meaning OpcodeEnum::OPCODE_14 true
0xF 15 No meaning OpcodeEnum::OPCODE_15 true
Mapping

All incomming frames are being mapped to the Frame class, this class is basically an oop version of the dataframe displayed above. The following mapping is used:

Additional functionallity

There are a few functions added to the Frame for ease of use:

Events

The websocket makes use of the symfony event dispatcher. Because of this, each incomming dataframe wil dispatch an event. This event can be used to react on incomming frames. The following is a list of events that can be listened to:

Event class Reason
HandshakeEvent first data sent over a new connection will be treated as handshake request
ConnectEvent new connection (handshake is already done when this event is triggered)
DataEvent received data (triggered when data is received)
FrameEvent received frame (triggered when a frame is received)
MessageEvent received message (only works when the FrameEventSubscriber is an active listener, triggered when a frame is received with TEXT opcode)
DisconnectEvent disconnected (triggered when a connection is disconned)

For all events to be dispatched there are 4 event dispatchers. The following is a list of the dispatchters and their in-/outgoning events:

Dispatcher Incomming events Outgoing events Purpose
HandshakeEventSubscriber HandshakeEvent ConnectEvent Handle handshake and dispatch a connect event when successfull
ConnectionEventSubscriber ConnectEvent, DisconnectEvent DataEvent, DisconnectEvent Handle connection and map connection events
DataEventSubscriber DataEvent FrameEvent Parse incomming data to a frame and dispatch as frame event
FrameEventSubscriber FrameEvent MessageEvent Handle incomming frame event and dispatch a Message event if the opcode is TEXT

Running the example

There is a simple chat application included in this project. To run this, use the following commands:

You must run both commands separate from each other

Known issues

  1. Fragmentations is not supported yet
  2. Encode function of the encoder does not yet support masking
  3. Strings longer than 65536 cannot be received due to buffering

All versions of websockets with dependencies

PHP Build Version
Package Version
Requires react/socket Version ^1.1
symfony/event-dispatcher Version ^3.4 || ^4.0
psr/log Version ^1.1
aeviiq/collection Version ^2.0
myclabs/php-enum Version ^1.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nusje2000/websockets contains the following files

Loading the files please wait ....