コード例 #1
0
        public string Execute(string request)
        {
            var task1 = new Task <string>(() =>
            {
                var webSocketClient = WebSocketClientManager.GetInstance().GetClientById(_websocketClientId);
                if (webSocketClient != null)
                {
                    OperationManager.GetInstance().AddOperation(Token, this);
                    webSocketClient.Send(request);
                    Log.InfoFormat("Request: {0}", request);

                    while (!blockToken.IsCancellationRequested)
                    {
                        Thread.Sleep(300);
                    }

                    OperationManager.GetInstance().RemoveOperation(Token);
                    Log.InfoFormat("Response: {0}", _response);
                    return(_response);
                }
                else
                {
                    Log.WarnFormat("Cannot file websocket client={0}", _websocketClientId);
                    return("");
                }
            }, blockToken.Token);

            task1.Start();
            task1.Wait();

            Log.InfoFormat("task1.Result: {0}", task1.Result);
            return(task1.Result);
        }
コード例 #2
0
 static WebSocketClientManager()
 {
     _lockObject = new object();
     _instance   = new WebSocketClientManager();
 }
コード例 #3
0
 public static void Initialize()
 {
     Repository.RepositoryManager.AddAssemby(typeof(Repository.Mybatis.MsSql.NinjectBinder).Assembly);
     OperationManager.GetInstance();
     WebSocketClientManager.GetInstance();
 }