From bfb86b71df637cd16f0dbb5f98ce097af92c15c7 Mon Sep 17 00:00:00 2001 From: Pawel Kadluczka Date: Tue, 6 Feb 2018 10:49:37 -0800 Subject: [PATCH] Fixing support for Protobuf in SocialWeather (#1362) --- .../PersistentConnectionLifeTimeManager.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs b/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs index 7df866b47a..e94f5045f4 100644 --- a/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs +++ b/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Sockets; +using Microsoft.AspNetCore.Sockets.Features; namespace SocialWeather { @@ -22,7 +23,16 @@ namespace SocialWeather public void OnConnectedAsync(ConnectionContext connection) { connection.Metadata["groups"] = new HashSet(); - connection.Metadata["format"] = connection.GetHttpContext().Request.Query["formatType"].ToString(); + var format = connection.GetHttpContext().Request.Query["formatType"].ToString(); + connection.Metadata["format"] = format; + if (string.Equals(format, "protobuf", StringComparison.OrdinalIgnoreCase)) + { + var transferModeFeature = connection.Features.Get(); + if (transferModeFeature != null) + { + transferModeFeature.TransferMode = TransferMode.Binary; + } + } _connectionList.Add(connection); }