So I can work on my desktop

This commit is contained in:
RaidMax 2015-08-23 16:58:48 -05:00
parent 38c8f81051
commit feb37123e2
19 changed files with 236 additions and 120 deletions

View File

@ -11,7 +11,7 @@ namespace IW4MAdmin
public override void Execute(Event E) public override void Execute(Event E)
{ {
if (E.Owner.owner == null) if (E.Owner.clientDB.getOwner() == null)
{ {
E.Origin.setLevel(Player.Permission.Owner); E.Origin.setLevel(Player.Permission.Owner);
E.Origin.Tell("Congratulations, you have claimed ownership of this server!"); E.Origin.Tell("Congratulations, you have claimed ownership of this server!");

View File

@ -60,12 +60,9 @@ namespace IW4MAdmin
if (S == null) if (S == null)
continue; continue;
if (!isIW4MStillRunning(S.pID()) || !S.isRunning) if (!isIW4MStillRunning(S.pID()))
{ {
Thread Defunct = ThreadList[S.pID()]; Thread Defunct = ThreadList[S.pID()];
if (!S.isRunning)
Utilities.shutdownInterface(S.pID());
S.isRunning = false; S.isRunning = false;
if (Defunct != null) if (Defunct != null)
@ -73,6 +70,10 @@ namespace IW4MAdmin
Defunct.Join(); Defunct.Join();
ThreadList[S.pID()] = null; ThreadList[S.pID()] = null;
} }
if (!S.isRunning)
Utilities.shutdownInterface(S.pID());
mainLog.Write("Server with PID #" + S.pID() + " can no longer be monitored.", Log.Level.Debug); mainLog.Write("Server with PID #" + S.pID() + " can no longer be monitored.", Log.Level.Debug);
activePIDs.Remove(S.pID()); activePIDs.Remove(S.pID());
defunctServers.Add(S); defunctServers.Add(S);

View File

@ -16,8 +16,7 @@ namespace IW4MAdmin
{ {
commandQueue = new Queue<string>(); commandQueue = new Queue<string>();
} }
private void getAliases(List<Aliases> returnAliases, Aliases currentAlias) private void getAliases(List<Aliases> returnAliases, Aliases currentAlias)
{ {
foreach(String IP in currentAlias.IPS) foreach(String IP in currentAlias.IPS)
@ -47,43 +46,7 @@ namespace IW4MAdmin
return allAliases; return allAliases;
getAliases(allAliases, currentIdentityAliases); getAliases(allAliases, currentIdentityAliases);
return allAliases; return allAliases;
/*
List<Aliases> aliasAliases = new List<Aliases>();
Aliases currentAliases = aliasDB.getPlayer(Origin.databaseID);
if (currentAliases == null)
{
Log.Write("No aliases found for " + Origin.Name, Log.Level.Debug);
return;
}
foreach (String IP in currentAliases.getIPS())
{
List<Aliases> tmp = aliasDB.getPlayer(IP);
if (tmp != null)
aliasAliases = tmp;
foreach (Aliases a in aliasAliases)
{
if (a == null)
continue;
Player aliasPlayer = clientDB.getPlayer(a.getNumber());
if (aliasPlayer != null)
{
aliasPlayer.Alias = a;
if (returnPlayers.Exists(p => p.databaseID == aliasPlayer.databaseID == false))
{
returnPlayers.Add(aliasPlayer);
getAliases(returnPlayers, aliasPlayer);
}
}
}
} */
} }
//Add player object p to `players` list //Add player object p to `players` list
@ -411,7 +374,7 @@ namespace IW4MAdmin
override public void setDvar(String Dvar, String Value) override public void setDvar(String Dvar, String Value)
{ {
lastDvarPointer = Utilities.executeCommand(PID, Dvar + " " + Value, lastDvarPointer); lastDvarPointer = Utilities.executeCommand(PID, Dvar + " " + "\"" + Value + "\"", lastDvarPointer);
} }
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
@ -427,6 +390,10 @@ namespace IW4MAdmin
if (events.Count > 0) if (events.Count > 0)
{ {
Event curEvent = events.Peek(); Event curEvent = events.Peek();
if (curEvent == null)
continue;
processEvent(curEvent); processEvent(curEvent);
foreach (Plugin P in PluginImporter.potentialPlugins) foreach (Plugin P in PluginImporter.potentialPlugins)
{ {
@ -610,6 +577,9 @@ namespace IW4MAdmin
{ {
try try
{ {
// clear out any lingering instances
Utilities.shutdownInterface(PID);
// inject our dll // inject our dll
if (!Utilities.initalizeInterface(PID)) if (!Utilities.initalizeInterface(PID))
{ {
@ -646,8 +616,19 @@ namespace IW4MAdmin
} }
// our settings // our settings
setDvar("sv_kickBanTime", "3600"); // 1 hour setDvar("sv_kickbantime", "3600"); // 1 hour
setDvar("g_logSync", "1"); // yas
int logSync = -1;
Int32.TryParse(getDvar("g_logSync").current, out oneLog);
if (logSync == 0)
{
Log.Write("g_logsync is not set to 1, restarting map...");
setDvar("g_logSync", "1"); // yas
executeCommand("map_restart");
SharedLibrary.Utilities.Wait(10);
}
if (Mod == String.Empty || oneLog == 1) if (Mod == String.Empty || oneLog == 1)
logPath = Basepath + '\\' + "m2demo" + '\\' + logPath; logPath = Basepath + '\\' + "m2demo" + '\\' + logPath;
@ -799,7 +780,17 @@ namespace IW4MAdmin
{ {
Log.Write("New map loaded - " + clientnum + " active players", Log.Level.Debug); Log.Write("New map loaded - " + clientnum + " active players", Log.Level.Debug);
String newMapName = getDvar("mapname").current; String newMapName = "0";
String newGametype = "0";
String newHostName = "0";
while(newMapName == "0" || newGametype == "0" || newHostName == "0") // weird anomaly here.
{
newMapName = getDvar("mapname").current;
newGametype = getDvar("g_gametype").current;
newHostName = getDvar("sv_hostname").current;
}
Map newMap = maps.Find(m => m.Name.Equals(newMapName)); Map newMap = maps.Find(m => m.Name.Equals(newMapName));
if (newMap != null) if (newMap != null)
@ -807,6 +798,9 @@ namespace IW4MAdmin
else else
mapname = newMapName; mapname = newMapName;
Gametype = newGametype;
hostname = SharedLibrary.Utilities.stripColors(newHostName);
return true; return true;
} }
@ -912,6 +906,8 @@ namespace IW4MAdmin
commands = new List<Command>(); commands = new List<Command>();
owner = clientDB.getOwner();
if(owner == null) if(owner == null)
commands.Add(new Owner("owner", "claim ownership of the server", "owner", Player.Permission.User, 0, false)); commands.Add(new Owner("owner", "claim ownership of the server", "owner", Player.Permission.User, 0, false));

View File

@ -288,7 +288,7 @@ namespace IW4MAdmin
} }
} }
IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + "\0"), ProcessHandle); // this gets disposed next call IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + '\0'), ProcessHandle); // this gets disposed next call
if (memoryForDvarName == IntPtr.Zero) if (memoryForDvarName == IntPtr.Zero)
{ {
@ -343,49 +343,45 @@ namespace IW4MAdmin
return false; return false;
} }
IntPtr baseAddress = IntPtr.Zero; List<IntPtr> baseAddresses = new List<IntPtr>();
System.Diagnostics.Process P = System.Diagnostics.Process.GetProcessById(pID); System.Diagnostics.Process P = System.Diagnostics.Process.GetProcessById(pID);
foreach (System.Diagnostics.ProcessModule M in P.Modules) foreach (System.Diagnostics.ProcessModule M in P.Modules)
{ {
if (M.ModuleName == "AdminInterface.dll") if (M.ModuleName == "AdminInterface.dll" && M.BaseAddress != IntPtr.Zero)
baseAddress = M.BaseAddress; baseAddresses.Add(M.BaseAddress);
} }
if (baseAddress == IntPtr.Zero) IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "FreeLibraryAndExitThread");
{
Program.getManager().mainLog.Write("Base address was not found!");
return false;
}
IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "FreeLibrary");
if (lpLLAddress == IntPtr.Zero) if (lpLLAddress == IntPtr.Zero)
{ {
Program.getManager().mainLog.Write("Could not obtain address of function address"); Program.getManager().mainLog.Write("Could not obtain address of freelibary");
return false; return false;
} }
ClientId clientid = new ClientId(); ClientId clientid = new ClientId();
threadID = new IntPtr(); threadID = new IntPtr();
RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid); foreach (IntPtr baseAddress in baseAddresses)
if (threadID == IntPtr.Zero)
{ {
Program.getManager().mainLog.Write("Could not create remote thread"); RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid);
return false; if (threadID == IntPtr.Zero)
} {
Program.getManager().mainLog.Write("Could not create remote thread");
return false;
}
#if DEBUG #if DEBUG
Program.getManager().mainLog.Write("Thread ID is " + threadID); Program.getManager().mainLog.Write("Thread ID is " + threadID);
#endif #endif
uint responseCode = WaitForSingleObject(threadID, 3000); uint responseCode = WaitForSingleObject(threadID, 3000);
if (responseCode != 0x00000000L) if (responseCode != 0x00000000L)
{ {
Program.getManager().mainLog.Write("Thread did not finish in a timely manner!"); Program.getManager().mainLog.Write("Thread did not finish in a timely manner!", Log.Level.Debug);
Program.getManager().mainLog.Write("Last error is: " + Marshal.GetLastWin32Error()); Program.getManager().mainLog.Write("Last error is: " + Marshal.GetLastWin32Error(), Log.Level.Debug);
return false; return false;
}
} }
CloseHandle(ProcessHandle); CloseHandle(ProcessHandle);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -24,6 +24,34 @@
$("#history_dialog").load(this.href); $("#history_dialog").load(this.href);
}); });
}); });
</script>
<script>
$(function () {
$('.pseudoLinkAlias').click(function (e) {
e.preventDefault();
$(this).next().toggle('fast');
return true;
});
});
$(function () {
$('a').click(function (e) {
e.stopPropagation();
e.preventDefault();
var href = this.href;
var parts = href.split('?');
var url = parts[0];
console.log(parts);
var params = parts[1].split('?');
var pp, inputs = '';
for (var i = 0, n = params.length; i < n; i++) {
pp = params[i].split('=');
inputs += '<input type="hidden" name="' + pp[0] + '" value="' + pp[1] + '" />';
}
$("body").append('<form action="' + url + '" method="post" id="sneakySneaky">' + inputs + '</form>');
$("#poster").submit();
});
});
</script> </script>
</body> </body>
</html> </html>

