-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.cpp
More file actions
127 lines (99 loc) · 2.04 KB
/
client.cpp
File metadata and controls
127 lines (99 loc) · 2.04 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "clientUtils.h"
#pragma comment(lib, "ws2_32.lib")
int log_Stat = 0;
studentPortal loggedStud;
using namespace std;
void main()
{
// Initialize WinSock
WSAData data;
WORD ver = MAKEWORD(2, 2);
int wsResult = WSAStartup(ver, &data);
if (wsResult != 0)
{
cerr << "Can't start Winsock, Err #" << wsResult << endl;
return;
}
SOCKET sock = connectToServer(ipaddress, 54000);
char buf[4096];
char userInput[500];
char control;
info siuuu;
introScreen2(userInput , log_Stat , &loggedStud);
do
{
// Send the text
int sendResult = send(sock, userInput, sizeof(userInput) + 1, 0);
if (!strncmp(userInput, "faculty", 7))
{
if (sendResult != SOCKET_ERROR)
{
// Wait for response
//std::cout << ">>>>> " << log_Stat<<endl;
faculties(sock);
}
}
else if (!strncmp(userInput, "searchfaculty", 13))
{
if (sendResult != SOCKET_ERROR)
{
searchFaculties_client(sock);
}
}
//Newly Implemented addition
else if (!strncmp(userInput, "help", 4))
{
if (sendResult != SOCKET_ERROR)
{
services(sock);
}
}
//Newly Implemented addition
else if (!strncmp(userInput, "Portal", 6))
{
if (sendResult != SOCKET_ERROR)
{
fflush(stdin);
Portal(sock , &loggedStud, &log_Stat);
}
}
else if (!strncmp(userInput, "login", 6))
{
if (sendResult != SOCKET_ERROR)
{
fflush(stdin);
login_client(sock , &log_Stat , &loggedStud);
}
}
else if (!strncmp(userInput, "cafe", 4))
{
if (sendResult != SOCKET_ERROR)
{
fflush(stdin);
TicketPrint(sock , &loggedStud);
}
}
else if (!strncmp(userInput, "admission", 9))
{
if (sendResult != SOCKET_ERROR)
{
fflush(stdin);
admission(sock);
}
}
else if (!strncmp(userInput, "chat", 4))
{
if (sendResult != SOCKET_ERROR)
{
fflush(stdin);
chat(sock);
}
}
printf("\n\n\n\nPress enter to go back : ");
getchar();
introScreen2(userInput, log_Stat, &loggedStud);
} while (true);
// Gracefully close down everything
closesocket(sock);
WSACleanup();
}