Ejemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            /*
             * try
             * {
             *  client = new HuyaLiveClient(this);
             *  //client.SetMobileMode(false);
             *  client.SetLogger(logger);
             *  // Shen tu
             *  client.Start("666007");
             *  // Yang qi huang
             *  //client.Start("18001");
             *  // Uzi
             *  //client.Start("666888");
             *  // Da sheng gui lai
             *  //client.Start("931827");
             *  // Shen mi gou
             *  //client.Start("399910");
             *  // Qiqi
             *  //client.Start("11807215");
             * }
             * catch (Exception ex)
             * {
             *  logger?.WriteLine("Exception: " + ex.ToString());
             *  logger?.WriteLine("");
             * }
             * //*/

            try
            {
                client = new HuyaLiveClient(this);
                client.SetMobileMode(false);
                client.SetLogger(logger);

                isActived = true;

                cbBoxRoomId.Items.Clear();

                int        infoLength = roomIdInfos.Length;
                ListItem[] listItems  = new ListItem[infoLength];
                for (int i = 0; i < infoLength; i++)
                {
                    RoomIdInfo info = roomIdInfos[i];
                    listItems[i] = new ListItem(info.roomId, info.roomIntro);
                    cbBoxRoomId.Items.Add(listItems[i]);
                }

                cbBoxRoomId.SelectedIndex = 0;
                cbBoxRoomId.SelectedItem  = listItems[0];
            }
            catch (Exception ex)
            {
                logger?.WriteLine("Exception: " + ex.ToString());
                logger?.WriteLine("");
            }
        }
Ejemplo n.º 2
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (client != null)
            {
                if (client.IsRunning())
                {
                    client.Stop();
                }

                client.Dispose();
                client.SetLogger(null);
                client.SetListener(null);
                client = null;
            }
        }
Ejemplo n.º 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (client == null)
                {
                    client = new HuyaLiveClient(this);
                    //client.SetMobileMode(false);
                    client.SetLogger(logger);
                }

                if (client != null)
                {
                    string roomId = txtBoxRoomId.Text;
                    roomId.Trim();

                    if (roomId == "")
                    {
                        MessageBox.Show("房间号不能为空!", "HuyaHelper");
                        return;
                    }

                    if (roomId == curRoomId && roomId != "")
                    {
                        // Current roomId is not change, directly return.
                        return;
                    }

                    if (client.IsRunning())
                    {
                        client.Stop();
                    }

                    ClearChatContent();

                    client.Start(roomId);

                    // Record connected roomId.
                    curRoomId = roomId;
                }
            }
            catch (Exception ex)
            {
                logger?.WriteLine("Exception: " + ex.ToString());
                logger?.WriteLine("");
            }
        }