|
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
|
}
bool LoginScreen::validateURL(QString& url)
{
}
bool LoginScreen::connect(Socket& s)
{
QString host, nick;
string response;
int port;
parseURL(host,port,ui->serverURLEdit->text());
nick = ui->nickEdit->text();
try
{
s.Create();
s.Connect(host.toStdString(),port);
s << nick.toStdString();
s >> response;
if(response == "CHATNICKINVALID")
{
cout << "Spaces not allowed in nicknames, please enter another nickname: ";
}
else if(response == "CHATNICKEXIST")
{
cout << "Nickname in use, please enter another nickname: ";
}
else if(response == "CHATFULL")
{
cout << "Chatroom is full, please wait..." << endl;
}
else if(response != "CHATOK")
{
cout << "Error: " << response << endl;
}
else
{
return true;
}
s.Close();
return false;
}
catch(SocketException& e)
{
cout << e.description() << endl;
exit(-1);
}
|