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

  • HttpRequestParser
  • HttpServer
  • OriginCheck
  • Router

Interfaces

  • HttpServerInterface

Traits

  • CloseResponseTrait
  • Overview
  • Namespace
  • Class
  • Tree

Class OriginCheck

A middleware to ensure JavaScript clients connecting are from the expected domain. This protects other websites from open WebSocket connections to your application. Note: This can be spoofed from non-web browser clients

Ratchet\Http\OriginCheck implements Ratchet\Http\HttpServerInterface uses Ratchet\Http\CloseResponseTrait
Namespace: Ratchet\Http
Located at Ratchet/Http/OriginCheck.php
Methods summary
public
# __construct( Ratchet\MessageComponentInterface $component, array $allowed = [] )

Parameters

$component
Ratchet\MessageComponentInterface
$component Component/Application to decorate
$allowed
array
$allowed An array of allowed domains that are allowed to connect from
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()
Properties summary
protected Ratchet\MessageComponentInterface $_component
#
public array $allowedOrigins []
#
Ratchet API documentation generated by ApiGen 2.8.0