FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Socket Class Reference
Inheritance diagram for Socket:
Component Thing

Public Member Functions

 action ($controller_name, $action, $params=null, $read_length=1024)
 Request an action from the HTTP Server on the WebSocket server. More...
 
 token ($params=null)
 Create a WebSocket access token. More...
 
- Public Member Functions inherited from Component
 __construct ($fred, $config=null)
 
 __destruct ()
 
 clientConfig ()
 Public configuration. More...
 
 config ($key, $default=null)
 Retrieve a config value. More...
 
 ping ()
 Ping function. More...
 
 filemtime ($filename)
 Filemtime with session cache. More...
 
 component ($name)
 Get a component (local or default). More...
 
 components (... $names)
 Get multiple components in an array. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

 $clientHost = null
 Host the WebSocket server is running on (for public connections; empty = same as HTTP). More...
 
 $clientPort = null
 Port client websockets can connect to (empty = no connection allowed). More...
 
 $clientPrefix = null
 Prefix for websocket requests (for example when tunneling WSS traffic). More...
 
 $clientLocalPort = null
 When the WebSocket server should listen on another local port then the client connects. More...
 
 $clientOrigins = []
 Allowed origins (empty = all). More...
 
 $tokenTtl = 30
 Time a request token is valid (seconds). More...
 
 $localHost = 'localhost'
 Host the WebSocket server is running on (for local connections). More...
 
 $localPort = 6871
 Port for local connections (HTTP server <-> WebSocket server). More...
 
 $localClients = ['127.0.0.1','::1']
 Allowed clients for a local connection. More...
 
- Data Fields inherited from Component
 $filemtimeTtl = 0
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 getServer ()
 
- Protected Member Functions inherited from Component
 init ()
 
 done ()
 
 getSession ()
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_server = null
 WebSocket server. More...
 
- Protected Attributes inherited from Component
 $_fred = null
 
 $_config = null
 
 $_name = null
 
 $_components = []
 Local components (key = component name, value = component). More...
 
 $_session = null
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Detailed Description

Definition at line 5 of file Socket.php.

Member Function Documentation

◆ action()

action (   $controller_name,
  $action,
  $params = null,
  $read_length = 1024 
)

Request an action from the HTTP Server on the WebSocket server.

Parameters
string$controller_nameControler to apply the action on (empty = local action).
string$actionRequested action.
mixed$paramsParameters for the action.
int$read_lengthMaximum number of bytes to read.
Returns
string Response from the WebSocket server (false on error).
See also
http://php.net/socket_last_error

Definition at line 30 of file Socket.php.

◆ getServer()

getServer ( )
protected

Definition at line 55 of file Socket.php.

◆ token()

token (   $params = null)

Create a WebSocket access token.

Parameters
array$paramsParameters to pass to the WebSocket server (this is used as the session - read-only).
Returns
string Token (false on error; null = not available).

Definition at line 49 of file Socket.php.

Field Documentation

◆ $_server

$_server = null
protected

WebSocket server.

Definition at line 19 of file Socket.php.

◆ $clientHost

$clientHost = null

Host the WebSocket server is running on (for public connections; empty = same as HTTP).

Definition at line 7 of file Socket.php.

◆ $clientLocalPort

$clientLocalPort = null

When the WebSocket server should listen on another local port then the client connects.

Definition at line 10 of file Socket.php.

◆ $clientOrigins

$clientOrigins = []

Allowed origins (empty = all).

Definition at line 12 of file Socket.php.

◆ $clientPort

$clientPort = null

Port client websockets can connect to (empty = no connection allowed).

Definition at line 8 of file Socket.php.

◆ $clientPrefix

$clientPrefix = null

Prefix for websocket requests (for example when tunneling WSS traffic).

Definition at line 9 of file Socket.php.

◆ $localClients

$localClients = ['127.0.0.1','::1']

Allowed clients for a local connection.

Definition at line 17 of file Socket.php.

◆ $localHost

$localHost = 'localhost'

Host the WebSocket server is running on (for local connections).

Definition at line 15 of file Socket.php.

◆ $localPort

$localPort = 6871

Port for local connections (HTTP server <-> WebSocket server).

Definition at line 16 of file Socket.php.

◆ $tokenTtl

$tokenTtl = 30

Time a request token is valid (seconds).

Definition at line 13 of file Socket.php.


The documentation for this class was generated from the following file: