Beispiel #1
0
        private void txtIO_TextChanged(object sender, EventArgs e)
        {
            if (!this.textChangingFromNetwork && this.textBoxMap[(TextBox)sender] == this.lastKnownIdOfThisPeer)
            {
                /// Get an interface for sending the message
                ILobby sendIface = null;
                if (this.joinedLobby != null && this.createdLobby == null)
                {
                    sendIface = this.joinedLobby;
                }
                else if (this.joinedLobby == null && this.createdLobby != null)
                {
                    sendIface = this.createdLobby;
                }

                if (sendIface != null)
                {
                    /// Create the package
                    RCPackage package = RCPackage.CreateNetworkCustomPackage(MY_FORMAT);
                    package.WriteString(0, ((TextBox)sender).Text);

                    /// Get the targets of the package
                    List <int> targets = new List <int>();
                    for (int i = 0; i < this.lastKnownLineStates.Length; i++)
                    {
                        if (i != this.lastKnownIdOfThisPeer && this.targetSelectors[i].Checked)
                        {
                            targets.Add(i);
                        }
                    }
                    if (targets.Count != 0)
                    {
                        /// Send a dedicated message.
                        sendIface.SendPackage(package, targets.ToArray());
                    }
                    else
                    {
                        /// Send the message to the whole lobby.
                        sendIface.SendPackage(package);
                    }
                }
            }
        }