🐛 crash on abnormal disconnecting from websocket server
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.Handler;
|
||||
using Ragon.Server.IO;
|
||||
using Ragon.Server.Lobby;
|
||||
|
||||
@@ -21,6 +23,7 @@ namespace Ragon.Server;
|
||||
|
||||
public interface IRagonServer
|
||||
{
|
||||
BaseOperation ResolveHandler(RagonOperation operation);
|
||||
RagonLobbyPlayer? GetPlayerByConnection(INetworkConnection connection);
|
||||
RagonLobbyPlayer? GetPlayerById(string id);
|
||||
}
|
||||
@@ -28,10 +28,10 @@ public class RagonWebHookPlugin
|
||||
{
|
||||
private Dictionary<string, string> _webHooks;
|
||||
|
||||
private RagonServer _server;
|
||||
private IRagonServer _server;
|
||||
private HttpClient _httpClient;
|
||||
|
||||
public RagonWebHookPlugin(RagonServer server, RagonServerConfiguration configuration)
|
||||
public RagonWebHookPlugin(IRagonServer server, RagonServerConfiguration configuration)
|
||||
{
|
||||
_webHooks = new Dictionary<string, string>(configuration.WebHooks);
|
||||
_httpClient = new HttpClient();
|
||||
@@ -46,7 +46,7 @@ public class RagonWebHookPlugin
|
||||
var executor = context.Executor;
|
||||
executor.Run(async () =>
|
||||
{
|
||||
var authorizationOperation = (AuthorizationOperation) _server.ResolveOperation(RagonOperation.AUTHORIZE);
|
||||
var authorizationOperation = (AuthorizationOperation) _server.ResolveHandler(RagonOperation.AUTHORIZE);
|
||||
var response = await _httpClient.PostAsync(new Uri(value), httpContent);
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
|
||||
@@ -223,7 +223,7 @@ public class RagonServer : IRagonServer, INetworkListener
|
||||
_server.Broadcast(sendData, NetworkChannel.UNRELIABLE);
|
||||
}
|
||||
|
||||
public BaseOperation ResolveOperation(RagonOperation operation)
|
||||
public BaseOperation ResolveHandler(RagonOperation operation)
|
||||
{
|
||||
return _handlers[(byte)operation];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user