*/
define('SITE_PREFIX', '/brisk/');
+define('SITE_PREFIX_LEN', 7);
function spu_process_info($stream_info, $method, &$header, &$get, &$post, &$cookie)
{
var $debug;
var $blocking_mode;
- var $room;
+ var $app;
var $bin5;
var $curtime;
// Sac_a_push::create("/tmp/brisk.sock", 0, 0
- static function create(&$room, $sockname, $debug, $blocking_mode)
+ static function create(&$app, $sockname, $debug, $blocking_mode)
{
$thiz = new Sac_a_push();
- $thiz->room = $room;
+ $thiz->app = $app;
$thiz->file_socket = $sockname;
$thiz->unix_socket = "unix://$sockname";
$thiz->debug = $debug;
$addr = stream_socket_get_name($new_socket, TRUE);
$header_out = array();
- $this->room->request_mgr($this, $header_out, $new_socket, $path, $addr, $get, $post, $cookie);
+ $subs = SITE_PREFIX."briskin5/";
+ $subs_l = strlen($subs);
+ $rret = FALSE;
+ if (!strncmp($path, SITE_PREFIX, SITE_PREFIX_LEN)) {
+ $rret = $this->app->request_mgr($this, $header_out, $new_socket, substr($path, SITE_PREFIX_LEN), $addr, $get, $post, $cookie);
+ }
+ if ($rret == FALSE) {
+ // FIXME: manage 404 !!!
+ printf("TODO: fix unknown page\n");
+ }
printf("number of sockets after %d\n", count($this->socks));
}
else {
else {
if (($buf = fread($sock, 512)) === FALSE) {
printf("error read\n");
- exit(123);
}
else if (strlen($buf) === 0) {
if ($sock === $this->list) {
}
}
else {
- if ($debug > 1) {
+ if ($this->debug > 1) {
print_r($read);
}
if ($sock === $this->list) {
}
+ $this->app->garbage_manager(FALSE);
+
+
/* manage unfinished pages */
foreach ($this->pages_flush as $k => $pgflush) {
if ($pgflush->try_flush($this->curtime) == TRUE) {
if (isset($this->s2u[intval($sock)])) {
$user = $this->s2u[intval($sock)];
$response = $user->rd_cache_get();
+ if (($this->curtime - $user->lacc) <= (EXPIRE_TIME_RD / 2)) {
+ $user->ping_req = FALSE;
+ }
if ($response == "") {
$content = "";
$user->stream_main($content, $get, $post, $cookie);
-
+ printf("[%s] [%d] [%d]\n", $user->name, $user->lacc, $this->curtime);
+ if ($content == "" && $user->ping_req == FALSE
+ && (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 2))) {
+ $content = $user->stream_ping();
+ $user->ping_req = TRUE;
+ }
if ($content == "" && $user->rd_kalive_is_expired($this->curtime)) {
$content = $user->stream_keepalive();
}
}
if ($response != "") {
- echo "SPIA: [".substr($response, 0, 60)."...]\n";
+ // echo "SPIA: [".substr($response, 0, 60)."...]\n";
+ echo "SPIA: [".$response."...]\n";
$response_l = mb_strlen($response, "ASCII");
$wret = @fwrite($sock, $response);
if ($wret < $response_l) {