View File

@ -278,7 +278,6 @@
border-radius: 0px 0px 11px 11px; border-radius: 0px 0px 11px 11px;
} }
.players { .players {
float: left; float: left;
width: 400px; width: 400px;
@ -331,6 +330,11 @@
font-size: 14pt; font-size: 14pt;
width: 505px; width: 505px;
} }
.playerAlias, .playerIPs
{
display: none;
}
.chatFormat_submit, .chatFormat_submit:hover .chatFormat_submit, .chatFormat_submit:hover
{ {

Binary file not shown.

View File

@ -98,7 +98,12 @@ namespace SamplePlugin
killerStats.KDR = killerStats.Kills / killerStats.Deaths; killerStats.KDR = killerStats.Kills / killerStats.Deaths;
playerStats.updateStats(Killer, killerStats); playerStats.updateStats(Killer, killerStats);
killerStats.killStreak++;
killerStats.deathStreak = 0;
} }
Killer.Tell(messageOnStreak(killerStats.killStreak, killerStats.deathStreak));
} }
if (E.Type == Event.GType.Death) if (E.Type == Event.GType.Death)
@ -110,6 +115,11 @@ namespace SamplePlugin
victimStats.KDR = victimStats.Kills / victimStats.Deaths; victimStats.KDR = victimStats.Kills / victimStats.Deaths;
playerStats.updateStats(Victim, victimStats); playerStats.updateStats(Victim, victimStats);
victimStats.deathStreak++;
victimStats.killStreak = 0;
Victim.Tell(messageOnStreak(victimStats.killStreak, victimStats.deathStreak));
} }
} }
@ -123,6 +133,32 @@ namespace SamplePlugin
} }
private String messageOnStreak(int killStreak, int deathStreak)
{
String Message = "";
switch (killStreak)
{
case 5:
Message = "Great job! You're on a ^55 killstreak!";
break;
case 10:
Message = "Amazing! ^510 ^7kills without dying!";
break;
}
switch (deathStreak)
{
case 5:
Message = "Pick it up soldier, you've died 5 times in a row...";
break;
case 10:
Message = "Seriously? ^510 ^7deaths without getting a kill?";
break;
}
return Message;
}
public override string Name public override string Name
{ {
get { return "Basic Stats"; } get { return "Basic Stats"; }
@ -204,11 +240,15 @@ namespace SamplePlugin
Deaths = D; Deaths = D;
KDR = DR; KDR = DR;
Skill = S; Skill = S;
deathStreak = 0;
killStreak = 0;
} }
public int Kills; public int Kills;
public int Deaths; public int Deaths;
public double KDR; public double KDR;
public double Skill; public double Skill;
public int deathStreak;
public int killStreak;
} }
} }

