using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PN_ServerFlex
{
    public partial class Form1 : Form
    {
        string PUBLISH_KEY = "demo";
        string SUBSCRIBE_KEY = "demo";
        string SECRET_KEY = "";
        Pubnub pubnub = null;
        public Form1()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
        }

        private void butBroadcast_Click(object sender, EventArgs e)
        {
            lblPS.Text = "";
            lblPI.Text = "";

            BroadCastMessage();
        }

        private void BroadCastMessage()
        {
            pubnub = new Pubnub(PUBLISH_KEY, SUBSCRIBE_KEY, SECRET_KEY, false);
            string channel = txtChannel.Text;
            List<object> info = pubnub.publish(channel, comboBox1.Text);
            ShowStatus(info);
        }

        private void ShowStatus(List<object> info)
        {
            lblPS.Text = info[0].ToString();
            lblPI.Text = info[1].ToString();
        }

        
    }
}
