forked from dparker2/StudyGroup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
70 lines (57 loc) · 1.98 KB
/
server.cpp
File metadata and controls
70 lines (57 loc) · 1.98 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
#include "server.h"
#include <QDebug>
server::server(QObject *parent) : QObject(parent)
{
my_socket = new QTcpSocket(this);
connect(my_socket, SIGNAL(connected()), this, SLOT(socket_connected()));
connect(my_socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead()));
connect(my_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
//my_socket->connectToHost("18.221.67.202", 9001); // CSCI 150 SERVER
//my_socket->connectToHost("localhost", 24680);
//my_socket->connectToHost("52.53.198.189", 24680); // David's AWS server
}
/***
* Public
* Functions
* API
*/
/***
* bool verifyUserInfo(QString& username, QString& password)
* returns true if found
* false if not
*/
bool server::verifyUserInfo(QString& username, QString& password)
{
my_socket->connectToHost("18.221.67.202", 9001); // CSCI 150 SERVER
if (my_socket->waitForConnected(5000)) {
qDebug() << "Connected.";
} else {
qDebug() << "Not connected.";
}
// Socket connected at this point, pass through info
my_socket->write(QString("0"+username+" "+password+"\n").toLocal8Bit());
return true; // Always return true for now
}
bool server::createAccount(QString& email, QString& username, QString& password)
{
my_socket->connectToHost("18.221.67.202", 9001); // CSCI 150 SERVER
if (my_socket->waitForConnected(5000)) {
qDebug() << "Connected.";
} else {
qDebug() << "Not connected.";
}
// Socket connected at this point, pass through info
my_socket->write(QString("1"+email+" "+username+" "+password+"\n").toLocal8Bit());
return true; // Always return true for now
}
void server::socket_connected()
{
qDebug() << "Connected!";
}
void server::socket_readyRead() {
qDebug() << my_socket->readAll();
}
void server::error(QAbstractSocket::SocketError err)
{
qDebug() << my_socket->errorString();
}