public function send($message, $raw=false)
    {
        if(!$raw && $this->parser){
            $message = call_user_func([$this->parser, 'encode'], $message, $this);
        }
        
        if($message === false || $message === null) {
            return false;
        }
        
        $message = (string)$message;
        
        if($this->isUDP() ) {
            return stream_socket_sendto($this->socket, $message);
        }
        
        if ($this->bufferIsFull()) {
            if($this->_pipe) {
                $this->_pipe->pauseRecv();
            }
            $this->trigger(Server::ON_BUFFER_FULL, new IOEvent());
            return false;
        }
        
        if(!$this->isConnnected()) {
            $this->sendBuffer .= $message;
            return ;
        }
        
        if($this->sendBuffer === ''){
            $len = fwrite($this->socket, $message);
            if ($len === strlen($message)) {
                return true;
            }else if($len >0) {
                $this->sendBuffer = substr($message, $len);
                Yii::$app->eventLooper->add($this->socket, EventLooper::EV_WRITE, [$this, 'baseWrite']);
            } else {
                $error = error_get_last();
                
                $event = new ErrorEvent([
                    'code' => $error['type'],
                    'errstr' => $error['message'],
                ]);
                
                $this->trigger(Server::ON_ERROR, $event);
                
                if(!is_resource($this->socket) || feof($this->socket)){
                    
                    $this->status = static::STATUS_CLOSED;
                    
                    $this->removeEventLooper();
                    
                    $event = new CloseEvent([
                        'by' => CloseEvent::BY_PEER,
                    ]);
                    $this->trigger(Server::ON_CLOSE, $event);
                    $this->destroy();
                    return false;
                }
            }
            
            return $len;
        }else{
            if ($this->bufferIsFull()) {
                $this->trigger(Server::ON_BUFFER_FULL, new IOEvent());
                return false;
            }
            
            $this->sendBuffer .= $message;
            
            return strlen($message);
        }
    }