-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsconvoclientconnection.h
47 lines (37 loc) · 1.09 KB
/
dsconvoclientconnection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef DSCONVOCLIENTCONNECTION_H
#define DSCONVOCLIENTCONNECTION_H
#include "dsconvoconnection.h"
#include <QObject>
class DSConvoClientConnection : public DSConvoConnection
{
Q_OBJECT
public:
enum State {
Ungreeted,
Greeting,
Greeted,
};
enum Error {
BadUsername,
RepeatedUsername,
ServerLoad,
};
explicit DSConvoClientConnection(QTcpSocket *socket, QObject *parent = nullptr);
inline State state() const { return state_; }
inline const QString &username() const { return username_; }
void sendHello(const QString &username);
void sendMessage(const QString &message);
void sendGoodbye();
signals:
void greeted();
void messaged(const DSConvo::Protocol::MessageBroadcast &m);
void errorOccurred(DSConvoClientConnection::Error);
private:
void handleHelloReply(const google::protobuf::Message*);
void handleMessageBroadcast(const google::protobuf::Message*);
State state_;
QString username_;
protected slots:
void streamMessageParsed(DSConvoStream::ParsedMessage&) override;
};
#endif