|
12 | 12 | using osu.Framework.Bindables;
|
13 | 13 | using osu.Game.Online.API;
|
14 | 14 | using osu.Game.Online.Rooms;
|
| 15 | +using osu.Game.Overlays.Notifications; |
| 16 | +using osu.Game.Localisation; |
15 | 17 |
|
16 | 18 | namespace osu.Game.Online.Multiplayer
|
17 | 19 | {
|
@@ -50,6 +52,7 @@ private void load(IAPIProvider api)
|
50 | 52 | connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserJoined), ((IMultiplayerClient)this).UserJoined);
|
51 | 53 | connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserLeft), ((IMultiplayerClient)this).UserLeft);
|
52 | 54 | connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserKicked), ((IMultiplayerClient)this).UserKicked);
|
| 55 | + connection.On<int, long, string>(nameof(IMultiplayerClient.Invited), ((IMultiplayerClient)this).Invited); |
53 | 56 | connection.On<int>(nameof(IMultiplayerClient.HostChanged), ((IMultiplayerClient)this).HostChanged);
|
54 | 57 | connection.On<MultiplayerRoomSettings>(nameof(IMultiplayerClient.SettingsChanged), ((IMultiplayerClient)this).SettingsChanged);
|
55 | 58 | connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged);
|
@@ -106,6 +109,32 @@ protected override Task LeaveRoomInternal()
|
106 | 109 | return connection.InvokeAsync(nameof(IMultiplayerServer.LeaveRoom));
|
107 | 110 | }
|
108 | 111 |
|
| 112 | + public override async Task InvitePlayer(int userId) |
| 113 | + { |
| 114 | + if (!IsConnected.Value) |
| 115 | + return; |
| 116 | + |
| 117 | + Debug.Assert(connection != null); |
| 118 | + |
| 119 | + try |
| 120 | + { |
| 121 | + await connection.InvokeAsync(nameof(IMultiplayerServer.InvitePlayer), userId).ConfigureAwait(false); |
| 122 | + } |
| 123 | + catch (HubException exception) |
| 124 | + { |
| 125 | + switch (exception.GetHubExceptionMessage()) |
| 126 | + { |
| 127 | + case UserBlockedException.MESSAGE: |
| 128 | + PostNotification?.Invoke(new SimpleErrorNotification { Text = OnlinePlayStrings.InviteFailedUserBlocked }); |
| 129 | + break; |
| 130 | + |
| 131 | + case UserBlocksPMsException.MESSAGE: |
| 132 | + PostNotification?.Invoke(new SimpleErrorNotification { Text = OnlinePlayStrings.InviteFailedUserOptOut }); |
| 133 | + break; |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | + |
109 | 138 | public override Task TransferHost(int userId)
|
110 | 139 | {
|
111 | 140 | if (!IsConnected.Value)
|
|
0 commit comments