Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/08/2011, 07:30
IDRID
 
Fecha de Ingreso: mayo-2010
Mensajes: 118
Antigüedad: 13 años, 11 meses
Puntos: 1
Pregunta HTML5 WebSockets Chat

Hola, necesito ayuda con este chat:

http://idridplanet.blogspot.com/p/community.html

Mirar los codigos javascript en el codigo de fuente de la pagina, que es un poco largo y tengo que poner los de PHP tamben xD!

Server.php

Código PHP:
<?php
// run this file via the php CLI: php server.php 127.0.0.1 9090

if ($argc != 3) {
    print(
"Usage: server.php ip_address port\n");
    echo 
$ip_address;
    echo 
$port;
    exit(
1);
}

// gather settings from script arguments
$ip_address $argv[1];
$port $argv[2];

// show us all errors
error_reporting(E_ALL E_NOTICE);
// keep running until script aborts or we're killed
set_time_limit(0);
// flush output buffering
ob_implicit_flush();

// include the WebSocketServer class file
require_once 'http://idridmoon.byethost13.com/community/WebSocketServer.class.php';

// callback function
function process($sourceUser$msg$server){

    
// echo the data back to all connected users
    
foreach($server->getUsers() as $user){
        
$server->send($user->socket$msg);
    }
}

// instantiate the server class
// new WebSocketServer( socket address, socket port, callback function )
$webSocket = new WebSocketServer($ip_address$port'process');
// start it up
$webSocket->run();
El otro archivo del include esta aqui: https://github.com/remy/html5demos/tree/master/server/