public IHttpActionResult Publish(MsgModel msg)
        {
            var json = JsonConvert.SerializeObject(msg);

            _webSocketHandler.Publish(json);
            return(Ok());
        }
Ejemplo n.º 2
0
 public async Task <IHttpActionResult> Push(MsgModel model)
 {
     foreach (var clientPair in clients)
     {
         var client = clientPair.Value;
         try
         {
             await WriteEventToStreamAsync(Guid.NewGuid(), "push", JsonConvert.SerializeObject(model), client);
         }
         catch (Exception)
         {
             Stream ignore;
             clients.TryRemove(clientPair.Key, out ignore);
         }
     }
     return(Ok());
 }