Changeset 461

Show
Ignore:
Timestamp:
04/09/07 09:25:30 (15 years ago)
Author:
ppalmers
Message:

- Osc requests now don't require a perfect path match to work.

e.g. an OscNode? at path '/X/Y' will now handle OscMessages? for '/X/Y/Z'

if 'Z' is not registered as a child OscNode? of '/X/Y'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libosc/OscNode.cpp

    r445 r461  
    7676OscNode::processOscMessage(string path, OscMessage *m) 
    7777{ 
    78     debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) MSG: %s\n",this, path.c_str()); 
     78    debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) {%s} MSG: %s\n", this, m_oscBase.c_str(), path.c_str()); 
    7979 
    8080    // delete leading slash 
     
    9191 
    9292        // process the message 
     93        m->setPath(""); // handled by the node itself 
    9394        retVal=processOscMessage(m); 
    9495 
     
    100101 
    101102    } else { // it targets a deeper node 
     103        OscResponse retVal; 
     104         
    102105        string newpath=path.substr(firstsep+1); 
    103106        int secondsep=newpath.find_first_of('/'); 
     
    109112        } 
    110113 
     114        // first try to find a child node that might be able 
     115        // to handle this. 
     116        // NOTE: the current model allows only one node to  
     117        //       handle a request, and then the default 
     118        //       handler. 
    111119        for ( OscNodeVectorIterator it = m_ChildNodes.begin(); 
    112120          it != m_ChildNodes.end(); 
     
    117125            } 
    118126        } 
     127         
     128        // The path is not registered as a child node. 
     129        // This node should handle it 
    119130        debugOutput( DEBUG_LEVEL_VERBOSE, "Child node %s not found \n",newbase.c_str()); 
    120131 
    121         return OscResponse(OscResponse::eError); 
     132        m->setPath(newpath); // the remaining portion of the path 
     133        retVal=processOscMessage(m); 
     134 
     135        if(retVal.isHandled()) { 
     136            return retVal; // completely handled 
     137        } 
     138        // (partially) unhandled 
     139        return processOscMessageDefault(m, retVal); 
    122140    } 
    123141    return OscResponse(OscResponse::eError); 
     
    130148OscNode::processOscMessage(OscMessage *m) 
    131149{ 
    132     debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) MSG PROCESS: %s\n", this, m->getPath().c_str()); 
     150    debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) {%s} DEFAULT PROCESS: %s\n", this, m_oscBase.c_str(), m->getPath().c_str()); 
    133151    m->print(); 
    134152    return OscResponse(OscResponse::eUnhandled); // handled but no response 
  • trunk/libffado/src/libosc/unittests.cpp

    r452 r461  
    104104    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child1/subchild1",&m).isError()); 
    105105    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child1/subchild2",&m).isError()); 
    106     result &= TEST_SHOULD_RETURN_TRUE(n1.processOscMessage("base1/child1/subchild3",&m).isError()); 
    107106    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child2",&m).isError()); 
    108     result &= TEST_SHOULD_RETURN_TRUE(n1.processOscMessage("base1/child2/subchild1",&m).isError()); 
     107    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child1/subchild3",&m).isHandled()); 
     108    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child2/subchild1/test1",&m).isHandled()); 
    109109 
    110110    return result;