FlashPolicy

Purpose of this Component

Allow browsers that don't natively support WebSockets to connect to your Ratchet app with Flash Sockets.

In your HTML include the JavaScript library web-socket-js, which is a client-side polyfill for the WebSocket API.

In order for Flash to communicate with a server through sockets, it must first gain permission via an XML response on the 843 port. Flash will make this request automatically before it connects to your WebSocket application server.

This means you need to run two shell scripts; one on port 843 wit FlashPolicy and one on port 80 for your application.

Note: This component is bundled within the App class. It assumes port 843 if you're running on port 80 and 8843 if otherwise (proxy forwarding).

Configuration methods

  • FlashPolicy addAllowedAccess (string $domain, string $ports, bool $secure) - Whitelist a client based on their domain, port and if the connection must be secured or not
  • FlashPolicy setSiteControl (string $permittedCrossDomainPolicies) - Set to one of "all", "master-only", or "none" (if you know what you're doing) - default is "all"

Wraps other components nicely

None

Wrapped by other components nicely

Usage

<?php
// Your shell script
use Ratchet\Server\FlashPolicy;
use Ratchet\Server\IoServer;

    $flash = new FlashPolicy;
    $flash->addAllowedAccess('*', 8080); // Allow all Flash Sockets from any domain to connect on port 8080

    $server = IoServer::factory($flash, 843);
    $server->run();