sources/network/rconsession.cpp

changeset 24
e651d02802c0
parent 23
f7221183a994
child 25
88b41eea08e0
equal deleted inserted replaced
23:f7221183a994 24:e651d02802c0
14 g_rconSession->disconnect(); 14 g_rconSession->disconnect();
15 delete g_rconSession; 15 delete g_rconSession;
16 } 16 }
17 17
18 g_rconSession = this; 18 g_rconSession = this;
19 19 }
20 if (not m_socket.set_blocking (false)) 20
21 { 21 // -------------------------------------------------------------------------------------------------
22 // TODO: find a better way to deal with errors 22 //
23 STATIC METHOD
24 RCONSession::new_session() -> RCONSession*
25 {
26 RCONSession* session = new RCONSession;
27
28 if (not session->socket()->set_blocking (false))
29 {
23 print ("unable to set socket as non-blocking: %s\n", 30 print ("unable to set socket as non-blocking: %s\n",
24 m_socket.error_string().chars()); 31 session->socket()->error_string().chars());
25 } 32 delete session;
33 return nullptr;
34 }
35
36 return session;
26 } 37 }
27 38
28 // ------------------------------------------------------------------------------------------------- 39 // -------------------------------------------------------------------------------------------------
29 // 40 //
30 RCONSession::~RCONSession() 41 RCONSession::~RCONSession()
273 packet.write_string (message); 284 packet.write_string (message);
274 send (packet); 285 send (packet);
275 bump_last_ping(); 286 bump_last_ping();
276 return true; 287 return true;
277 } 288 }
289
290 // -------------------------------------------------------------------------------------------------
291 //
292 METHOD
293 RCONSession::state() const -> RCONSessionState
294 {
295 return m_state;
296 }

mercurial