bool OsNatSocketBaseImpl::handleSturnData(char*      buffer, 
                                          int&       bufferLength,
                                          UtlString& receivedIp,
                                          int&       receivedPort)
{
    bool bHandled = false ;
    bool bDataIndication = false ;

    if ((bufferLength > 0) && TurnMessage::isTurnMessage(buffer, bufferLength, &bDataIndication))
    {
        if (bDataIndication)
        {
            bufferLength = handleTurnDataIndication(buffer, bufferLength, 
                    &receivedIp, &receivedPort) ;

            // We need to recurse for DIs -- it may be an encapsulated STUN 
            // message (e.g. ICE)
            return handleSturnData(buffer, bufferLength, receivedIp, receivedPort) ;
        }
        else
        {
            handleTurnMessage(buffer, bufferLength, receivedIp, receivedPort) ;
            bHandled = true ;           
        }
    }
    else if ((bufferLength > 0) && StunMessage::isStunMessage(buffer, 
            bufferLength))
    {
        handleStunMessage(buffer, bufferLength, receivedIp, receivedPort) ;
        bHandled = true ;
    }

    return bHandled ;
}
示例#2
0
void Controller::handleMessage(Message &msg)
{
	if (msg.getName() == Constants::MESSAGE_KEY_TURN)
	{
		handleTurnMessage(msg);
	}
	else if (msg.getName() == Constants::MESSAGE_KEY_INIT)
	{
		handleInitMessage(msg);
	}
	else if (msg.getName() == Constants::MESSAGE_KEY_SHUTDOWN
			|| msg.getName() == Constants::MESSAGE_KEY_WRONG_TOKEN)
	{
		network->terminate();
	}
}