Skip to content

Commit

Permalink
Some improvements/bugfixes on receiving binary frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekudo committed Jan 15, 2012
1 parent 0b3e51b commit eb13f89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions client/coffee/client.coffee
Expand Up @@ -33,8 +33,7 @@ $(document).ready ->
payload = new Object()
payload.action = 'setFilename'
payload.data = $('#file').val()
socket.send JSON.stringify payload
i for i in [1..1000000]
socket.send JSON.stringify payload
socket.send(data)
return false

11 changes: 9 additions & 2 deletions server/lib/WebSocket/Application/DemoApplication.php
Expand Up @@ -71,8 +71,15 @@ private function _actionEcho($text)

private function _actionSetFilename($filename)
{
$filename = basename($filename);
if(!empty($filename))
if(strpos($filename, '\\') !== false)
{
$filename = substr($filename, strrpos($filename, '\\')+1);
}
elseif(strpos($filename, '/') !== false)
{
$filename = substr($filename, strrpos($filename, '/')+1);
}
if(!empty($filename))
{
$this->_filename = $filename;
return true;
Expand Down
2 changes: 1 addition & 1 deletion server/lib/WebSocket/Connection.php
Expand Up @@ -480,7 +480,7 @@ private function hybi10Decode($data)
* data is transferd.
*/
if(strlen($data) < $dataLength)
{
{
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions server/lib/WebSocket/Server.php
Expand Up @@ -35,7 +35,7 @@ public function run()
while(true)
{
$changed_sockets = $this->allsockets;
socket_select($changed_sockets, $write = null, $except = null, null);
socket_select($changed_sockets, $write = null, $except = null, 0, 5000);
foreach($changed_sockets as $socket)
{
if($socket == $this->master)
Expand Down Expand Up @@ -76,7 +76,7 @@ public function run()
else
{
$client = $this->clients[(int)$socket];
$bytes = socket_recv($socket, $data, 1024, 0);
$bytes = socket_recv($socket, $data, 8192, 0);

if($bytes === false)
{
Expand Down

0 comments on commit eb13f89

Please sign in to comment.