jamulus/src/socket.h

79 lines
2.6 KiB
C
Raw Normal View History

/******************************************************************************\
* Copyright (c) 2004-2006
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
2007-09-08 12:45:14 +02:00
#if !defined ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ )
#define SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_
#include <QObject.h>
#include <QMessageBox.h>
#include <QUdpSocket.h>
#include <QSocketNotifier.h>
#include <vector>
#include "global.h"
#include "channel.h"
#include "util.h"
/* Definitions ****************************************************************/
2007-09-08 12:45:14 +02:00
// maximum block size for network input buffer. Consider two bytes per sample
#define MAX_SIZE_BYTES_NETW_BUF ( MAX_NET_BLOCK_SIZE_FACTOR * MIN_BLOCK_SIZE_SAMPLES * 2 )
/* Classes ********************************************************************/
class CSocket : public QObject
{
Q_OBJECT
public:
CSocket(CChannel* pNewChannel) : pChannel(pNewChannel), bIsClient(true)
{ Init(); }
2007-03-05 22:52:39 +01:00
CSocket(CChannelSet* pNewChannelSet, QObject* pNServP) :
pChannelSet(pNewChannelSet), pServer ( pNServP ), bIsClient(false)
{ Init(); }
virtual ~CSocket() {}
void SendPacket ( const CVector<unsigned char>& vecbySendBuf,
const CHostAddress& HostAddr );
protected:
void Init();
QUdpSocket SocketDevice;
CVector<unsigned char> vecbyRecBuf;
CHostAddress RecHostAddr;
2007-09-08 12:45:14 +02:00
CChannel* pChannel; // for client
CChannelSet* pChannelSet; // for server
2006-02-26 11:50:47 +01:00
QObject* pServer;
bool bIsClient;
public slots:
void OnDataReceived();
};
2007-09-08 12:45:14 +02:00
#endif /* !defined ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */