diff --git a/osu.Game/Online/DevelopmentEndpointConfiguration.cs b/osu.Game/Online/DevelopmentEndpointConfiguration.cs
index 1c78c3c147..5f3c353f4d 100644
--- a/osu.Game/Online/DevelopmentEndpointConfiguration.cs
+++ b/osu.Game/Online/DevelopmentEndpointConfiguration.cs
@@ -13,7 +13,6 @@ namespace osu.Game.Online
SpectatorEndpointUrl = $@"{APIEndpointUrl}/signalr/spectator";
MultiplayerEndpointUrl = $@"{APIEndpointUrl}/signalr/multiplayer";
MetadataEndpointUrl = $@"{APIEndpointUrl}/signalr/metadata";
- NotificationsWebSocketEndpointUrl = "wss://dev.ppy.sh/home/notifications/feed";
}
}
}
diff --git a/osu.Game/Online/EndpointConfiguration.cs b/osu.Game/Online/EndpointConfiguration.cs
index 6187471b65..f3bcced630 100644
--- a/osu.Game/Online/EndpointConfiguration.cs
+++ b/osu.Game/Online/EndpointConfiguration.cs
@@ -44,10 +44,5 @@ namespace osu.Game.Online
/// The endpoint for the SignalR metadata server.
///
public string MetadataEndpointUrl { get; set; }
-
- ///
- /// The endpoint for the notifications websocket.
- ///
- public string NotificationsWebSocketEndpointUrl { get; set; }
}
}
diff --git a/osu.Game/Online/ExperimentalEndpointConfiguration.cs b/osu.Game/Online/ExperimentalEndpointConfiguration.cs
index bc65fd63f3..c3d0014c8b 100644
--- a/osu.Game/Online/ExperimentalEndpointConfiguration.cs
+++ b/osu.Game/Online/ExperimentalEndpointConfiguration.cs
@@ -14,7 +14,6 @@ namespace osu.Game.Online
SpectatorEndpointUrl = "https://spectator.ppy.sh/spectator";
MultiplayerEndpointUrl = "https://spectator.ppy.sh/multiplayer";
MetadataEndpointUrl = "https://spectator.ppy.sh/metadata";
- NotificationsWebSocketEndpointUrl = "wss://notify.ppy.sh";
}
}
}
diff --git a/osu.Game/Online/Notifications/WebSocket/OsuClientWebSocket.cs b/osu.Game/Online/Notifications/WebSocket/OsuClientWebSocket.cs
deleted file mode 100644
index 965f606bdc..0000000000
--- a/osu.Game/Online/Notifications/WebSocket/OsuClientWebSocket.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using System;
-using System.Diagnostics;
-using System.Net;
-using System.Net.WebSockets;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
-using osu.Framework.Extensions.TypeExtensions;
-using osu.Framework.Logging;
-using osu.Game.Online.API;
-
-namespace osu.Game.Online.Notifications.WebSocket
-{
- public class OsuClientWebSocket : IAsyncDisposable
- {
- public event Func? MessageReceived;
- public event Func? Closed;
-
- private readonly string endpoint;
- private readonly ClientWebSocket socket;
-
- private CancellationTokenSource? linkedTokenSource = null;
-
- public OsuClientWebSocket(IAPIProvider api, string endpoint)
- {
- socket = new ClientWebSocket();
- socket.Options.SetRequestHeader(@"Authorization", @$"Bearer {api.AccessToken}");
- socket.Options.Proxy = WebRequest.DefaultWebProxy;
- if (socket.Options.Proxy != null)
- socket.Options.Proxy.Credentials = CredentialCache.DefaultCredentials;
-
- this.endpoint = endpoint;
- }
-
- public async Task ConnectAsync(CancellationToken cancellationToken)
- {
- if (socket.State == WebSocketState.Connecting || socket.State == WebSocketState.Open)
- throw new InvalidOperationException("Connection is already opened");
-
- Debug.Assert(linkedTokenSource == null);
- linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
-
- await socket.ConnectAsync(new Uri(endpoint), linkedTokenSource.Token).ConfigureAwait(false);
- runReadLoop(linkedTokenSource.Token);
- }
-
- private void runReadLoop(CancellationToken cancellationToken) => Task.Factory.StartNew(async () =>
- {
- byte[] buffer = new byte[1024];
- StringBuilder messageResult = new StringBuilder();
-
- while (!cancellationToken.IsCancellationRequested)
- {
- try
- {
- WebSocketReceiveResult result = await socket.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false);
-
- switch (result.MessageType)
- {
- case WebSocketMessageType.Text:
- messageResult.Append(Encoding.UTF8.GetString(buffer[..result.Count]));
-
- if (result.EndOfMessage)
- {
- SocketMessage? message = JsonConvert.DeserializeObject(messageResult.ToString());
- messageResult.Clear();
-
- Debug.Assert(message != null);
-
- if (message.Error != null)
- {
- Logger.Log($"{GetType().ReadableName()} error: {message.Error}", LoggingTarget.Network);
- break;
- }
-
- await invokeMessageReceived(message).ConfigureAwait(false);
- }
-
- break;
-
- case WebSocketMessageType.Binary:
- throw new NotImplementedException("Binary message type not supported.");
-
- case WebSocketMessageType.Close:
- throw new WebException("Connection closed by remote host.");
- }
- }
- catch (Exception ex)
- {
- await invokeClosed(ex).ConfigureAwait(false);
- return;
- }
- }
- }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default);
-
- private async Task invokeMessageReceived(SocketMessage message)
- {
- if (MessageReceived == null)
- return;
-
- var invocationList = MessageReceived.GetInvocationList();
-
- // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
- foreach (Func handler in invocationList)
- await handler.Invoke(message).ConfigureAwait(false);
- }
-
- private async Task invokeClosed(Exception ex)
- {
- if (Closed == null)
- return;
-
- var invocationList = Closed.GetInvocationList();
-
- // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
- foreach (Func handler in invocationList)
- await handler.Invoke(ex).ConfigureAwait(false);
- }
-
- public Task SendMessage(SocketMessage message, CancellationToken cancellationToken)
- {
- if (socket.State != WebSocketState.Open)
- return Task.CompletedTask;
-
- return socket.SendAsync(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)), WebSocketMessageType.Text, true, cancellationToken);
- }
-
- public async Task DisconnectAsync()
- {
- linkedTokenSource?.Cancel();
- await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, @"Disconnecting", CancellationToken.None).ConfigureAwait(false);
- linkedTokenSource?.Dispose();
- linkedTokenSource = null;
- }
-
- public async ValueTask DisposeAsync()
- {
- try
- {
- await DisconnectAsync().ConfigureAwait(false);
- }
- catch
- {
- // Closure can fail if the connection is aborted. Don't really care since it's disposed anyway.
- }
-
- socket.Dispose();
- }
- }
-}
diff --git a/osu.Game/Online/ProductionEndpointConfiguration.cs b/osu.Game/Online/ProductionEndpointConfiguration.cs
index a26a25bce5..0244761b65 100644
--- a/osu.Game/Online/ProductionEndpointConfiguration.cs
+++ b/osu.Game/Online/ProductionEndpointConfiguration.cs
@@ -13,7 +13,6 @@ namespace osu.Game.Online
SpectatorEndpointUrl = "https://spectator.ppy.sh/spectator";
MultiplayerEndpointUrl = "https://spectator.ppy.sh/multiplayer";
MetadataEndpointUrl = "https://spectator.ppy.sh/metadata";
- NotificationsWebSocketEndpointUrl = "wss://notify.ppy.sh";
}
}
}