예제 #1
0
파일: Login.xaml.cs 프로젝트: royb3/pong
        public MainWindow()
        {
            InitializeComponent();

            lob = new Lobby();

            #region Create Events

            btnLogin.Click += btnLogin_Click;

            tbName.Focus();

            #endregion

            #region debug check

            if (App.quickLogin)
            {
                tbName.Text = "Debug User";
                btnLogin_Click(null, null);
            }

            #endregion
        }
예제 #2
0
파일: Socket.cs 프로젝트: royb3/pong
        public Boolean StartConnection(string Ip)
        {
            Lobby lob = new Lobby();
            client = new Client(Ip);
            // maak de on receive handlers
            client.On("send_broadcast", (data) =>
            {
                MessageBox.Show(data.ToString());
            });

            #region add, del and get room

            client.On("delplayer", (data) =>
            {
                recentPlayerOffline = data.Json.Args[1];
                RecentMessage = recentPlayerOffline + " went offline.";
                playerlist = new List<string>();
                for (int i = 0; i < data.Json.Args[0].Count; i++)
                {
                    string tmp = data.Json.Args[0][i];
                    playerlist.Add(tmp);
                }
            });

            #endregion

            #region lobby message
            client.On("newlobbymessage", (data) =>
                {
                    string tmpFrom = data.Json.Args[0];
                    string tmpMessage = data.Json.Args[1];
                    Lobby.LobbyMessage = tmpFrom + " - " + tmpMessage;
                });

            #endregion

            #region add, del and get player

            client.On("playerlist", (data) =>
                {
                    playerListIsBuild = false;
                    playerlist = new List<string>();
                    for (int i = 0; i < data.Json.Args[0].Count; i++)
                    {
                        string tmp = data.Json.Args[0][i];
                        playerlist.Add(tmp);
                    }
                    if (playerlist.Count == 0)
                    {
                        playerlist.Add("a");
                    }
                    playerListIsBuild = true;
                });

            client.On("delplayer", (data) =>
                {
                    recentPlayerOffline = data.Json.Args[1];
                    RecentMessage = recentPlayerOffline + " went offline.";
                    playerlist = new List<string>();
                    for (int i = 0; i < data.Json.Args[0].Count; i++)
                    {
                        string tmp = data.Json.Args[0][i];
                        playerlist.Add(tmp);
                    }
                });

            client.On("addplayer", (data) =>
                {
                    recentPlayerOnline = data.Json.Args[1];
                    RecentMessage = recentPlayerOnline + " is online.";
                    playerlist = new List<string>();
                    for (int i = 0; i < data.Json.Args[0].Count; i++)
                    {
                        string tmp = data.Json.Args[0][i];
                        playerlist.Add(tmp);
                    }
                });
            #endregion
            //start de connectie
            client.Connect();

            for (int i = 0; i < 100; i++)
            {
                if (client.IsConnected)
                    return true;
                Thread.Sleep(10);
            }
            return false;
        }
예제 #3
0
파일: GameRoom.xaml.cs 프로젝트: royb3/pong
 void GameRoom_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     Lobby lob = new Lobby();
     lob.Show();
 }
예제 #4
0
파일: GameRoom.xaml.cs 프로젝트: royb3/pong
        void GameRoom_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Lobby lob = new Lobby();

            lob.Show();
        }