void ConnectAsFirstBtn::EventHandle (Event e, Info I) { Client* client = Client::GetInstance(); switch (e) { case MouseClick: if (client -> isConnected()) return; if (!client -> isConnected()) { try { client -> Connect(SinglePlayer); } catch (ENoServerAvailable* e) { Window* window = Window::GetInstance(); ServerCommand cmd = ServerCommand(); cmd.SetType(SSetTextNoServerAvailable); window -> CommandHandle(cmd); } catch (EConnectionFailed* e) { Window* window = Window::GetInstance(); ServerCommand cmd = ServerCommand(); cmd.SetType(SSetTextConnectionError); window -> CommandHandle(cmd); } catch(IException* e) { Window* window = Window::GetInstance(); ServerCommand cmd = ServerCommand(); cmd.SetType(SSetTextWrong); window -> CommandHandle(cmd); } } break; case MouseOn: this -> _isActive = true; this -> Draw(); break; case MouseOut: this -> _isActive = false; this -> Draw(); break; } }
void ClientApp::Run() { Window* mw = Window::GetInstance(); try { mw -> Initialize(); } catch (...) { ServerCommand cmd = ServerCommand(); cmd.SetType(SSetTextWrong); mw -> CommandHandle(cmd); } }