-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.h
41 lines (38 loc) · 1.28 KB
/
client.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
#ifndef CLIENT_H
#define CLIENT_H
#include <QObject>
#include <QTcpSocket>
#include <QUrl>
#include <QDebug>
class Client : public QObject
{
Q_OBJECT
public:
explicit Client(QObject *parent = nullptr);
~Client();
public:
void waitForConnection(); //等待连接到服务器
void writeToServer(QString msg, QString type); //发送消息给服务器,带有消息类型
void connectToLocalServer(int port); //连接到本地服务器
void disconnect(); //断开连接
QString getPeerIpAddress() const; //获取服务端的IP地址
signals:
void newChatMsg(QString msg);
void remotePlay(qint64 position);
void remotePause(qint64 position);
void remoteStop();
void remoteSeek(qint64 position);
void remoteSync(qint64 position); //远程视频同步
void remoteSetVideoSource(QString src); //非服务端客户端设置播放源
void remoteSetLocalVideoSource(QString src); //服务端客户端使用
void userConnected(QString usrName); //判断哪一个客户端连接到服务端
void userDisconnected(QString usrName);
public slots:
void setUdpPort(quint16 udpPort);
void connectToServer(QUrl url, int port);
private slots:
void readFromServer();
private:
QTcpSocket *socket = nullptr;
};
#endif // CLIENT_H