-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsconvoserverconnection.h
46 lines (35 loc) · 1.24 KB
/
dsconvoserverconnection.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
#ifndef DSCONVOSERVERCONNECTION_H
#define DSCONVOSERVERCONNECTION_H
#include "dsconvoconnection.h"
#include <QObject>
#include <functional>
class DSConvoServerConnection : public DSConvoConnection
{
Q_OBJECT
public:
using HelloReplyError = DSConvoProtocol::HelloReplyPayload::HelloReplyError;
enum State {
Ungreeted,
Greeted,
};
explicit DSConvoServerConnection(QTcpSocket *socket, QObject *parent = nullptr);
inline State state() const { return state_; }
inline const QString &username() const { return username_; }
void sendMessageBroadcast(const DSConvo::Protocol::MessageBroadcast &m);
signals:
void helloRequested(QString &u, DSConvoServerConnection::HelloReplyError *r);
void helloAccepted();
void messageAccepted(const QString &m);
void farewellSent();
private:
void handleHelloRequest(const google::protobuf::Message*);
void handleMessageRequest(const google::protobuf::Message*);
void handleGoodbye();
void sendHelloReply(DSConvoProtocol::HelloReplyPayload::HelloReplyError result,
const QString &username);
State state_;
QString username_;
protected slots:
void streamMessageParsed(DSConvoStream::ParsedMessage&) override;
};
#endif