UdpSwitch.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2005-2007 by Peter Dimov.
00004 
00005 This file is part of Calitko (http://www.calitko.org).
00006 
00007 Calitko is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 Calitko is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Calitko; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #ifndef PROTOCOLS__TRANSPORTS__UDP_SWITCH_H
00024 #define PROTOCOLS__TRANSPORTS__UDP_SWITCH_H
00025 
00026 #include "NodeAddress.h"
00027 
00028 namespace Protocols {
00029 namespace Transports {
00030 
00031 class UdpConnection;
00032 class UdpSwitchPrivate;
00033 
00035 
00044 class UdpSwitch : public QObject
00045 {
00046     Q_OBJECT
00047     REFERENCE_OBJECT (UdpSwitch)
00048 
00049 public:
00050                     UdpSwitch();
00051                     ~UdpSwitch();
00052 
00053     bool            start (const NodeAddress &switchAddress,
00054                            bool acceptIncommingConnection);
00055     void            stop();
00056 
00057 signals:
00058     void            connectionAccepted (UdpConnection *);
00059 
00060 protected:
00061     bool            openChannel (UdpConnection *udpConnection, const NodeAddress &nodeAddress);
00062     void            closeChannel (UdpConnection *udpConnection);
00063     bool            writeDatagram (UdpConnection *udpConnection, const char * data, qint64 maxSize);
00064 
00065 private slots:
00066     void            readyRead();
00067 
00068 private:
00069     UdpSwitchPrivate    *p;
00070 
00071     friend class UdpConnection;
00072 };
00073 
00074 } // namespace Transports
00075 } // namespace Protocols
00076 
00077 #endif // PROTOCOLS__TRANSPORTS__UDP_SWITCH_H
00078