bool AppCastingMOOSApp::OnNewMail(MOOSMSG_LIST &NewMail)
{
    m_curr_time = MOOSTime();

    MOOSMSG_LIST::iterator p;
    for(p=NewMail.begin(); p!=NewMail.end();) {
        CMOOSMsg &msg = *p;
        if(msg.GetKey() == "APPCAST_REQ") {
            handleMailAppCastRequest(msg.GetString());
            p = NewMail.erase(p);
        }
        else if(msg.GetKey() == "_async_timing")
            p = NewMail.erase(p);
        else
            ++p;
    }
    return(true);
}
//a static helper function
bool CMOOSCommClient::PeekMail(MOOSMSG_LIST &Mail,
							   const string &sKey, 
							   CMOOSMsg &Msg,
							   bool bRemove,
							   bool bFindYoungest )
{
	MOOSMSG_LIST::iterator p;
	MOOSMSG_LIST::iterator q =Mail.end();

	double dfYoungest = -1;

	for(p = Mail.begin();p!=Mail.end();p++)
	{
		if(p->m_sKey==sKey)
		{
			//might want to consider more than one msg....

			if(bFindYoungest)
			{
				if(p->m_dfTime>dfYoungest)
				{
					dfYoungest=p->m_dfTime;
					q = p;
				}
			}
			else
			{
				//simply take first
				q=p;
				break;
			}

		}
	}

	if(q!=Mail.end())
	{
		Msg=*q;

		if(bRemove)
		{
			//Mail.erase(p);
			Mail.erase(q);
		}
		return true;

	}

	return false;
}