PHP Classes

File: examples/websocket/server.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   examples/websocket/server.php   Download  
File: examples/websocket/server.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 1,077 bytes
 

Contents

Class file image Download
<?php
/**
 * This is a simple socket server setup for WebSockets
 */
$ConfigArray = array(
   
'PATH' => dirname(__FILE__) . '/',
   
'APP' => dirname(__FILE__) . '/app',
   
'SOCKET' => array(
       
'host' => 'localhost',
       
'port' => '9091',
       
'class-client' => 'A_Socket_Client_Websocket',
       
'class-message' => 'A_Socket_Message_Json',
       
'message-connect' => '{"type":{"module":"","controller":"connect","action":"user"},"data":null}',
       
'message-disconnect' => '{"type":{"module":"","controller":"disconnect","action":"user"},"data":null}'
   
),
   
'DEFAULT_ACTION' => array('', 'main', 'main'),
   
'ERROR_ACTION' => array('', 'main', 'main')
);

include
$ConfigArray['PATH'] . '../../A/Locator.php';
$Locator = new A_Locator();
$Locator->autoload();

$Config = new A_Config_Php();
$Config->import($ConfigArray);

$Locator->set('Config', $Config);

$EventListener = new A_Socket_Eventlistener_Frontcontroller($Locator);

$EventManager = new A_Event_Manager();
$EventManager->addEventListener($EventListener);

$Server = new A_Socket_Server($EventManager);
$Server->run($ConfigArray['SOCKET']);