Skip to content

Commit fc4a637

Browse files
committed
Add back helper class for single directional messaging
1 parent 8db5cd3 commit fc4a637

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

osu.Framework.Tests/Platform/IPCTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public void TestOneWay()
4646
Assert.IsTrue(server.IsPrimaryInstance, @"Server wasn't able to bind");
4747
Assert.IsFalse(client.IsPrimaryInstance, @"Client was able to bind when it shouldn't have been able to");
4848

49-
var serverChannel = new IpcChannel<Foobar, object>(server);
50-
var clientChannel = new IpcChannel<Foobar, object>(client);
49+
var serverChannel = new IpcChannel<Foobar>(server);
50+
var clientChannel = new IpcChannel<Foobar>(client);
5151

5252
async Task waitAction()
5353
{

osu.Framework/Platform/IpcChannel.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,29 @@
77
namespace osu.Framework.Platform
88
{
99
/// <summary>
10-
/// Setup an IPC channel which supports sending a specific pair of well-defined types.
10+
/// Define an IPC channel which supports sending a specific well-defined type.
1111
/// </summary>
12-
/// <typeparam name="T"></typeparam>
13-
/// <typeparam name="TResponse"></typeparam>
12+
/// <typeparam name="T">The type to send.</typeparam>
13+
public class IpcChannel<T> : IpcChannel<T, object> where T : class
14+
{
15+
public IpcChannel(IIpcHost host)
16+
: base(host)
17+
{
18+
}
19+
}
20+
21+
/// <summary>
22+
/// Define an IPC channel which supports sending and receiving a specific well-defined type.
23+
/// </summary>
24+
/// <typeparam name="T">The type to send.</typeparam>
25+
/// <typeparam name="TResponse">The type to receive.</typeparam>
1426
public class IpcChannel<T, TResponse> : IDisposable
1527
where T : class
1628
where TResponse : class
1729
{
1830
private readonly IIpcHost host;
1931

20-
public event Func<T, TResponse>? MessageReceived;
32+
public event Func<T, TResponse?>? MessageReceived;
2133

2234
public IpcChannel(IIpcHost host)
2335
{
@@ -37,7 +49,7 @@ public Task SendMessageAsync(T message) => host.SendMessageAsync(new IpcMessage
3749
{
3850
Type = typeof(T).AssemblyQualifiedName,
3951
Value = message,
40-
});
52+
}).ConfigureAwait(false);
4153

4254
if (response == null)
4355
return null;

0 commit comments

Comments
 (0)