I had to do some changes to one of our applications and noticed that it was still using the beta release of SignalR. So I thought it would be a good idea to quickly do an update to the release version. There were some breaking changes I was able to fix quite easily:
From:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddSignalR(options => | |
{ | |
options.JsonSerializerSettings.Converters.Add(new NullToDefaultConverter<Guid>()); | |
}); |
To:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services | |
.AddSignalR() | |
.AddJsonProtocol(options => | |
{ | |
options.PayloadSerializerSettings.Converters.Add(new NullToDefaultConverter<Guid>()); | |
}); |
From:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (clientProxy != null) | |
await clientProxy.InvokeAsync("ChatCreated", chatResult); |
To:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (clientProxy != null) | |
await clientProxy.SendAsync("ChatCreated", chatResult); |
From:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chatResult.Users | |
.Where(x => !string.IsNullOrWhiteSpace(x.ConnectionId)) | |
.ToList() | |
.ForEach(async user => { await _chatHub.Groups.AddAsync(user.ConnectionId, chatId); }); |
To:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chatResult.Users | |
.Where(x => !string.IsNullOrWhiteSpace(x.ConnectionId)) | |
.ToList() | |
.ForEach(async user => { await _chatHub.Groups.AddToGroupAsync(user.ConnectionId, chatId); }); |
From:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userConnectionId = await _userLogic.GetConnectionId(userId); | |
if (!string.IsNullOrWhiteSpace(userConnectionId)) | |
await Groups.RemoveAsync(userConnectionId, groupName); |
To:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userConnectionId = await _userLogic.GetConnectionId(userId); | |
if (!string.IsNullOrWhiteSpace(userConnectionId)) | |
await Groups.RemoveFromGroupAsync(userConnectionId, groupName); |