Esempio n. 1
0
        private Dictionary<UserInfo, long> userTimeouts; // for removing expired users

        #endregion Fields

        #region Constructors

        public LobbyForm(Lobby lobby)
        {
            InitializeComponent();

            this.lobby = lobby;
            this.userGames = new Dictionary<UserInfo, ICollection<String>>();
            this.nicknameTextBox.Text = Options.nickname;
            this.currentUser = new UserInfo(Options.nickname);
            this.lobby.OnMessageReveived += lobby_OnMessageReveived;

            // GUI Config
            tabPageAll = new ChatTabPage("Broadcast");
            tabPageAll.Text = "All:";
            this.tabControlChat.TabPages.Add(tabPageAll);

            this.messageTextBox.KeyDown += new KeyEventHandler(delegate(object o, KeyEventArgs e) {
                if (e.KeyCode == Keys.Enter)
                {
                    sendMessageButton.PerformClick();
                }
            });

            this.gamesListBox.ContextMenu = new ContextMenu();
            this.gamesListBox.ContextMenu.MenuItems.Add(0, new MenuItem("Join Game Channel", delegate(object o, EventArgs e)
            {
                ChatTabPage t = joinChannel(this.gamesListBox.SelectedItem.ToString());
                t.Select();
            }));

            /******************************************************************************************
             * Check every second for expiring users
             *****************************************************************************************/
            /*
            this.expiringTimer = new Timer();
            this.expiringTimer.Interval = Options.EXPIRING_INTERVAL_CHECK;
            this.expiringTimer.Tick += delegate(object o, EventArgs e)
            {
                userTimeouts.
                foreach(KeyValuePair<UserInfo, long> k in userTimeouts)
                {
                    if (k.Value > CurrentMillis.Millis)
                    {
                        userTimeouts.
                    }
                }
            };
            this.expiringTimer.Start();
             */
        }
Esempio n. 2
0
        public SysTrayApp()
        {
            // create vhdpath directory, if it doesnt exist
            String localVhdBasePath = Path.Combine(Application.StartupPath, Options.vhdlocalpath);
            if (!Directory.Exists(localVhdBasePath))
            {
                Directory.CreateDirectory(localVhdBasePath);
            }
            gamesLibrary = new GamesLibrary(new VhdStorage(new DirectoryInfo(localVhdBasePath)));

            lobby = new Lobby();
            lobby.Listen();

            /******************************************************************************************
             * Announce Own Games every 10s
             *****************************************************************************************/
            this.announcingTimer = new Timer();
            this.announcingTimer.Interval = Options.ANNOUNCING_INTERVAL;
            this.announcingTimer.Tick += delegate(object o, EventArgs e) {
                lobby.Send(new AnnouncementMessage(new UserInfo(Options.nickname), gamesLibrary.GetGameNames()));
            };
            this.announcingTimer.Start();

            /******************************************************************************************
             * GUI Init
             *****************************************************************************************/
            trayIcon = new NotifyIcon();
            trayIcon.Text = "vhdgamer";
            trayIcon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

            // Add menu to tray icon and show it.
            trayMenu = new ContextMenu();
            trayMenu.Popup += delegate { updateContextMenu(); };

            trayIcon.ContextMenu = trayMenu;
            trayIcon.MouseClick += new MouseEventHandler(trayIcon_Click);
            trayIcon.Visible = true;

            updateContextMenu();

            // info for user (if click on tooltop -> show menu)
            trayIcon.ShowBalloonTip(1000, "vhdgamer", "Click here to start or download games...", ToolTipIcon.Info);
            trayIcon.BalloonTipClicked += delegate { trayIcon.GetType().InvokeMember("ShowContextMenu", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, trayIcon, null); };
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Lobby localLobby = new Lobby();
            localLobby.OnMessageReveived += delegate(object o, MessageEventArgs e) {
                Console.WriteLine("RX: " + ((ChatMessage)e.Message).Text);
            };
            localLobby.Listen();

            Thread.Sleep(2000);

            localLobby.Send(new ChatMessage("Hallo"));

            Thread.Sleep(2000);

            localLobby.StopListening();

            //Lobby externalLobby = new Lobby(54321, 12345);
            //externalLobby.OnMessageSent += delegate(object o, MessageEventArgs e) {
            //    Console.WriteLine("TX: " + ((ChatMessage)e.Message).Text);
            //};
            //externalLobby.Send(new ChatMessage("Hallo"));
        }