コード例 #1
0
ファイル: Button.cpp プロジェクト: kverhun/tic-tac-toe
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;
	}
}
コード例 #2
0
ファイル: ClientApp.cpp プロジェクト: kverhun/tic-tac-toe
void ClientApp::Run()
{
	Window* mw = Window::GetInstance();
	try
	{
		mw -> Initialize();
	}
	catch (...)
	{
		ServerCommand cmd = ServerCommand();
		cmd.SetType(SSetTextWrong);
		mw -> CommandHandle(cmd);
	}
}