View File

@ -47,7 +47,7 @@
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$(TargetName).dll"</PostBuildEvent> <PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$SimpleStatsPlugin.dll"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -239,7 +239,7 @@ namespace SharedLibrary
/// <param name="Target">Player to send message to</param> /// <param name="Target">Player to send message to</param>
public void Tell(String Message, Player Target) public void Tell(String Message, Player Target)
{ {
if (Target.clientID > -1) if (Target.clientID > -1 && Message.Length > 0)
executeCommand("tellraw " + Target.clientID + " " + Message + "^7"); executeCommand("tellraw " + Target.clientID + " " + Message + "^7");
if (Target.Level == Player.Permission.Console) if (Target.Level == Player.Permission.Console)

View File

@ -90,6 +90,11 @@ namespace SharedLibrary
return Cleaned.ToString(); return Cleaned.ToString();
} }
/// <summary>
/// Remove all IW Engine color codes
/// </summary>
/// <param name="str">String containing color codes</param>
/// <returns></returns>
public static String stripColors(String str) public static String stripColors(String str)
{ {
if (str == null) if (str == null)
@ -97,6 +102,11 @@ namespace SharedLibrary
return Regex.Replace(str, @"\^[0-9]", ""); return Regex.Replace(str, @"\^[0-9]", "");
} }
/// <summary>
/// Get the IW Engine color code corresponding to an admin level
/// </summary>
/// <param name="level">Specified player level</param>
/// <returns></returns>
public static String levelToColor(Player.Permission level) public static String levelToColor(Player.Permission level)
{ {
switch (level) switch (level)
@ -114,6 +124,11 @@ namespace SharedLibrary
} }
} }
/// <summary>
/// HTML formatted level color
/// </summary>
/// <param name="Level">Specified player level</param>
/// <returns></returns>
public static String levelHTMLFormatted(Player.Permission Level) public static String levelHTMLFormatted(Player.Permission Level)
{ {
switch (Level) switch (Level)
@ -186,6 +201,11 @@ namespace SharedLibrary
return str; return str;
} }
/// <summary>
/// Get the full gametype name
/// </summary>
/// <param name="input">Shorthand gametype reported from server</param>
/// <returns></returns>
public static String gametypeLocalized(String input) public static String gametypeLocalized(String input)
{ {
switch (input) switch (input)
@ -293,6 +313,8 @@ namespace SharedLibrary
return "fifth"; return "fifth";
case 100: case 100:
return "One-Hundreth (amazing!)"; return "One-Hundreth (amazing!)";
case 500:
return "^7You're really ^5dedicated ^7to this server! This is your ^5500th ^7time connecting!";
default: default:
return connection.ToString() + Prefix; return connection.ToString() + Prefix;
} }

