libs/library.php
/**
     * Waits for a msg. if not in items add msg else wait until msg is received
     * @param $msg
     * @return bool
     */
Waits for a msg. if not in items add msg else wait until msg is received
@param $msg
@return bool
Waits for a msg . if not in items add msg else wait until msg is received @param $msg @return bool
public function WaitFor($msg)
    {
        if (!preg_match(DuoFernRegex::DUOFERN_REGEX_MSG_WILDCHARS, $msg)) {
            return false;
        }
        foreach ($this->items as $key => $item) {
            if (preg_match('/^' . $item['msg'] . '$/', $msg) && $item['received'] == true) { 
                unset ($this->items[$key]);
                return true;
            } else if ($item['msg'] == $msg && $item['received'] == false) { 
                return false;
            }
        }
        $this->items[] = array("msg" => $msg, "received" => false);
        return false;
    }
public function WaitFor ( $ msg ) { if ( ! preg_match ( DuoFernRegex :: DUOFERN_REGEX_MSG_WILDCHARS , $ msg ) ) { return false ; } foreach ( $ this -> items as $ key => $ item ) { if ( preg_match ( '/^' . $ item [ 'msg' ] . '$/' , $ msg ) && $ item [ 'received' ] == true ) { unset ( $ this -> items [ $ key ] ) ; return true ; } else if ( $ item [ 'msg' ] == $ msg && $ item [ 'received' ] == false ) { return false ; } } $ this -> items [ ] = array ( " msg " => $ msg , " received " => false ) ; return false ; }
Waits for a msg.
Waits for a msg .
// check valid msg // received // wait // new message