예제 #1
0
        public async Task <IActionResult> BroadcastBinaryAsync([FromBody] SimpleModel model)
        {
            if (model != null)
            {
                var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model));
                await _connectionManager.BroadcastBinaryAsync(bytes, new RouteValueDictionary(new { Id = 1, SomeProperty = "Some value" }));
            }

            return(Ok());
        }
예제 #2
0
        public async Task <IActionResult> BroadcastBinaryAsync([FromBody] SimpleModel model)
        {
            var bytes = _distrubutedCache.Get(model.Key);
            var routeValueDictionary = new RouteValueDictionary(new { Key = model.Key });

            if (bytes != null)
            {
                await _connectionManager.BroadcastBinaryAsync(bytes, routeValueDictionary);
            }
            return(Ok());
        }
예제 #3
0
        public static async Task BroadcastAsyncFileChanged(this IConnectionManager connectionManager, string content, string fullname)
        {
            if (string.IsNullOrEmpty(HostingHelper.MainAppDirectory))
            {
                // _Layout.cshtml from resources
                fullname = PathUtility.NormalizeToWebPath(fullname);
                await connectionManager.BroadcastBinaryAsync(Encoding.UTF8.GetBytes(content),
                                                             new RouteValueDictionary(new { mainappdir = HostingHelper.MainAppDirectory, fileupdated = fullname }));

                return;
            }

            fullname = fullname.Replace(HostingHelper.MainAppDirectory, string.Empty);
            fullname = PathUtility.NormalizeToWebPath(fullname);
            fullname = fullname.Replace("/wwwroot", string.Empty);

            await connectionManager.BroadcastBinaryAsync(Encoding.UTF8.GetBytes(content),
                                                         new RouteValueDictionary(new { mainappdir = HostingHelper.MainAppDirectory, fileupdated = fullname }));
        }