芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/joolsmen.com/chat/class.chathandler.php
125 && $length < 65536) $header = pack('CCn', $b1, 126, $length); elseif($length >= 65536) $header = pack('CCNN', $b1, 127, $length); return $header.$socketData; } function doHandshake($received_header,$client_socket_resource, $host_name, $port) { $headers = array(); $lines = preg_split("/\r\n/", $received_header); foreach($lines as $line) { $line = chop($line); if(preg_match('/\A(\S+): (.*)\z/', $line, $matches)) { $headers[$matches[1]] = $matches[2]; } } $secKey = $headers['Sec-WebSocket-Key']; $secAccept = base64_encode(pack('H*', sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'))); $buffer = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" . "Upgrade: websocket\r\n" . "Connection: Upgrade\r\n" . "WebSocket-Origin: $host_name\r\n" . "WebSocket-Location: ws://$host_name:$port/demo/shout.php\r\n". "Sec-WebSocket-Accept:$secAccept\r\n\r\n"; socket_write($client_socket_resource,$buffer,strlen($buffer)); } function newConnectionACK($client_ip_address) { $message = 'New client ' . $client_ip_address.' joined'; $messageArray = array('message'=>$message,'message_type'=>'chat-connection-ack'); $ACK = $this->seal(json_encode($messageArray)); return $ACK; } function connectionDisconnectACK($client_ip_address) { $message = 'Client ' . $client_ip_address.' disconnected'; $messageArray = array('message'=>$message,'message_type'=>'chat-connection-ack'); $ACK = $this->seal(json_encode($messageArray)); return $ACK; } function createChatBoxMessage($chat_user,$chat_box_message) { $message = $chat_user . ":
" . $chat_box_message . "
"; $messageArray = array('message'=>$message,'message_type'=>'chat-box-html'); $chatMessage = $this->seal(json_encode($messageArray)); return $chatMessage; } } ?>