-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmysocket.cpp
More file actions
96 lines (81 loc) · 1.74 KB
/
mysocket.cpp
File metadata and controls
96 lines (81 loc) · 1.74 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<<<<<<< 61ddbc132891cf9533228634c5d59b0c5d30fb7b
#include "mysocket.h"
MySocket::MySocket(QString _name, QString _money,QObject *parent)
: QThread(parent)
{
//初始化
onlineCount = 0;
socket = new QTcpSocket();
socket->connectToHost("127.0.0.1",22656);
connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
this->name = _name;
this->money = _money;
requestPeople();
}
MySocket::~MySocket()
{
}
void MySocket::requestPeople()
{
QByteArray data;
data.append(this->name);
data.append('-');
data.append(this->money);
socket->write(data);
}
void MySocket::readyRead()
{
QByteArray data=socket->readAll();
emit dealReply(data);
}
void MySocket::PK(QString name)
{
QByteArray people;
people.append(name);
socket->write(people);
}
=======
#include "mysocket.h"
MySocket::MySocket(QString _name, QString _money,QObject *parent)
: QThread(parent)
{
//初始化
onlineCount = 0;
socket = new QTcpSocket();
socket->connectToHost("115.159.48.101",22656);
connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
this->name = _name;
this->money = _money;
requestPeople();
}
MySocket::~MySocket()
{
}
void MySocket::requestPeople()
{
QByteArray data;
data.append(this->name);
data.append('-');
data.append(this->money);
socket->write(data);
}
void MySocket::readyRead()
{
QByteArray data=socket->readAll();
emit dealReply(data);
}
void MySocket::PK(QString name)
{
QByteArray people;
people.append(name);
socket->write(people);
}
void MySocket::beginPK(QString pkname, QString id)
{
QByteArray data;
data.append(pkname);
data.append('/');
data.append(id);
socket->write(data);
}
>>>>>>> final version