Skip to content

Commit

Permalink
Update TcpConnection.php
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor committed May 19, 2015
1 parent 77ae7ec commit 31767d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Connection/TcpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ public function __construct($socket)
*/
public function send($send_buffer, $raw = false)
{
// 如果没有设置以原始数据发送,并且有设置协议则按照协议编码
if(false === $raw && $this->protocol)
{
$parser = $this->protocol;
$send_buffer = $parser::encode($send_buffer, $this);
}

// 如果当前状态是连接中,则把数据放入发送缓冲区
if($this->_status === self::STATUS_CONNECTING)
{
Expand All @@ -226,12 +233,6 @@ public function send($send_buffer, $raw = false)
return false;
}

// 如果没有设置以原始数据发送,并且有设置协议则按照协议编码
if(false === $raw && $this->protocol)
{
$parser = $this->protocol;
$send_buffer = $parser::encode($send_buffer, $this);
}
// 如果发送缓冲区为空,尝试直接发送
if($this->_sendBuffer === '')
{
Expand Down

0 comments on commit 31767d2

Please sign in to comment.