reSIProcate/repro  9694
XmlRpcConnection.hxx
Go to the documentation of this file.
00001 #if !defined(XmlRpcConnection_hxx)
00002 #define XmlRpcConnection_hxx 
00003 
00004 #include <map>
00005 #include <rutil/Data.hxx>
00006 #include <rutil/Socket.hxx>
00007 #include <rutil/TransportType.hxx>
00008 #include <resip/stack/Tuple.hxx>
00009 
00010 #include "repro/XmlRpcServerBase.hxx"
00011 
00012 namespace repro
00013 {
00014 
00015 class XmlRpcConnection
00016 {
00017    friend class XmlRpcServerBase;
00018       
00019 public:
00020    XmlRpcConnection(XmlRpcServerBase& server, resip::Socket sock);
00021    ~XmlRpcConnection();
00022    
00023    unsigned int getConnectionId() const { return mConnectionId; }
00024    void buildFdSet(resip::FdSet& fdset);
00025    bool process(resip::FdSet& fdset);
00026 
00027    virtual bool sendResponse(unsigned int requestId, const resip::Data& responseData, bool isFinal);
00028    virtual void sendEvent(const resip::Data& eventData);
00029 
00030 private:
00031    bool processSomeReads();
00032    bool processSomeWrites();
00033    bool tryParse(); // returns true if we processed something and there is more data in the buffer
00034             
00035    XmlRpcServerBase& mXmlRcpServer;
00036    const unsigned int mConnectionId;
00037    static unsigned int NextConnectionId;
00038 
00039    unsigned int mNextRequestId;
00040    typedef std::map<unsigned int, resip::Data> RequestMap;
00041    RequestMap mRequests;
00042            
00043    resip::Socket mSock;
00044    resip::Data mRxBuffer;
00045    resip::Data mTxBuffer;
00046 };
00047 
00048 }
00049 
00050 #endif  
00051 
00052 /* ====================================================================
00053  * The Vovida Software License, Version 1.0 
00054  * 
00055  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00056  * Copyright (c) 2010 SIP Spectrum, Inc.  All rights reserved.
00057  * 
00058  * Redistribution and use in source and binary forms, with or without
00059  * modification, are permitted provided that the following conditions
00060  * are met:
00061  * 
00062  * 1. Redistributions of source code must retain the above copyright
00063  *    notice, this list of conditions and the following disclaimer.
00064  * 
00065  * 2. Redistributions in binary form must reproduce the above copyright
00066  *    notice, this list of conditions and the following disclaimer in
00067  *    the documentation and/or other materials provided with the
00068  *    distribution.
00069  * 
00070  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00071  *    and "Vovida Open Communication Application Library (VOCAL)" must
00072  *    not be used to endorse or promote products derived from this
00073  *    software without prior written permission. For written
00074  *    permission, please contact vocal@vovida.org.
00075  *
00076  * 4. Products derived from this software may not be called "VOCAL", nor
00077  *    may "VOCAL" appear in their name, without prior written
00078  *    permission of Vovida Networks, Inc.
00079  * 
00080  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00081  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00082  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00083  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00084  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00085  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00086  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00087  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00088  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00089  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00090  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00091  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00092  * DAMAGE.
00093  * 
00094  * ====================================================================
00095  * 
00096  * This software consists of voluntary contributions made by Vovida
00097  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00098  * Inc.  For more information on Vovida Networks, Inc., please see
00099  * <http://www.vovida.org/>.
00100  *
00101  */