Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.btn1.IsEnabled = false;

            //耗时长或有阻塞情况的不用线程池中的线程
            //ThreadPool.QueueUserWorkItem(fn => {
            //    Connect();
            //});
            try
            {
                Task task = Task.Factory.StartNew(() => {
                    var dic = new Dictionary <string, string>();
                    //dic.Add("sub-1", "/topic/latest_quotation_detail_CL1906");
                    //dic.Add("sub-2", "/topic/ask_bid_CL1906");
                    dic.Add("sub-1", "/topic/test");

                    WebSocketUtility ws = WebSocketUtility.Create("ws://market.future.alibaba.com/webSocket/zd/market", dic);
                    ws.Connect(onMessage);
                }, TaskCreationOptions.LongRunning);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
 //[TestMethod]
 public void TestWebSocketUtility()
 {
     string result = WebSocketUtility.Post("wss://mesh.fewbox.com:6443/api/v1/namespaces/fewbox-staging/pods/auth-deployment-latest-c56c67c8-vj7ph/exec?command=/bin/bash&stdin=true&stderr=true&stdout=true&tty=true&container=auth",
                                           "",
                                           new List <Header> {
     }).Result;
     //Assert.Fail(result);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化socket
        /// </summary>
        public void BindSocket()
        {
            Task task = Task.Factory.StartNew(() =>
            {
                var dic = new Dictionary <string, string>();
                dic.Add("sub-0", "/topic/latest_quotation_" + exchangeId + "." + productId + ".*");

                WebSocketUtility ws = WebSocketUtility.Create("ws://market.future.alibaba.com/webSocket/zd/market", dic);
                ws.Connect(delegate(string data)
                {
                });
            }, TaskCreationOptions.LongRunning);
        }