Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(textBox2.Text, out int port))
            {
                MessageBox.Show("端口号输入错误");
                return;
            }

            if (string.IsNullOrEmpty(textBox3.Text))
            {
                MessageBox.Show("关键字不能为空");
                return;
            }

            pushClient?.ClosePush( );
            pushClient = new NetPushClient(textBox1.Text, port, textBox3.Text);
            OperateResult create = pushClient.CreatePush(new Action <NetPushClient, string>(PushFromServer));

            if (create.IsSuccess)
            {
                button1.Enabled = false;
                button2.Enabled = true;
                MessageBox.Show("成功");
                panel2.Enabled = true;
            }
            else
            {
                MessageBox.Show("失败:" + create.Message);
            }
        }
Exemplo n.º 2
0
        public Broadcaster( )
        {
            // 获取所有连接的句柄,方便后面进行消息广播
            _hubContext = GlobalHost.ConnectionManager.GetHubContext <MyHub>( );

            // 实例化一个数据
            pushClient = new NetPushClient("127.0.0.1", 23467, "A");
            pushClient.CreatePush(NetPushCallBack);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            pushClient = new NetPushClient("127.0.0.1", 12345, "A");
            OperateResult create = pushClient.CreatePush((NetPushClient, y) =>
            {
                Console.WriteLine(y);
            });

            Console.ReadKey();
        }
Exemplo n.º 4
0
        public Broadcaster(IHubContext <ChartHub> hubContext, string netPushServer, int netPushPort)
        {
            // 获取所有连接的句柄,方便后面进行消息广播
            _hubContext = hubContext;

            // 实例化一个数据
            pushClient = new NetPushClient(netPushServer, netPushPort, "STK");
            pushClient.CreatePush(StkNetPushCallBack);

            // 实例化一个数据
            pushClient = new NetPushClient(netPushServer, netPushPort, "AGV");
            pushClient.CreatePush(AgvNetPushCallBack);
        }