sources/network/rconsession.cpp

changeset 57
a2f41245e387
parent 47
35b968619b0c
child 58
d175243ad169
equal deleted inserted replaced
56:b4caacf567af 57:a2f41245e387
6 // ------------------------------------------------------------------------------------------------- 6 // -------------------------------------------------------------------------------------------------
7 // 7 //
8 RCONSession::RCONSession() : 8 RCONSession::RCONSession() :
9 m_state (RCON_DISCONNECTED), 9 m_state (RCON_DISCONNECTED),
10 m_lastPing (0), 10 m_lastPing (0),
11 m_numAdmins (0) 11 m_numAdmins (0) {}
12
13 // -------------------------------------------------------------------------------------------------
14 //
15 STATIC METHOD
16 RCONSession::new_session() -> RCONSession*
12 { 17 {
13 if (g_rconSession != NULL) 18 if (g_rconSession != NULL)
14 { 19 {
15 g_rconSession->disconnect(); 20 g_rconSession->disconnect();
16 delete g_rconSession; 21 delete g_rconSession;
17 } 22 }
18 23
19 g_rconSession = this; 24 g_rconSession = new RCONSession;
20 } 25
21 26 if (not g_rconSession->socket()->set_blocking (false))
22 // -------------------------------------------------------------------------------------------------
23 //
24 STATIC METHOD
25 RCONSession::new_session() -> RCONSession*
26 {
27 RCONSession* session = new RCONSession;
28
29 if (not session->socket()->set_blocking (false))
30 { 27 {
31 print ("unable to set socket as non-blocking: %s\n", 28 print ("unable to set socket as non-blocking: %s\n",
32 session->socket()->error_string().chars()); 29 g_rconSession->socket()->error_string().chars());
33 delete session; 30 delete g_rconSession;
34 return nullptr; 31 return nullptr;
35 } 32 }
36 33
37 return session; 34 return g_rconSession;
38 } 35 }
39 36
40 // ------------------------------------------------------------------------------------------------- 37 // -------------------------------------------------------------------------------------------------
41 // 38 //
42 RCONSession::~RCONSession() 39 RCONSession::~RCONSession()
53 RCONSession::connect (IPAddress address) -> void 50 RCONSession::connect (IPAddress address) -> void
54 { 51 {
55 m_address = address; 52 m_address = address;
56 m_state = RCON_CONNECTING; 53 m_state = RCON_CONNECTING;
57 Interface::update_statusbar(); 54 Interface::update_statusbar();
55 send_hello();
58 } 56 }
59 57
60 // ------------------------------------------------------------------------------------------------- 58 // -------------------------------------------------------------------------------------------------
61 // 59 //
62 METHOD 60 METHOD

mercurial