mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 03:53:04 +00:00
delete RCON folder
This commit is contained in:
parent
27bcb60a02
commit
909ccef3e1
5 changed files with 0 additions and 166 deletions
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 381eb0e589457424db93a1587f86f9eb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SanAndreasUnity.RCON
|
||||
{
|
||||
public class CommandInterpreter
|
||||
{
|
||||
public static String Interpret(String command)
|
||||
{
|
||||
string[] words = command.Split(' ');
|
||||
|
||||
if (command == "heartbeat")
|
||||
{
|
||||
// Implement heartbeat ping
|
||||
return "Heartbeat was sent to master server";
|
||||
}
|
||||
|
||||
if (command == "help")
|
||||
{
|
||||
return "The available commands for now are heartbeat, announce and help";
|
||||
}
|
||||
|
||||
if (words[0] == "announce")
|
||||
{
|
||||
String announcement = String.Join(" ", words, 1, words.Length - 1);
|
||||
SanAndreasUnity.Chat.ChatManager.SendChatMessageToAllPlayersAsServer(announcement);
|
||||
return "Server : " + announcement;
|
||||
}
|
||||
|
||||
return "Unknown command";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9cf8ca8374941dd4aaa862202a1a2b7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,100 +0,0 @@
|
|||
using Rcon;
|
||||
using Rcon.Events;
|
||||
using SanAndreasUnity.Net;
|
||||
using SanAndreasUnity.Utilities;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SanAndreasUnity.RCON
|
||||
{
|
||||
public class RCONManager : MonoBehaviour
|
||||
{
|
||||
// Todo : set these from config
|
||||
private static String password;
|
||||
private static int portNumber;
|
||||
|
||||
// Objects used to pass commands and responses between threads
|
||||
private static BlockingCollection<String> mainToSec = new BlockingCollection<String>(1);
|
||||
private static BlockingCollection<String> secToMain = new BlockingCollection<String>(1);
|
||||
|
||||
private static BackgroundWorker workerInstance = null;
|
||||
|
||||
public static void StartServer()
|
||||
{
|
||||
password = Config.GetString("RCON_password");
|
||||
portNumber = Config.GetInt("RCON_port");
|
||||
|
||||
if (workerInstance != null)
|
||||
return;
|
||||
|
||||
workerInstance = new BackgroundWorker();
|
||||
|
||||
workerInstance.DoWork += new DoWorkEventHandler( worker_doWork );
|
||||
workerInstance.ProgressChanged += new ProgressChangedEventHandler( worker_progressChanged );
|
||||
workerInstance.WorkerReportsProgress = true;
|
||||
// workerInstance.WorkerSupportsCancellation = true;
|
||||
|
||||
workerInstance.RunWorkerAsync(); // Call the background worker
|
||||
}
|
||||
|
||||
#region Code that runs in the RCON Server Thread
|
||||
private static void worker_doWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
using (RconServer server = new RconServer(password, portNumber))
|
||||
{
|
||||
server.OnClientCommandReceived += Server_OnClientCommandReceived;
|
||||
server.OnClientConnected += Server_OnClientConnected;
|
||||
server.OnClientAuthenticated += Server_OnClientAuthenticated;
|
||||
server.OnClientDisconnected += Server_OnClientDisconnected;
|
||||
server.Start();
|
||||
}
|
||||
}
|
||||
static void Server_OnClientAuthenticated(object sender, ClientAuthenticatedEventArgs e)
|
||||
{
|
||||
// Console.WriteLine("{0} authenticated", e.Client.Client.LocalEndPoint);
|
||||
}
|
||||
static void Server_OnClientDisconnected(object sender, ClientDisconnectedEventArgs e)
|
||||
{
|
||||
// Console.WriteLine("{0} disconnected", e.EndPoint);
|
||||
}
|
||||
static void Server_OnClientConnected(object sender, ClientConnectedEventArgs e)
|
||||
{
|
||||
// Console.WriteLine("{0} connected", e.Client.Client.LocalEndPoint);
|
||||
}
|
||||
static string Server_OnClientCommandReceived(object sender, ClientSentCommandEventArgs e)
|
||||
{
|
||||
secToMain.Add(e.Command); // Pass the command to the main thread
|
||||
|
||||
workerInstance.ReportProgress(0); //Report our progress to the main thread
|
||||
|
||||
String commandResult = "Command didn't process correctly"; // default value
|
||||
|
||||
commandResult = mainToSec.Take();
|
||||
|
||||
return commandResult;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Runs in main thread
|
||||
private static void worker_progressChanged(object sender, ProgressChangedEventArgs e)
|
||||
{
|
||||
String command = "unknown";
|
||||
|
||||
command = secToMain.Take();
|
||||
|
||||
mainToSec.Add(CommandInterpreter.Interpret(command));
|
||||
}
|
||||
|
||||
void OnLoaderFinished()
|
||||
{
|
||||
if (NetStatus.IsServer)
|
||||
{
|
||||
if (Config.GetBool("RCON_enabled"))
|
||||
StartServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c77317cdc437f244b8d409c229aa2e95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 5018
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue