src/whatsprot.class.php
protected function sendBroadcast($targets, $node, $type)
    {
        if (!is_array($targets)) {
            $targets = [$targets];
        }

        $toNodes = [];
        foreach ($targets as $target) {
            $jid = $this->getJID($target);
            $hash = ['jid' => $jid];
            $toNode = new ProtocolNode('to', $hash, null, null);
            $toNodes[] = $toNode;
        }

        $broadcastNode = new ProtocolNode('broadcast', null, $toNodes, null);

        $msgId = $this->createMsgId();

        $messageNode = new ProtocolNode('message',
            [
                'to'   => time().'@broadcast',
                'type' => $type,
                'id'   => $msgId,
            ], [$node, $broadcastNode], null);

        $this->sendNode($messageNode);
        $this->waitForServer($msgId);
        //listen for response
        $this->eventManager()->fire('onSendMessage',
            [
                $this->phoneNumber,
                $targets,
                $msgId,
                $node,
            ]);

        return $msgId;
    }
protected function sendBroadcast($targets, $node, $type)
    {
        if (!is_array($targets)) {
            $targets = [$targets];
        }

        $toNodes = [];
        foreach ($targets as $target) {
            $jid = $this->getJID($target);
            $hash = ['jid' => $jid];
            $toNode = new ProtocolNode('to', $hash, null, null);
            $toNodes[] = $toNode;
        }

        $broadcastNode = new ProtocolNode('broadcast', null, $toNodes, null);

        $msgId = $this->createMsgId();

        $messageNode = new ProtocolNode('message',
            [
                'to'   => time().'@broadcast',
                'type' => $type,
                'id'   => $msgId,
            ], [$node, $broadcastNode], null);

        $this->sendNode($messageNode);
        $this->waitForServer($msgId);
        //listen for response
        $this->eventManager()->fire('onSendMessage',
            [
                $this->phoneNumber,
                $targets,
                $msgId,
                $node,
            ]);

        return $msgId;
    }
protected function sendBroadcast ( $ targets , $ node , $ type ) { if ( ! is_array ( $ targets ) ) { $ targets = [ $ targets ] ; } $ toNodes = [ ] ; foreach ( $ targets as $ target ) { $ jid = $ this -> getJID ( $ target ) ; $ hash = [ 'jid' => $ jid ] ; $ toNode = new ProtocolNode ( 'to' , $ hash , null , null ) ; $ toNodes [ ] = $ toNode ; } $ broadcastNode = new ProtocolNode ( 'broadcast' , null , $ toNodes , null ) ; $ msgId = $ this -> createMsgId ( ) ; $ messageNode = new ProtocolNode ( 'message' , [ 'to' => time ( ) . '@broadcast' , 'type' => $ type , 'id' => $ msgId , ] , [ $ node , $ broadcastNode ] , null ) ; $ this -> sendNode ( $ messageNode ) ; $ this -> waitForServer ( $ msgId ) ; //listen for response $ this -> eventManager ( ) -> fire ( 'onSendMessage' , [ $ this -> phoneNumber , $ targets , $ msgId , $ node , ] ) ; return $ msgId ; }
Send a broadcast.

@param array  $targets Array of numbers to send to
@param object $node
@param        $type

@return string
Send a broadcast .