chatserver.h Example File
btchat/chatserver.h
#ifndef CHATSERVER_H
#define CHATSERVER_H
#include <qbluetoothserviceinfo.h>
#include <qbluetoothaddress.h>
#include <QtCore/QObject>
#include <QtCore/QList>
QT_FORWARD_DECLARE_CLASS(QBluetoothServer)
QT_FORWARD_DECLARE_CLASS(QBluetoothSocket)
QT_USE_NAMESPACE
class ChatServer : public QObject
{
Q_OBJECT
public:
explicit ChatServer(QObject *parent = 0);
~ChatServer();
void startServer(const QBluetoothAddress &localAdapter = QBluetoothAddress());
void stopServer();
public slots:
void sendMessage(const QString &message);
signals:
void messageReceived(const QString &sender, const QString &message);
void clientConnected(const QString &name);
void clientDisconnected(const QString &name);
private slots:
void clientConnected();
void clientDisconnected();
void readSocket();
private:
QBluetoothServer *rfcommServer;
QBluetoothServiceInfo serviceInfo;
QList<QBluetoothSocket *> clientSockets;
};
#endif // CHATSERVER_H