+ // fprintf(STDERR, "Arrivati %d bytes dalla socket n. %d\n", mb_strlen($buf, "ASCII"), $key);
+
+ if (isset($this->s2u[$id])) {
+ //
+ // TODO:
+ // fix $addr
+ // fix $this->pendpage_try_addflush below (probably not required)
+ //
+ $addr = "127.0.0.1";
+ $user = $this->s2u[$id];
+
+ // fprintf(STDERR, 'POST USER');
+ if ($user && $user->rd_transp && strpos($user->rd_transp->type, "websocket") !== FALSE) {
+ $clie_cmd = $user->rd_transp->unchunk($buf, $sock);
+ $clie_cmd = json_decode($clie_cmd, TRUE);
+ // fprintf(STDERR, "HERE WE ARE INCOMING DATA [%s]\n", print_r($clie_cmd, TRUE));
+
+ $wr_addr = substr(parse_url($clie_cmd["target"])["path"], strlen(SITE_PREFIX));
+ if ($wr_addr == "index_wr.php") {
+ ob_start();
+ // complete: index_wr_main($this->app, $addr, $get, $post, $cookie);
+ index_wr_main($this->app, $addr, $clie_cmd, NULL, NULL);
+ $content = ob_get_contents();
+ ob_end_clean();
+ }
+ else if ($wr_addr == "briskin5/index_wr.php") {
+ $table_idx = $clie_cmd['table_idx'];
+ $table_token = $clie_cmd['table_token'];
+
+ if (($bri = $this->app->match_get($table_idx, $table_token)) != FALSE) {
+ ob_start();
+ bin5_index_wr_main($bri, $addr, $clie_cmd, NULL, NULL);
+ $content = ob_get_contents();
+ ob_end_clean();
+ }
+ }
+ else {
+ fprintf(STDERR, "Unknown page [%s]\n", $wr_addr);
+ }
+ /*
+ briskin5/index_wr.php
+
+ if (isset($table_idx) && isset($table_token)) {
+ if (($bri = $s_a_p->app->match_get($table_idx, $table_token)) != FALSE) {
+ ob_start();
+ bin5_index_wr_main($bri, $addr, $get, $post, $cookie);
+ $content = ob_get_contents();
+ ob_end_clean();
+ }
+ else {
+ $content = "Bin5 Load data error";
+ }
+ }
+ else {
+ $content = "Bin5 Load data error";
+ }
+ $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
+ */
+ }
+ }
+ else {
+ fprintf(STDERR, "User associated with ID: %s not found\n", $id);
+ }
+
+ if (isset($this->s2p[$id])) {
+ $this->s2p[$id]->rest -= mb_strlen($buf, "ASCII");
+ $this->s2p[$id]->cont .= $buf;
+ if ($this->s2p[$id]->rest <= 0) {
+ $header = $new_socket = $path = $addr = $get = $cookie = 0;
+ $post = array();
+
+ $this->s2p[$id]->context_get($header, $new_socket, $path, $addr, $get, $post, $cookie);
+ $this->pendpage_rem($this->s2p[$id]);
+ fprintf(STDERR, "SOCKET RUN: %s\n", $new_socket);
+
+ $manage_page = TRUE;
+ }
+ }
+
+ // postclose case
+ if (isset($this->s2c[$id])) {
+ $postclose = $this->s2c[$id];
+ // printf("POSTCLOSE: found pc in s2c list\n");
+ if ($postclose->read($buf, $this->curtime) == 0) {
+ printf("POSTCLOSE: received end opcode, close\n");
+ fclose($sock);
+ $this->socks_unset($sock);
+ }
+ }