示例#1
1
        public ClientGUI(string ip, string name)
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle;

            panelGame1 = new Panel();
            this.name = name;
            this.ip = ip;
            this.broadcast = "BROADCAST";
            this.Text = name;

            tabController.TabPages.Add(broadcast);
            tabController.TabPages[0].Name = broadcast;
            tabController.TabPages[0].Controls.Add(new ChatPanel());

            Comm = new Communication(ip, name);

            openGames = new Dictionary<string, string>();

            Comm.IncommingMessageHandler += Comm_IncommingMessageHandler;

            buttonRpsls.Text = "Rock - Paper - Scissors -" + Environment.NewLine +"Lizard - Spock";

            this.BackColor = Color.Gray;

            buttonConnect4.Enabled = false;
            buttonRpsls.Enabled = false;
        }
        /// <summary>
        /// Closes the current session if it exists and creates a new.
        /// </summary>
        public static void CreateNewInstance()
        {
            Contract.Ensures(!ReferenceEquals(Instance, null));
            Contract.Ensures(!Instance.HasToken);
            Contract.Ensures(Instance.StockGroups.Count == 0);
            Contract.Ensures(Instance.TotalFunds == 0);
            Contract.Ensures(Instance.Username.Equals(""));

            if (_instance != null && _instance.HasToken)
            {
                _instance.CloseConnection();
            }

            _instance = new Communication();
        }
示例#3
0
 /// <summary>
 /// Sends the client update to the server.
 /// </summary>
 /// <returns>Task representing sent update.</returns>
 public async Task SendClientUpdateAsync(ClientUpdate update)
 {
     LastSentClientUpdateID = update.ID;
     await Communication.UDPSendMessageAsync(updatesToServer, serverUpdateAddress, ClientUpdate.Encode(update));
 }