View File

@ -97,6 +97,15 @@ namespace Webfront_Plugin
private String processReplacements(String Input, String Macro, int curPage, int ID, String Query, params Server[] Servers) private String processReplacements(String Input, String Macro, int curPage, int ID, String Query, params Server[] Servers)
{ {
bool Authenticated = false;
if (Servers[0] != null && Manager.lastIP != null)
{
Player User = Servers[0].clientDB.getPlayer(Manager.lastIP.ToString());
if (User != null && User.Level > Player.Permission.Flagged)
Authenticated = true;
}
if (Macro.Length < 5) if (Macro.Length < 5)
return ""; return "";
@ -110,13 +119,13 @@ namespace Webfront_Plugin
foreach (Server S in activeServers) foreach (Server S in activeServers)
{ {
StringBuilder players = new StringBuilder(); StringBuilder players = new StringBuilder();
if (S.getClientNum() < 1) if (S.getClientNum() > 0)
players.Append("<h2>No Players</h2>");
else
{ {
int count = 0; int count = 0;
double currentPlayers = S.statusPlayers.Count; double currentPlayers = S.statusPlayers.Count;
players.Append("<table cellpadding='0' cellspacing='0' class='players'>");
foreach (Player P in S.getPlayers()) foreach (Player P in S.getPlayers())
{ {
if (P == null) if (P == null)
@ -147,6 +156,7 @@ namespace Webfront_Plugin
count++; count++;
} }
players.Append("</table>");
} }
buffer.AppendFormat(@"<table cellpadding=0 cellspacing=0 class=server> buffer.AppendFormat(@"<table cellpadding=0 cellspacing=0 class=server>
<tr> <tr>
@ -159,11 +169,12 @@ namespace Webfront_Plugin
<th><a class='history' href='/graph?server={4}'>History</a></th> <th><a class='history' href='/graph?server={4}'>History</a></th>
</tr> </tr>
</table> </table>
<table cellpadding='0' cellspacing='0' class='players'> {5}",
{5}
</table>",
S.getName(), S.getMap(), S.getClientNum() + "/" + S.getMaxClients(), SharedLibrary.Utilities.gametypeLocalized(S.getGametype()), S.pID(), players.ToString()); S.getName(), S.getMap(), S.getClientNum() + "/" + S.getMaxClients(), SharedLibrary.Utilities.gametypeLocalized(S.getGametype()), S.pID(), players.ToString());
buffer.AppendFormat("<div class='chatHistory' id='chatHistory_{0}'></div><script type='text/javascript'>$( document ).ready(function() {{ setInterval({1}loadChatMessages({0}, '#chatHistory_{0}'){1}, 2500); }});</script><div class='null' style='clear:both;'></div>", S.pID(), '\"');
if (S.getClientNum() > 0)
buffer.AppendFormat("<div class='chatHistory' id='chatHistory_{0}'></div><script type='text/javascript'>$( document ).ready(function() {{ setInterval({1}loadChatMessages({0}, '#chatHistory_{0}'){1}, 2500); }});</script><div class='null' style='clear:both;'></div>", S.pID(), '\"');
//if (S.getClientNum() > 0) //if (S.getClientNum() > 0)
// buffer.AppendFormat("<form class='chatOutFormat' action={1}javascript:chatRequest({0}, 'chatEntry_{0}'){1}><input class='chatFormat_text' type='text' placeholder='Enter a message...' id='chatEntry_{0}'/><input class='chatFormat_submit' type='submit'/></form>", S.pID(), '\"'); // buffer.AppendFormat("<form class='chatOutFormat' action={1}javascript:chatRequest({0}, 'chatEntry_{0}'){1}><input class='chatFormat_text' type='text' placeholder='Enter a message...' id='chatEntry_{0}'/><input class='chatFormat_submit' type='submit'/></form>", S.pID(), '\"');
buffer.Append("<hr/>"); buffer.Append("<hr/>");
@ -230,30 +241,35 @@ namespace Webfront_Plugin
List<Aliases> allAlliases = S.getAliases(Player); List<Aliases> allAlliases = S.getAliases(Player);
List<String> nameAlias = new List<String>(); List<String> nameAlias = new List<String>();
List<String> IPAlias = new List<String>();
foreach (Aliases A in allAlliases) foreach (Aliases A in allAlliases)
{ {
foreach (String Name in A.Names.Distinct()) foreach (String Name in A.Names.Distinct())
nameAlias.Add(Name); nameAlias.Add(Name);
}
if (Authenticated)
{
foreach (String IP in A.IPS.Distinct())
IPAlias.Add(IP);
}
}
str.Append("<a href='#' class='pseudoLinkAlias'>Show Aliases</a>");
str.Append("<div class='playerAlias'>");
foreach (String Name in nameAlias.Distinct()) foreach (String Name in nameAlias.Distinct())
str.AppendFormat("<span>{0}</span><br/>", Utilities.stripColors(Name)); str.AppendFormat("<span>{0}</span><br/>", Utilities.stripColors(Name));
str.Append("</div>");
StringBuilder IPs = new StringBuilder(); StringBuilder IPs = new StringBuilder();
if (false) if (Authenticated)
{ {
/*foreach (Player a in aliases) IPs.Append("<a href='#'><span class='pseudoLinkIP'><i>Show IPs</i></span></a>");
{ IPs.Append("<div class='playerIPs'>");
foreach (String ip in a.Alias.IPS) foreach (String IP in IPAlias)
{ IPs.AppendFormat("<span>{0}</span><br/>", IP);
if (!IPs.ToString().Contains(ip)) IPs.Append("</div>");
IPs.AppendFormat("<span>{0}</span><br/>", ip);
}
}*/
} }
else else
IPs.Append("Hidden"); IPs.Append("Hidden");
@ -268,7 +284,7 @@ namespace Webfront_Plugin
String Screenshot = String.Empty; String Screenshot = String.Empty;
//if (logged) //if (logged)
Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name); Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}' target='_blank'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name);
buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, str, IPs, 0, SharedLibrary.Utilities.levelHTMLFormatted(Player.Level), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/player?id=" + Player.databaseID, Screenshot); buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, str, IPs, 0, SharedLibrary.Utilities.levelHTMLFormatted(Player.Level), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/player?id=" + Player.databaseID, Screenshot);
buffer.Append("</tr>"); buffer.Append("</tr>");

