Call it to close the connection. It returns immediately
| 271 | |
| 272 | // Call it to close the connection. It returns immediately |
| 273 | void DisconnectFromChatServer() { |
| 274 | if (!Socket_connected) |
| 275 | return; |
| 276 | SendChatString("/QUIT", 1); |
| 277 | shutdown(Chatsock, 2); |
| 278 | #ifdef WIN32 |
| 279 | closesocket(Chatsock); |
| 280 | #else |
| 281 | close(Chatsock); |
| 282 | #endif |
| 283 | Socket_connecting = 0; |
| 284 | Socket_connected = 0; |
| 285 | Input_chat_buffer[0] = '\0'; |
| 286 | if (User_list) { |
| 287 | DLLmem_free(User_list); |
| 288 | User_list = nullptr; |
| 289 | } |
| 290 | if (Chan_list) { |
| 291 | DLLmem_free(Chan_list); |
| 292 | Chan_list = nullptr; |
| 293 | } |
| 294 | |
| 295 | Chat_server_connected = 0; |
| 296 | Joining_channel = 0; |
| 297 | Joined_channel = 0; |
| 298 | RemoveAllChatUsers(); |
| 299 | FlushChatCommandQueue(); |
| 300 | FlushChannelList(); |
| 301 | } |
| 302 | |
| 303 | // returns NULL if no line is there to print, otherwise returns a string to |
| 304 | // print (all preformatted of course) |
no test coverage detected