/* * ,, ,, * `7MM"""YMM mm `7MMF' `7MMF' `7MM `7MM * MM `7 MM MM MM MM MM * MM d `7M' `MF'.gP"Ya `7MMpMMMb.mmMMmm MM MM ,6"Yb. `7MMpMMMb. ,M""bMM MM .gP"Ya `7Mb,od8 ,pP"Ybd * MMmmMM VA ,V ,M' Yb MM MM MM MMmmmmmmMM 8) MM MM MM ,AP MM MM ,M' Yb MM' "' 8I `" * MM Y , VA ,V 8M"""""" MM MM MM MM MM ,pm9MM MM MM 8MI MM MM 8M"""""" MM `YMMMa. * MM ,M VVV YM. , MM MM MM MM MM 8M MM MM MM `Mb MM MM YM. , MM L. I8 * .JMMmmmmMMM W `Mbmmd'.JMML JMML.`Mbmo .JMML. .JMML.`Moo9^Yo.JMML JMML.`Wbmd"MML.JMML.`Mbmmd'.JMML. M9mmmP' */ /// <summary> /// Button event handler to send a request for the user to join the game /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_join_Click(object sender, EventArgs e) { try { // Create the channel DuplexChannelFactory <IWheel> channel = new DuplexChannelFactory <IWheel>(this, "WheelService"); wheel = channel.CreateChannel(); // if the user is added update ui if (wheel.AddPlayer(textBox_UserName.Text, out user)) { players = wheel.GetAllPlayers().ToList(); UpdatePlayers(); button_join.Enabled = false; } // otherwise show an error message else { if (wheel.GetAllPlayers().Length == MAX_PLAYERS) { MessageBox.Show(@"ERROR: No room for any additional players"); } else if (wheel.GameStarted()) { MessageBox.Show(@"ERROR: Game in progress. Please try again later."); } else { MessageBox.Show(@"ERROR: Alias in use. Please try again."); } // Alias rejected by the service so nullify service proxies wheel = null; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }