Exemplo n.º 1
0
 public static void Send(string dataStr)
 {
     if (broadcastService != null)
     {
         List <string> errorSessionIds = new List <string>();
         string        sessionKey      = "testkey";
         if (WSTestWSBehavior.GroupSessions.TryGetValue(sessionKey, out ConcurrentDictionary <string, WSTestWSBehavior> dic))
         {
             Parallel.ForEach(dic.Keys, po, key =>
             {
                 try
                 {
                     broadcastService.CurrentServiceHost(testPath).Sessions.SendTo(dataStr, key);
                 }
                 catch (Exception)
                 {
                     errorSessionIds.Add(key);
                 }
             });
         }
         if (errorSessionIds != null && errorSessionIds.Count > 0)
         {
             foreach (string errorSessionId in errorSessionIds)
             {
                 WebSocketBehavior webSocketBehavior = broadcastService.CurrentServiceHost(testPath).Sessions.Remove(errorSessionId);
                 if (webSocketBehavior != null)
                 {
                     webSocketBehavior.QuitFromGroups();
                     webSocketBehavior.Dispose();
                 }
             }
         }
     }
 }
        public static void WebSocketStart()
        {
            //币种
            var dicBit = ReflectionHelper.GetStaticPropertyNameAndValue(typeof(BitContract));

            //var dicBit = new Dictionary<string, object>();
            //dicBit.Add("ADA_USDT", BitContract.ADA_USDT);
            CommonlyExtensions.Foreach(dicBit, TakeEnum.ALL, (topic) =>
            {
                WebSocketBehavior.Subscribe(topic, HuoBiContract.HUOBI_ID);
            });
        }
Exemplo n.º 3
0
        public static bool TryGetUser(this WebSocketBehavior behavior, out WsUserName wsUserName, out UserData userData)
        {
            string base64String = behavior.Context.User.Identity.Name;

            return(WsRoot.TryGetUser(base64String, out wsUserName, out userData));
        }
        public WebSocketBehavior PublishService(EquipmentModel equipment)
        {
            WebSocketBehavior service = CreateService(equipment);

            return(service);
        }
Exemplo n.º 5
0
 private void OnNewListener(WebSocketBehavior client)
 {
     _listenerClients[client] = true;
 }
Exemplo n.º 6
0
 public WebSocketTransport(WebSocketTransportLayer layer, WebSocketBehavior session)
 {
     this.session = session;
     this.layer   = layer;
 }