defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010-2011 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 namespace Network { 00012 class RemoteSock; 00013 } 00014 00015 #ifndef REMOTESOCK_HPP 00016 #define REMOTESOCK_HPP 00017 00018 #include <QObject> 00019 #include <QTcpSocket> 00020 #include "remoteevent.hpp" 00021 #include "parser.hpp" 00022 00023 namespace Network 00024 { 00030 class RemoteSock : public QObject 00031 { 00032 friend class Doorman; 00033 friend class RemoteEvent; 00034 00035 Q_OBJECT 00036 public: 00037 RemoteSock(QTcpSocket *sock); 00038 ~RemoteSock(); 00039 QString ip() const; 00040 int port() const; 00041 RemoteEvent& newEvent(const QString& name); 00042 void sendEvent(RemoteEvent *event); 00043 const Parser& eventParser() const; 00044 const QString& getToken() const; 00045 const QString& getDevice() const; 00046 const QString& getVersion() const; 00047 00048 signals: 00049 void receiveEvent(const RemoteEvent&); 00050 00051 public slots: 00052 void receive(); 00053 00054 private: 00055 QTcpSocket *sock; 00056 QString token, device, version; 00057 QByteArray buffer; 00058 unsigned nextEventId; 00059 QMap<unsigned, RemoteEvent*> events; 00060 }; 00061 } 00062 00063 #endif // REMOTESOCK_HPP