void cleanup( struct client_payload *payload, struct client_protocol *protocol, struct client_client *client, config_info *ci ) { if (payload) { for (int cnt=0;cnt<ci->getNumClients();cnt++) { if (payload[cnt].pld && payload[cnt].handle) { payload[cnt].pld->DestroyPayload( payload[cnt].handle ); payload[cnt].handle=NULL; } } if (payload[0].pld) { delete payload[0].pld; payload[0].pld=NULL; } delete []payload; payload=NULL; } if (protocol) { for (int cnt=0;cnt<ci->getNumClients();cnt++) { if (protocol[cnt].connection && protocol[cnt].proto_handle && protocol[cnt].proto) { protocol[cnt].proto->DestroyConnection( protocol[cnt].proto_handle, protocol[cnt].connection ,0 ); protocol[cnt].connection=NULL; } } if (protocol[0].proto_handle && protocol[0].proto) { protocol[0].proto->DestroyProtocol( protocol[0].proto_handle, 0 ); protocol[0].proto_handle=NULL; } if (protocol[0].proto) { delete protocol[0].proto; } delete []protocol; protocol=NULL; } if (client) { if (client->clnt && client->handle) { client->clnt->DestroyClient( client->handle ); client->handle=NULL; } if (client->clnt) { delete client->clnt; client->clnt=NULL; } } ShutdownNetwork(); }
void TTrafficServerForm::cleanup( struct server_server *ss, struct server_reply *sr, struct client_protocol *sp ) { if (ss) { if (ss->handle && ss->serv) ss->serv->DestroyServer( ss->handle ); if (ss->serv) delete ss->serv; delete ss; ss=NULL; } if (sr) { /* if (sr->handle && sr->rep) { sr->rep->DestroyReply( sr->handle ); } */ if (sr->rep) { delete sr->rep; } delete sr; sr=NULL; } if (sp) { for (int cnt=0; cnt<ProtocolsListBox->Items->Count; cnt++) { struct client_protocol *tmp; tmp=&(sp[cnt]); if (tmp->proto && tmp->proto_handle && tmp->connection) { for (int cnt2=cnt+1; cnt2<ProtocolsListBox->Items->Count; cnt2++) { if (tmp->proto_handle==sp[cnt2].proto_handle && sp[cnt2].proto_handle && sp[cnt2].connection) { sp[cnt2].proto->DestroyConnection( sp[cnt2].proto_handle, sp [cnt2].connection, 0 ); sp[cnt2].proto_handle=NULL; sp[cnt2].connection=NULL; } } tmp->proto->DestroyProtocol( tmp->proto_handle, 0 ); delete tmp->proto; tmp->proto=NULL; tmp->proto_handle=NULL; } } delete []sp; sp=NULL; } ShutdownNetwork(); }
int main(int nargs, const char *args[]) { InitializeNetwork(); GameServer GS; GS.startServer("wozzy"); int nPlayers = GS.getNumberOfPlayers(); while(true) { if(nPlayers != GS.getNumberOfPlayers()) { nPlayers = GS.getNumberOfPlayers(); cout << "nPlayers = " << nPlayers << endl; } } ShutdownNetwork(); return 0; }