View File

@ -6,30 +6,25 @@ namespace Webfront_Plugin
{ {
public class Webfront : Plugin public class Webfront : Plugin
{ {
private static Manager webManager;
private static Thread webManagerThread; private static Thread webManagerThread;
public override void onEvent(Event E) public override void onEvent(Event E)
{ {
if (webManager != null) if (E.Type == Event.GType.Start)
{ {
if (E.Type == Event.GType.Start) Manager.webFront.addServer(E.Owner);
{ E.Owner.Log.Write("Webfront now has access to server on port " + E.Owner.getPort(), Log.Level.Production);
Manager.webFront.addServer(E.Owner); }
E.Owner.Log.Write("Webfront now has access to server on port " + E.Owner.getPort(), Log.Level.Production); if (E.Type == Event.GType.Stop)
} {
if (E.Type == Event.GType.Stop) Manager.webFront.removeServer(E.Owner);
{ E.Owner.Log.Write("Webfront has lost access to server on port " + E.Owner.getPort(), Log.Level.Production);
Manager.webFront.removeServer(E.Owner);
E.Owner.Log.Write("Webfront has lost access to server on port " + E.Owner.getPort(), Log.Level.Production);
}
} }
} }
public override void onLoad() public override void onLoad()
{ {
webManager = new Manager(); webManagerThread = new Thread(new ThreadStart(Manager.Init));
webManagerThread = new Thread(new ThreadStart(webManager.Init));
webManagerThread.Name = "Webfront"; webManagerThread.Name = "Webfront";
webManagerThread.Start(); webManagerThread.Start();
@ -37,7 +32,7 @@ namespace Webfront_Plugin
public override void onUnload() public override void onUnload()
{ {
webManager.webScheduler.Stop(); Manager.webScheduler.Stop();
webManagerThread.Join(); webManagerThread.Join();
} }

View File

@ -8,24 +8,42 @@ using System.Net;
namespace Webfront_Plugin namespace Webfront_Plugin
{ {
class Manager static class Manager
{ {
public IScheduler webScheduler { get; private set; } public static IScheduler webScheduler { get; private set; }
public static Framework webFront { get; private set; } public static Framework webFront { get; private set; }
public static IPAddress lastIP;
public Manager() public static void Init()
{
}
public void Init()
{ {
webScheduler = KayakScheduler.Factory.Create(new SchedulerDelegate()); webScheduler = KayakScheduler.Factory.Create(new SchedulerDelegate());
var server = KayakServer.Factory.CreateHttp(new RequestDelegate(), webScheduler); var server = KayakServer.Factory.Create(new ServerDelegate(), webScheduler);
webFront = new Framework(); webFront = new Framework();
using (server.Listen(new IPEndPoint(IPAddress.Any, 1624))) using (server.Listen(new IPEndPoint(IPAddress.Any, 1624)))
webScheduler.Start(); webScheduler.Start();
}
}
class HttpServerDelegate : IServerDelegate
{
IHttpRequestDelegate requestDelegate;
public HttpServerDelegate(IHttpRequestDelegate requestDelegate)
{
this.requestDelegate = requestDelegate;
}
public ISocketDelegate OnConnection(IServer server, ISocket socket)
{
// Kayak.Http.IHttpServerFactory
}
public void OnClose(IServer server)
{
} }
} }
@ -38,7 +56,7 @@ namespace Webfront_Plugin
public void OnStop(IScheduler scheduler) public void OnStop(IScheduler scheduler)
{ {
} }
} }