private void btnChat_Click(object sender, EventArgs e)
 {
     if (txtChatEntry.Text.Length > 0)
     {
         server.OnGlobalChatEvent("Admin", txtChatEntry.Text);
     }
     txtChatEntry.Text = "";
 }
Esempio n. 2
0
        private bool tunnel_OnMessageReceivedEvent(string msg)
        {
            if (msg.StartsWith("chat:"))
            {
                lobby.OnGlobalChatEvent(name, msg.Substring("chat:".Length));
                return(true);
            }
            else if (msg.StartsWith("join:"))
            {
                int    gameID    = -1;
                string gameIDStr = msg.Substring("join:".Length);
                if (int.TryParse(gameIDStr, out gameID))
                {
                    string ticket = lobby.OnJoinGameRequestEvent(this, gameID);
                    if (string.IsNullOrEmpty(ticket))
                    {
                        this.tunnel.SendMessage("ticket:invalid");
                    }
                    else
                    {
                        this.tunnel.SendMessage("ticket:" + ticket);
                    }
                }
                else
                {
                    Logger.Log(LogType.Error, name + " tried to join with non-integer gameID");

                    this.tunnel.SendMessage("ticket:invalid");
                }

                return(true);
            }
            else if (msg == "quit")
            {
                Logger.Log(LogType.Event, name + " has quit");

                Quit();

                return(true);
            }
            else if (msg == "reqgames")
            {
                Logger.Log(LogType.Debug, name + " requested game list");
                lobby.OnRequestGameListEvent(this);

                return(true);
            }
            else if (msg == "reqbank")
            {
                Logger.Log(LogType.Debug, name + " requested bank amount");

                tunnel.SendMessage("bank:" + this.bank.ToString("0"));

                return(true);
            }

            return(false);
        }