✨ http-commands
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
namespace Ragon.Relay;
|
||||
|
||||
public class KickPlayerCommand
|
||||
{
|
||||
public string Id;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using Ragon.Server.Room;
|
||||
|
||||
namespace Ragon.Relay;
|
||||
|
||||
public class RelayRoomPlugin: IRoomPlugin
|
||||
public class RelayRoomPlugin: BaseRoomPlugin
|
||||
{
|
||||
public void Tick(float dt)
|
||||
{
|
||||
|
||||
@@ -1,41 +1,24 @@
|
||||
using System.Net.Http;
|
||||
using Ragon.Server;
|
||||
using Ragon.Server.Lobby;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Ragon.Server.Plugin;
|
||||
using Ragon.Server.Room;
|
||||
|
||||
namespace Ragon.Relay;
|
||||
|
||||
public class RelayServerPlugin: IServerPlugin
|
||||
public class RelayServerPlugin: BaseServerPlugin
|
||||
{
|
||||
private HttpClient httpClient;
|
||||
public IRoomPlugin CreateRoomPlugin(RoomInformation information)
|
||||
{
|
||||
return new RelayRoomPlugin();
|
||||
}
|
||||
|
||||
public RelayServerPlugin()
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
}
|
||||
|
||||
public bool OnRoomCreate(RagonLobbyPlayer player, RagonRoom room)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnRoomRemove(RagonLobbyPlayer player, RagonRoom room)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnRoomLeave(RagonRoomPlayer player, RagonRoom room)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnRoomJoin(RagonRoomPlayer player, RagonRoom room)
|
||||
public override bool OnCommand(string command, string payload)
|
||||
{
|
||||
Console.WriteLine(command);
|
||||
if (command == "kick-player")
|
||||
{
|
||||
var commandPayload = JsonConvert.DeserializeObject<KickPlayerCommand>(payload);
|
||||
var player = GetPlayerById(commandPayload.Id);
|
||||
if (player != null)
|
||||
player.Connection.Close();
|
||||
else
|
||||
Console.WriteLine($"Player not found with Id {commandPayload.Id}");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user