Wamp/Client.php
protected function send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true)
    {
        $rawMessage = json_encode($data);
        $payload = new WebsocketPayload();
        $payload
            ->setOpcode($opcode)
            ->setMask($masked)
            ->setPayload($rawMessage);

        $encoded = $payload->encodePayload();

        if (0 === @fwrite($this->socket, $encoded)) { //connection reseted by peers, just reconnect.
            $this->connected = false;
            $this->connect($this->target);

            fwrite($this->socket, $encoded);
        }

        return $this;
    }
protected function send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true)
    {
        $rawMessage = json_encode($data);
        $payload = new WebsocketPayload();
        $payload
            ->setOpcode($opcode)
            ->setMask($masked)
            ->setPayload($rawMessage);

        $encoded = $payload->encodePayload();

        if (0 === @fwrite($this->socket, $encoded)) { //connection reseted by peers, just reconnect.
            $this->connected = false;
            $this->connect($this->target);

            fwrite($this->socket, $encoded);
        }

        return $this;
    }
protected function send ( $ data , $ opcode = WebsocketPayload :: OPCODE_TEXT , $ masked = true ) { $ rawMessage = json_encode ( $ data ) ; $ payload = new WebsocketPayload ( ) ; $ payload -> setOpcode ( $ opcode ) -> setMask ( $ masked ) -> setPayload ( $ rawMessage ) ; $ encoded = $ payload -> encodePayload ( ) ; if ( 0 === @ fwrite ( $ this -> socket , $ encoded ) ) { //connection reseted by peers, just reconnect. $ this -> connected = false ; $ this -> connect ( $ this -> target ) ; fwrite ( $ this -> socket , $ encoded ) ; } return $ this ; }
Send message to the websocket.


@param array $data

@return $this|Client
Send message to the websocket .