Overview

Namespaces

  • Evenement
  • None
  • PHP
  • Psr
    • Http
      • Message
  • Ratchet
    • Http
    • RFC6455
      • Handshake
      • Messaging
    • Server
    • Session
      • Serialize
      • Storage
        • Proxy
    • Wamp
    • WebSocket
  • React
    • EventLoop
      • Tick
      • Timer
    • Socket
    • Stream
  • Symfony
    • Component
      • HttpFoundation
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
      • Routing
        • Annotation
        • Exception
        • Generator
          • Dumper
        • Loader
          • DependencyInjection
        • Matcher
          • Dumper
        • Tests
          • Annotation
          • Fixtures
            • AnnotatedClasses
            • OtherAnnotatedClasses
          • Generator
            • Dumper
          • Loader
          • Matcher
            • Dumper

Classes

  • ConnContext
  • WsConnection
  • WsServer

Interfaces

  • MessageCallableInterface
  • MessageComponentInterface
  • WsServerInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class WsServer

The adapter to handle WebSocket requests/responses This is a mediator between the Server and your application to handle real-time messaging through a web browser

Ratchet\WebSocket\WsServer implements Ratchet\Http\HttpServerInterface uses Ratchet\Http\CloseResponseTrait
Namespace: Ratchet\WebSocket
Link: http://ca.php.net/manual/en/ref.http.php
Link: http://dev.w3.org/html5/websockets/
Located at Ratchet/WebSocket/WsServer.php
Methods summary
public
# __construct( Ratchet\ComponentInterface $component )

Parameters

$component
Ratchet\WebSocket\MessageComponentInterface|Ratchet\MessageComponentInterface
$component Your application to run with WebSockets

Note

If you want to enable sub-protocols have your component implement WsServerInterface as well
public
# onOpen( Ratchet\ConnectionInterface $conn, Psr\Http\Message\RequestInterface $request = null )

Parameters

$conn
Ratchet\ConnectionInterface
$conn
$request
Psr\Http\Message\RequestInterface
$request null is default because PHP won't let me overload; don't pass null!!!

Throws

UnexpectedValueException
if a RequestInterface is not passed

Implementation of

Ratchet\Http\HttpServerInterface::onOpen()
public
# onMessage( Ratchet\ConnectionInterface $from, string $msg )

Triggered when a client sends data through the socket

Triggered when a client sends data through the socket

Parameters

$from
Ratchet\ConnectionInterface
$from The socket/connection that sent the message to your application
$msg
string
$msg The message received

Throws

Exception

Implementation of

Ratchet\MessageInterface::onMessage()
public
# onClose( Ratchet\ConnectionInterface $conn )

This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.

This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.

Parameters

$conn
Ratchet\ConnectionInterface
$conn The socket/connection that is closing/closed

Throws

Exception

Implementation of

Ratchet\ComponentInterface::onClose()
public
# onError( Ratchet\ConnectionInterface $conn, Exception $e )

If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown, the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method

If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown, the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method

Parameters

$conn
Ratchet\ConnectionInterface
$conn
$e
Exception
$e

Throws

Exception

Implementation of

Ratchet\ComponentInterface::onError()
public
# onControlFrame( Ratchet\RFC6455\Messaging\FrameInterface $frame, Ratchet\WebSocket\WsConnection $conn )
public
# setStrictSubProtocolCheck( mixed $enable )
public
# enableKeepAlive( React\EventLoop\LoopInterface $loop, mixed $interval = 30 )
Properties summary
protected SplObjectStorage $connections
#
Ratchet API documentation generated by ApiGen 2.8.0