http-commands

This commit is contained in:
2023-04-13 20:42:05 +04:00
parent 24c9aa2043
commit e1a9ad476c
31 changed files with 428 additions and 104 deletions
@@ -0,0 +1,6 @@
namespace Ragon.Relay;
public class KickPlayerCommand
{
public string Id;
}
+1 -1
View File
@@ -6,7 +6,7 @@ using Ragon.Server.Room;
namespace Ragon.Relay;
public class RelayRoomPlugin: IRoomPlugin
public class RelayRoomPlugin: BaseRoomPlugin
{
public void Tick(float dt)
{
+15 -32
View File
@@ -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;
}
}
+2
View File
@@ -4,6 +4,8 @@
"serverTickRate": 30,
"gameProtocol": "1.0.0",
"port": 5000,
"httpPort": 5001,
"httpKey": "defaultkey",
"limitConnections": 4095,
"limitPlayersPerRoom": 20,
"limitRooms": 200,