add client to app
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
int sock = TcpSocket::connectt("localhost", 8888);
|
||||
int sock = TcpSocket::connectt("petrovv.com", 8888);
|
||||
|
||||
if (sock < 0)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ int main()
|
||||
TcpSocket::sendt(sock, &message, sizeof(Message));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
std::ifstream sfile(filename, std::ios_base::binary | std::ios_base::in);
|
||||
|
||||
std::vector<NetUnit> net;
|
||||
|
@@ -13,8 +13,8 @@
|
||||
// When a new client connected:
|
||||
void call(int sock, sockaddr_in newSocketInfo)
|
||||
{
|
||||
printf("new User");
|
||||
|
||||
std::string add = TcpSocket::remoteAddress(newSocketInfo);
|
||||
printf("new: %s\n", add.c_str());
|
||||
int64_t conf, id;
|
||||
Message message;
|
||||
|
||||
@@ -23,6 +23,7 @@ void call(int sock, sockaddr_in newSocketInfo)
|
||||
|
||||
if (conf != StartHeader)
|
||||
{
|
||||
printf("StartHeader ERROR\n");
|
||||
TcpSocket::closet(sock);
|
||||
return;
|
||||
}
|
||||
@@ -51,14 +52,13 @@ void call(int sock, sockaddr_in newSocketInfo)
|
||||
while (sqlite3_step(stmt) != SQLITE_DONE)
|
||||
{
|
||||
int num_cols = sqlite3_column_count(stmt);
|
||||
|
||||
|
||||
int type = sqlite3_column_type(stmt, 0);
|
||||
|
||||
if(type == SQLITE_NULL) break;
|
||||
|
||||
if (type == SQLITE_NULL)
|
||||
break;
|
||||
gen = sqlite3_column_int64(stmt, 0);
|
||||
gen++;
|
||||
|
||||
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
@@ -80,8 +80,9 @@ void call(int sock, sockaddr_in newSocketInfo)
|
||||
list.resize(NUM_PER_GEN);
|
||||
|
||||
TcpSocket::recvt(sock, list.data(), NUM_PER_GEN * sizeof(NetUnit));
|
||||
|
||||
for(size_t i = 0; i < list.size(); i++){
|
||||
|
||||
for (size_t i = 0; i < list.size(); i++)
|
||||
{
|
||||
sqlite3_bind_int64(stmt, 1, id);
|
||||
sqlite3_bind_int64(stmt, 2, gen);
|
||||
sqlite3_bind_int64(stmt, 3, list[i].hash);
|
||||
@@ -97,7 +98,7 @@ void call(int sock, sockaddr_in newSocketInfo)
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
printf("del USER");
|
||||
printf("del\n");
|
||||
TcpSocket::closet(sock);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user