Fusion MyCommon et MyConsole
This commit is contained in:
parent
156590a1a1
commit
1746bc4e65
|
@ -1,178 +0,0 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Galactic_Colors_Control_Common
|
||||
{
|
||||
/// <summary>
|
||||
/// All used types - byte[] convertions
|
||||
/// </summary>
|
||||
public static class Binary
|
||||
{
|
||||
public static bool TryToBool(ref byte[] bytes, out bool res)
|
||||
{
|
||||
if (bytes.Length < 1)
|
||||
{
|
||||
res = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] data = new byte[1];
|
||||
data = bytes.Take(1).ToArray();
|
||||
RemoveFirst(ref bytes, 1);
|
||||
if (data[1] == 1)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data[1] == 0)
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///<remarks>1 byte</remarks>
|
||||
public static byte[] FromBool(bool x)
|
||||
{
|
||||
return x ? new byte[1] { 1 } : new byte[1] { 0 };
|
||||
}
|
||||
|
||||
public static bool TryToString(ref byte[] bytes, out string res)
|
||||
{
|
||||
res = null;
|
||||
int len;
|
||||
if (!TryToInt(ref bytes, out len))
|
||||
return false;
|
||||
|
||||
if (bytes.Length < len)
|
||||
return false;
|
||||
|
||||
res = Encoding.ASCII.GetString(bytes.Take(len).ToArray());
|
||||
RemoveFirst(ref bytes, len);
|
||||
return res != null;
|
||||
}
|
||||
|
||||
///<remarks>len(in bytes) + string</remarks>
|
||||
public static byte[] FromString(string text)
|
||||
{
|
||||
byte[] data = Encoding.ASCII.GetBytes(text);
|
||||
return AddBytes(FromInt(data.Length), data);
|
||||
}
|
||||
|
||||
public static bool TryToInt(ref byte[] bytes, out int res)
|
||||
{
|
||||
res = int.MinValue;
|
||||
|
||||
if (bytes.Length < 4)
|
||||
return false;
|
||||
|
||||
byte[] data = new byte[4];
|
||||
data = bytes.Take(4).ToArray();
|
||||
data.Reverse();
|
||||
res = BitConverter.ToInt32(data, 0);
|
||||
RemoveFirst(ref bytes, 4);
|
||||
return res != int.MinValue;
|
||||
}
|
||||
|
||||
///<remarks>4 bytes</remarks>
|
||||
public static byte[] FromInt(int x)
|
||||
{
|
||||
byte[] data = new byte[4];
|
||||
data = BitConverter.GetBytes(x);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool TryToStringArray(ref byte[] bytes, out string[] data)
|
||||
{
|
||||
data = null;
|
||||
|
||||
int len;
|
||||
if (!TryToInt(ref bytes, out len))
|
||||
return false;
|
||||
|
||||
if (len < 1 || len > 10000)
|
||||
return false;
|
||||
|
||||
data = new string[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (!TryToString(ref bytes, out data[i]))
|
||||
return false;
|
||||
}
|
||||
return data != null;
|
||||
}
|
||||
|
||||
public static byte[] FromStringArray(string[] array)
|
||||
{
|
||||
if (array == null)
|
||||
return new byte[0];
|
||||
|
||||
byte[] data = FromInt(array.Length);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
data = AddBytes(data, FromString(array[i]));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool TryToIntArray(ref byte[] bytes, out int[] res)
|
||||
{
|
||||
res = null;
|
||||
int len;
|
||||
if (!TryToInt(ref bytes, out len))
|
||||
return false;
|
||||
|
||||
res = new int[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (!TryToInt(ref bytes, out res[i]))
|
||||
return false;
|
||||
}
|
||||
return res != null;
|
||||
}
|
||||
|
||||
public static byte[] FromIntArray(int[] array)
|
||||
{
|
||||
byte[] data = FromInt(array.Length);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
data = AddBytes(data, FromInt(array[i]));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte[] AddBytes(params byte[][] arguments)
|
||||
{
|
||||
byte[] res = new byte[arguments.Sum(a => a.Length)];
|
||||
int offset = 0;
|
||||
for (int i = 0; i < arguments.Length; i++)
|
||||
{
|
||||
Buffer.BlockCopy(arguments[i], 0, res, offset, arguments[i].Length);
|
||||
offset += arguments[i].Length;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void RemoveFirst(ref byte[] bytes, int count)
|
||||
{
|
||||
if (bytes.Length - count < 0)
|
||||
{
|
||||
bytes = new byte[0] { };
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] newbytes = new byte[bytes.Length - count];
|
||||
newbytes = bytes.Skip(count).ToArray();
|
||||
bytes = newbytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Galactic_Colors_Control_Common
|
||||
namespace Galactic_Colors_Control_Common
|
||||
{
|
||||
public static class Common
|
||||
{
|
||||
public static string dictionary = Properties.Resources.Lang;
|
||||
|
||||
/// <summary>
|
||||
/// Simpler string array creation
|
||||
/// </summary>
|
||||
public static string[] Strings(params string[] args)
|
||||
{
|
||||
return args;
|
||||
}
|
||||
|
||||
public static string ArrayToString(string[] array)
|
||||
{
|
||||
string text = "";
|
||||
if (array != null)
|
||||
{
|
||||
foreach (string str in array)
|
||||
{
|
||||
text += ((text == "" ? "" : Environment.NewLine) + str);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static string ArrayToString(int[] array)
|
||||
{
|
||||
string text = "";
|
||||
foreach (int i in array)
|
||||
{
|
||||
text += ((text == "" ? "" : Environment.NewLine) + i.ToString());
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static string[] SplitArgs(string text)
|
||||
{
|
||||
return text.Split('"')
|
||||
.Select((element, index) => index % 2 == 0
|
||||
? element.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
: new string[] { element })
|
||||
.SelectMany(element => element).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,9 +37,6 @@
|
|||
<Reference Include="MyCommon">
|
||||
<HintPath>..\..\MyCommon\MyCommon\bin\Release\MyCommon.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MyConsole">
|
||||
<HintPath>..\..\MyConsole\MyConsole\bin\Release\MyConsole.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
@ -53,9 +50,7 @@
|
|||
<Compile Include="..\AssemblyInfoCommon.cs">
|
||||
<Link>Properties\AssemblyInfoCommon.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Binary.cs" />
|
||||
<Compile Include="Common.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
|
|
@ -1,177 +0,0 @@
|
|||
using MyConsole;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace Galactic_Colors_Control_Common
|
||||
{
|
||||
public class Logger
|
||||
{
|
||||
public enum logType { dev, debug, info, warm, error, fatal }
|
||||
|
||||
public enum logConsole { normal, show, hide }
|
||||
|
||||
public struct Log
|
||||
{
|
||||
public string text;
|
||||
public logType type;
|
||||
public logConsole console;
|
||||
|
||||
public Log(string p1, logType p2, logConsole p3 = logConsole.normal)
|
||||
{
|
||||
text = p1;
|
||||
type = p2;
|
||||
console = p3;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Log> toWriteLogs = new List<Log>();
|
||||
private string logPath;
|
||||
private ConsoleColor[] logBackColor;
|
||||
private ConsoleColor[] logForeColor;
|
||||
private Thread Updater;
|
||||
private logType logLevel = logType.info;
|
||||
private bool _run = true;
|
||||
public bool run { get { return _run; } }
|
||||
private static bool _debug = false;
|
||||
private static bool _dev = false;
|
||||
private bool haveConsole = false;
|
||||
|
||||
/// <summary>
|
||||
/// Create log file and start logger thread
|
||||
/// </summary>
|
||||
/// <param name="LogPath">Absolute path to logs directory</param>
|
||||
public void Initialise(string LogPath, ConsoleColor[] backColor, ConsoleColor[] foreColor, logType LogLevel, bool debug, bool dev, bool haveconsole = true)
|
||||
{
|
||||
haveConsole = haveconsole;
|
||||
logPath = LogPath;
|
||||
logBackColor = backColor;
|
||||
logForeColor = foreColor;
|
||||
logLevel = LogLevel;
|
||||
_debug = debug;
|
||||
_dev = dev;
|
||||
if (!Directory.Exists(logPath))
|
||||
{
|
||||
Directory.CreateDirectory(logPath);
|
||||
Write("Log Directory Created", logType.info);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Sort old logs
|
||||
string[] files = Directory.GetFiles(logPath);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (Path.GetExtension(file) == ".log")
|
||||
{
|
||||
string name = Path.GetFileName(file);
|
||||
name = name.Substring(0, Math.Min(name.Length, 10));
|
||||
if (name.Length == 10)
|
||||
{
|
||||
if (name != DateTime.UtcNow.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture))
|
||||
{
|
||||
int y;
|
||||
int m;
|
||||
int d;
|
||||
|
||||
if (int.TryParse(new string(name.Take(4).ToArray()), out y) && int.TryParse(new string(name.Skip(5).Take(2).ToArray()), out m) && int.TryParse(new string(name.Skip(8).Take(2).ToArray()), out d))
|
||||
{
|
||||
if (!Directory.Exists(logPath + "/" + y + "/" + m + "/" + d))
|
||||
{
|
||||
Directory.CreateDirectory(logPath + "/" + y + "/" + m + "/" + d);
|
||||
}
|
||||
File.Move(file, logPath + "/" + y + "/" + m + "/" + d + "/" + Path.GetFileName(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(logPath + "/" + DateTime.UtcNow.ToString("yyyy-MM-dd-", CultureInfo.InvariantCulture) + i + ".log")) { i++; }
|
||||
logPath = logPath + "/" + DateTime.UtcNow.ToString("yyyy-MM-dd-", CultureInfo.InvariantCulture) + i + ".log";
|
||||
Write("Log path:" + logPath, logType.debug);
|
||||
Updater = new Thread(new ThreadStart(UpdaterLoop));
|
||||
Updater.Start();
|
||||
}
|
||||
|
||||
public void Join()
|
||||
{
|
||||
_run = false;
|
||||
Updater.Join();
|
||||
}
|
||||
|
||||
public void ChangeLevel(logType level)
|
||||
{
|
||||
logLevel = level;
|
||||
Write("Change to " + logLevel.ToString(), logType.info, logConsole.show);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add log to log pile
|
||||
/// </summary>
|
||||
/// <param name="text">Log text</param>
|
||||
/// <param name="type">Log status</param>
|
||||
/// <param name="console">Server display modifier</param>
|
||||
public void Write(string text, logType type, logConsole console = logConsole.normal)
|
||||
{
|
||||
Write(new Log(text, type, console));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add log to log pile
|
||||
/// </summary>
|
||||
/// <param name="log">Log struct</param>
|
||||
private void Write(Log log)
|
||||
{
|
||||
if (_debug || _dev)
|
||||
{
|
||||
//Add Source Method
|
||||
log.text = "[" + new StackTrace().GetFrame(2).GetMethod().Name + "]: " + log.text;
|
||||
}
|
||||
toWriteLogs.Add(log);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write log pile to logfile and console
|
||||
/// </summary>
|
||||
public void UpdaterLoop()
|
||||
{
|
||||
while (_run || toWriteLogs.Count > 0)
|
||||
{
|
||||
while (toWriteLogs.Count > 0)
|
||||
{
|
||||
Log log = toWriteLogs[0]; //Saved log -> any lock need
|
||||
|
||||
if (log.type >= logLevel)
|
||||
{
|
||||
File.AppendAllText(logPath, DateTime.UtcNow.ToString("[yyyy-MM-dd]", CultureInfo.InvariantCulture) + " [" + log.type.ToString().ToUpper() + "]: " + log.text + Environment.NewLine);
|
||||
if (log.console != logConsole.hide)
|
||||
{
|
||||
ConsoleWrite(log);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (log.console == logConsole.show)
|
||||
{
|
||||
ConsoleWrite(log);
|
||||
}
|
||||
}
|
||||
toWriteLogs.Remove(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ConsoleWrite(Log log)
|
||||
{
|
||||
if (haveConsole)
|
||||
Console.Write(new ColorStrings(new ColorString(DateTime.UtcNow.ToString("[yyyy-MM-dd]", CultureInfo.InvariantCulture) + ": " + log.text, logForeColor[(int)log.type], logBackColor[(int)log.type])));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
using MyCommon;
|
||||
|
||||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
{
|
||||
/// <summary>
|
||||
/// Packet Master Class
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
using MyCommon;
|
||||
|
||||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
{
|
||||
public enum EventTypes
|
||||
{
|
||||
|
@ -44,7 +46,7 @@
|
|||
|
||||
public override string ToSmallString()
|
||||
{
|
||||
return type.ToString() + "|" + Common.ArrayToString(data);
|
||||
return type.ToString() + "|" + Strings.ArrayToString(data);
|
||||
}
|
||||
|
||||
public override string ToLongString()
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Galactic_Colors_Control_Common.Protocol
|
|||
{
|
||||
public static string GetEventText(EventData eve, int lang, MultiLang dico)
|
||||
{
|
||||
string data = Common.ArrayToString(eve.data);
|
||||
string data = Strings.ArrayToString(eve.data);
|
||||
switch (eve.type)
|
||||
{
|
||||
case EventTypes.ChatMessage:
|
||||
|
@ -25,10 +25,10 @@ namespace Galactic_Colors_Control_Common.Protocol
|
|||
|
||||
public static string GetResultText(ResultData res, int lang, MultiLang dico)
|
||||
{
|
||||
string data = Common.ArrayToString(res.result);
|
||||
string data = Strings.ArrayToString(res.result);
|
||||
if (res.type == ResultTypes.Error)
|
||||
data = dico.GetWord("Error", lang) + ": " + data;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
using MyCommon;
|
||||
|
||||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
{
|
||||
/// <summary>
|
||||
/// Client to Server Data request packet 'allways' return ResultData
|
||||
|
@ -30,12 +32,12 @@
|
|||
|
||||
public override string ToSmallString()
|
||||
{
|
||||
return Common.ArrayToString(args);
|
||||
return Strings.ArrayToString(args);
|
||||
}
|
||||
|
||||
public override string ToLongString()
|
||||
{
|
||||
return "Request : " + Common.ArrayToString(args) + "|" + id;
|
||||
return "Request : " + Strings.ArrayToString(args) + "|" + id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
using MyCommon;
|
||||
|
||||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
{
|
||||
public enum ResultTypes { Error, OK }
|
||||
|
||||
|
@ -46,12 +48,12 @@
|
|||
|
||||
public override string ToSmallString()
|
||||
{
|
||||
return type.ToString() + "|" + Common.ArrayToString(result);
|
||||
return type.ToString() + "|" + Strings.ArrayToString(result);
|
||||
}
|
||||
|
||||
public override string ToLongString()
|
||||
{
|
||||
return "Result : " + type.ToString() + "|" + Common.ArrayToString(result) + "|" + id;
|
||||
return "Result : " + type.ToString() + "|" + Strings.ArrayToString(result) + "|" + id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
<Reference Include="MyCommon">
|
||||
<HintPath>..\..\MyCommon\MyCommon\bin\Release\MyCommon.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MyConsole">
|
||||
<HintPath>..\..\MyConsole\MyConsole\bin\Release\MyConsole.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
using Galactic_Colors_Control;
|
||||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using Consol = MyConsole.ConsoleIO;
|
||||
using MyCommon;
|
||||
using MyConsole;
|
||||
using Consol = MyCommon.ConsoleIO;
|
||||
|
||||
namespace Galactic_Colors_Control_Console
|
||||
{
|
||||
|
@ -116,13 +115,13 @@ namespace Galactic_Colors_Control_Console
|
|||
System.Console.Clear();
|
||||
Consol.Write(new ColorStrings(Parser.GetResultText(client.Request(new string[2] { "party", "list" }), config.lang, multilang)));
|
||||
Consol.Write(new ColorStrings(multilang.GetWord("Party", config.lang) + ":" + System.Environment.NewLine + " (<id> [password] or 'c' for create)"));
|
||||
string[] data = Common.SplitArgs(System.Console.ReadLine());
|
||||
string[] data = Strings.SplitArgs(System.Console.ReadLine());
|
||||
if (data.Length > 0)
|
||||
{
|
||||
if (data[0] == "c")
|
||||
{
|
||||
Consol.Write(new ColorStrings("<party name> <player count>:"));
|
||||
string[] split = Common.SplitArgs(System.Console.ReadLine());
|
||||
string[] split = Strings.SplitArgs(System.Console.ReadLine());
|
||||
if (split.Length == 2)
|
||||
{
|
||||
ResultData createRes = client.Request(new string[4] { "party", "create", split[0], split[1] });
|
||||
|
@ -189,11 +188,11 @@ namespace Galactic_Colors_Control_Console
|
|||
if (input[0] == config.commandChar)
|
||||
{
|
||||
input = input.Substring(1);
|
||||
req = Common.SplitArgs(input);
|
||||
req = Strings.SplitArgs(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
req = Common.Strings("say", input);
|
||||
req = Strings.ArrayFromStrings("say", input);
|
||||
}
|
||||
Consol.Write(new ColorStrings(Parser.GetResultText(client.Request(req), config.lang, multilang)));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
|
|
@ -64,9 +64,6 @@
|
|||
<Reference Include="MyCommon">
|
||||
<HintPath>..\..\MyCommon\MyCommon\bin\Release\MyCommon.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MyConsole">
|
||||
<HintPath>..\..\MyConsole\MyConsole\bin\Release\MyConsole.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MyMonoGame">
|
||||
<HintPath>..\..\MonoGame\MyMonoGameGUI\MyMonoGameGUI\bin\Release\MyMonoGame.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
@ -5,7 +5,6 @@ using Microsoft.Xna.Framework.Content;
|
|||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MyCommon;
|
||||
using MyMonoGame;
|
||||
using MyMonoGame.GUI;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using Console = MyConsole.ConsoleIO;
|
||||
using MyConsole;
|
||||
using Console = MyCommon.ConsoleIO;
|
||||
|
||||
namespace Galactic_Colors_Control_GUI
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MyCommon;
|
||||
using MyMonoGame.GUI;
|
||||
using System.Threading;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MyCommon;
|
||||
using MyMonoGame.GUI;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
@ -78,12 +78,12 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
if (request[0] == Game.singleton.config.commandChar)
|
||||
{
|
||||
request = request.Substring(1);
|
||||
res = Game.singleton.client.Request(Common.SplitArgs(request));
|
||||
res = Game.singleton.client.Request(Strings.SplitArgs(request));
|
||||
ChatText(Parser.GetResultText(res, Game.singleton.config.lang, Game.singleton.multilang));
|
||||
}
|
||||
else
|
||||
{
|
||||
res = Game.singleton.client.Request(Common.Strings("say", request));
|
||||
res = Game.singleton.client.Request(Strings.ArrayFromStrings("say", request));
|
||||
if (res.type != ResultTypes.OK)
|
||||
{
|
||||
ChatText(Parser.GetResultText(res, Game.singleton.config.lang, Game.singleton.multilang));
|
||||
|
@ -98,7 +98,7 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
{
|
||||
Game.singleton.logger.Write("Server kick" + eve.data, Logger.logType.warm);
|
||||
message.title = Game.singleton.multilang.GetWord("ServerKick", Game.singleton.config.lang);
|
||||
message.text = Common.ArrayToString(eve.data);
|
||||
message.text = Strings.ArrayToString(eve.data);
|
||||
showOKMessage = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MyCommon;
|
||||
using MyMonoGame.GUI;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
else
|
||||
{
|
||||
message.title = Game.singleton.multilang.GetWord("Error", Game.singleton.config.lang);
|
||||
message.text = Common.ArrayToString(res.result);
|
||||
message.text = Strings.ArrayToString(res.result);
|
||||
showOKMessage = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Galactic_Colors_Control;
|
||||
using Galactic_Colors_Control_Common;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MyCommon;
|
||||
using MyMonoGame.GUI;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
{
|
||||
Game.singleton.background.Draw(spritebatch);
|
||||
Game.singleton.GUI.Label(new MyMonoGame.Vector(Game.singleton.ScreenWidth / 2, Game.singleton.ScreenHeight / 4), Game.singleton.multilang.GetWord("GCC", Game.singleton.config.lang), Game.singleton.GUI.content.GetFont("title"), new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 75, Game.singleton.ScreenHeight / 2 + 20, 150, 40), Game.singleton.GUI.content.GetBox("Default"), Game.singleton.multilang.IDToLang(Game.singleton.config.lang),Game.singleton.GUI.content.GetFont("basic"), new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 75, Game.singleton.ScreenHeight / 2 + 20, 150, 40), Game.singleton.GUI.content.GetBox("Default"), Game.singleton.multilang.IDToLang(Game.singleton.config.lang), Game.singleton.GUI.content.GetFont("basic"), new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
Game.singleton.GUI.ResetFocus();
|
||||
ChangeLang();
|
||||
}
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 75, Game.singleton.ScreenHeight / 2 + 70, 150, 40), Game.singleton.GUI.content.GetBox("Default"), Game.singleton.multilang.GetWord("Back", Game.singleton.config.lang),Game.singleton.GUI.content.GetFont("basic"), new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 75, Game.singleton.ScreenHeight / 2 + 70, 150, 40), Game.singleton.GUI.content.GetBox("Default"), Game.singleton.multilang.GetWord("Back", Game.singleton.config.lang), Game.singleton.GUI.content.GetFont("basic"), new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MyCommon;
|
||||
using MyMonoGame.GUI;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -77,14 +77,14 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
ResultData res = Game.singleton.client.Request(new string[4] { "party", "create", party, count.ToString() });
|
||||
if (res.type == ResultTypes.OK)
|
||||
{
|
||||
Game.singleton.logger.Write("Create party " + Common.ArrayToString(res.result), Logger.logType.info);
|
||||
Game.singleton.logger.Write("Create party " + Strings.ArrayToString(res.result), Logger.logType.info);
|
||||
Game.singleton.gameState = new GameState();
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.singleton.logger.Write("Create error " + Common.ArrayToString(res.result), Logger.logType.error);
|
||||
Game.singleton.logger.Write("Create error " + Strings.ArrayToString(res.result), Logger.logType.error);
|
||||
message.title = Game.singleton.multilang.GetWord("Error", Game.singleton.config.lang);
|
||||
message.text = Common.ArrayToString(res.result);
|
||||
message.text = Strings.ArrayToString(res.result);
|
||||
showOKMessage = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MyCommon;
|
||||
using MyMonoGame.GUI;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
@ -154,9 +154,9 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
}
|
||||
else
|
||||
{
|
||||
Game.singleton.logger.Write("Join error " + Common.ArrayToString(res.result), Logger.logType.error);
|
||||
Game.singleton.logger.Write("Join error " + Strings.ArrayToString(res.result), Logger.logType.error);
|
||||
message.title = Game.singleton.multilang.GetWord("Error", Game.singleton.config.lang);
|
||||
message.text = Common.ArrayToString(res.result);
|
||||
message.text = Strings.ArrayToString(res.result);
|
||||
showOKMessage = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -19,7 +19,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
|
||||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
Utilities.Broadcast(new EventData(EventTypes.ChatMessage, Common.Strings("Server : " + args[1])));
|
||||
Utilities.Broadcast(new EventData(EventTypes.ChatMessage, Strings.ArrayFromStrings("Server : " + args[1])));
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
using Console = MyConsole.ConsoleIO;
|
||||
using Console = MyCommon.ConsoleIO;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("ClientSide"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -19,7 +19,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
|
||||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(Server.clients.Count.ToString(), Server.config.size.ToString()));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(Server.clients.Count.ToString(), Server.config.size.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -25,12 +25,12 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
if (Utilities.GetName(client) == args[2]) { target = client; }
|
||||
}
|
||||
if (target == null)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("CantFind"));
|
||||
|
||||
Server.logger.Write(args[2] + " was kick by server.", Logger.logType.info, Logger.logConsole.show);
|
||||
if (args.Length > 2)
|
||||
{
|
||||
Utilities.Send(target, new EventData(EventTypes.ServerKick, Common.Strings(args[3])));
|
||||
Utilities.Send(target, new EventData(EventTypes.ServerKick, Strings.ArrayFromStrings(args[3])));
|
||||
Server.logger.Write("because" + args[3], Logger.logType.debug);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
text += (Utilities.GetName(socket) + ", ");
|
||||
}
|
||||
text = text.Remove(text.Length - 2, 2);
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(text));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(text));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
if (Utilities.GetName(client) == args[2]) { target = client; }
|
||||
}
|
||||
if (target == null)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("CantFind"));
|
||||
|
||||
string text = "";
|
||||
text += ("Name : " + Utilities.GetName(target) + Environment.NewLine);
|
||||
|
@ -36,7 +36,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
text += ("Party : " + Server.clients[target].party + Environment.NewLine);
|
||||
}
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(text));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(text));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
@ -21,13 +21,13 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (Utilities.IsConnect(soc))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Connected"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Connected"));
|
||||
|
||||
if (args[2] != Protocol.version.ToString()) //Check client protocol version
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Version", Protocol.version.ToString()));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Version", Protocol.version.ToString()));
|
||||
|
||||
if (args[1].Length < 3)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("TooShort"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("TooShort"));
|
||||
|
||||
Server.logger.Write("Identifiaction request from " + Utilities.GetName(soc), Logger.logType.debug);
|
||||
bool allreadyconnected = false;
|
||||
|
@ -37,16 +37,16 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
if (client.pseudo == args[1]) { allreadyconnected = true; break; }
|
||||
}
|
||||
if (allreadyconnected)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("AllreadyTaken"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("AllreadyTaken"));
|
||||
|
||||
lock (Server.clients_lock)
|
||||
{
|
||||
Server.clients[soc].status = 0;
|
||||
Server.clients[soc].pseudo = args[1];
|
||||
}
|
||||
Utilities.Broadcast(new EventData(EventTypes.ServerJoin, Common.Strings(args[1])));
|
||||
Utilities.Broadcast(new EventData(EventTypes.ServerJoin, Strings.ArrayFromStrings(args[1])));
|
||||
Server.logger.Write("Identified as " + Utilities.GetName(soc) + " form " + ((IPEndPoint)soc.LocalEndPoint).Address.ToString(), Logger.logType.info);
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(args[1]));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(args[1]));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -59,19 +59,19 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
text += (" " + (com.Group != 0 ? new string(' ', 4) : "") + com.Name + new string(' ', maxLen - com.Name.Length - (com.Group == 0 ? 0 : 4)) + " : " + com.DescText + Environment.NewLine);
|
||||
}
|
||||
}
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(text));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(text));
|
||||
}
|
||||
else
|
||||
{
|
||||
ICommand command = null;
|
||||
args = args.Skip(1).ToArray();
|
||||
if (!Manager.TryGetCommand(args, ref command))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("AnyCommand"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("AnyCommand"));
|
||||
|
||||
if (!Manager.CanAccess(command, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("AnyCommand"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("AnyCommand"));
|
||||
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(command.HelpText));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(command.HelpText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
@ -23,11 +23,11 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
if (Enum.TryParse(args[1], true, out Server.config.logLevel))
|
||||
{
|
||||
Server.logger.ChangeLevel(Server.config.logLevel);
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(Server.config.logLevel.ToString()));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(Server.config.logLevel.ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("IncorrectArgs"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("IncorrectArgs"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -14,7 +14,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
|
||||
public enum CommandGroup { root, server, party, client }
|
||||
|
||||
private static RequestResult AnyCommand = new RequestResult(ResultTypes.Error, Common.Strings("AnyCommand"));
|
||||
private static RequestResult AnyCommand = new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("AnyCommand"));
|
||||
|
||||
/// <summary>
|
||||
/// Find all ICommand and add them to commands
|
||||
|
@ -46,7 +46,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
return AnyCommand;
|
||||
|
||||
if (!server && command.IsClientSide)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("ClientSide"));
|
||||
|
||||
if (args.Length - (command.Group == 0 ? 0 : 1) <= command.minArgs)
|
||||
return new RequestResult(ResultTypes.Error, new string[2] { "TooShort", command.minArgs.ToString() });
|
||||
|
@ -61,7 +61,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
catch (Exception e)
|
||||
{
|
||||
Server.logger.Write("Command " + args[0] + " Exception : " + e.Message, Logger.logType.error);
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("ExecuteException"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("ExecuteException"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -21,7 +21,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, false, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
string[] data = new string[Server.parties[partyId].clients.Count];
|
||||
int i = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -21,10 +21,10 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, true, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
if (!Server.parties[partyId].open)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Allready"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Allready"));
|
||||
|
||||
Server.parties[partyId].open = false;
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -20,20 +20,20 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (!server && Server.clients[soc].partyID != -1)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Allready"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Allready"));
|
||||
|
||||
int size;
|
||||
if (!int.TryParse(args[3], out size))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Format"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Format"));
|
||||
|
||||
if (size < 1)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("TooSmall"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("TooSmall"));
|
||||
|
||||
if (size > Server.config.size)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("TooBig"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("TooBig"));
|
||||
|
||||
if (Server.parties.Count >= Server.config.partysize)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Full"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Full"));
|
||||
|
||||
Server.AddParty(new Party(args[2], size, Utilities.GetName(soc)));
|
||||
Server.logger.Write("Party " + args[2] + " create with " + size + " slots as " + Server.GetPartyID(false), Logger.logType.info);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
@ -21,14 +21,14 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if ((server && Server.selectedParty != -1) || (!server && Server.clients[soc].partyID != -1))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Allready"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Allready"));
|
||||
|
||||
int id;
|
||||
if (!int.TryParse(args[2], out id))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Format"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Format"));
|
||||
|
||||
if (!Server.parties.ContainsKey(id))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("CantFind"));
|
||||
|
||||
Party party = Server.parties[id];
|
||||
if (args.Length == 3)
|
||||
|
@ -37,7 +37,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
args[3] = "";
|
||||
}
|
||||
if (!server && !party.TestPassword(args[3]))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Password"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Password"));
|
||||
|
||||
if (server)
|
||||
{
|
||||
|
@ -47,13 +47,13 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
else
|
||||
{
|
||||
if (!party.open)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Close"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Close"));
|
||||
|
||||
if (party.clients.Count + 1 > party.size)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Full"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Full"));
|
||||
|
||||
Server.clients[soc].partyID = id;
|
||||
Utilities.BroadcastParty(new EventData(EventTypes.PartyJoin, Common.Strings(Utilities.GetName(soc))), id);
|
||||
Utilities.BroadcastParty(new EventData(EventTypes.PartyJoin, Strings.ArrayFromStrings(Utilities.GetName(soc))), id);
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -21,7 +21,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, true, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
Socket target = null;
|
||||
foreach (Socket client in Server.parties[partyId].clients)
|
||||
|
@ -29,9 +29,9 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
if (Utilities.GetName(client) == args[2]) { target = client; }
|
||||
}
|
||||
if (target == null)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("CantFind"));
|
||||
|
||||
Utilities.Send(target, new EventData(EventTypes.PartyKick, args.Length > 3 ? Common.Strings(args[2]) : null));
|
||||
Utilities.Send(target, new EventData(EventTypes.PartyKick, args.Length > 3 ? Strings.ArrayFromStrings(args[2]) : null));
|
||||
return Manager.Execute(new string[2] { "party", "leave" }, target, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -28,13 +28,13 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, false, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
if (Server.parties[partyId].IsOwner(Utilities.GetName(soc)))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Owner"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Owner"));
|
||||
|
||||
Server.clients[soc].partyID = -1;
|
||||
Utilities.BroadcastParty(new EventData(EventTypes.PartyLeave, Common.Strings(Utilities.GetName(soc))), partyId);
|
||||
Utilities.BroadcastParty(new EventData(EventTypes.PartyLeave, Strings.ArrayFromStrings(Utilities.GetName(soc))), partyId);
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -20,7 +20,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (Server.parties.Keys.Count == 0)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("AnyParty"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("AnyParty"));
|
||||
|
||||
string[] text = new string[Server.parties.Keys.Count];
|
||||
int i = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -21,10 +21,10 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, true, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
if (Server.parties[partyId].open)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Allready"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Allready"));
|
||||
|
||||
Server.parties[partyId].open = true;
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, true, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
if (args.Length == 3)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
}
|
||||
|
||||
if (!Server.parties[partyId].SetPassword(args[2], args[3]))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Password"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Password"));
|
||||
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, false, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
Party party = Server.parties[partyId];
|
||||
if (server)
|
||||
|
@ -31,7 +31,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
text += ("Name: " + party.name + Environment.NewLine);
|
||||
text += ("Count: " + party.count + "/" + party.size + Environment.NewLine);
|
||||
text += ("Status: " + (party.isPrivate ? "private" : (party.open ? "open" : "close")));
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(text));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(text));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -21,7 +21,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
int partyId = -1;
|
||||
if (!Utilities.AccessParty(ref partyId, args, true, soc, server))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Access"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Access"));
|
||||
|
||||
foreach (Socket client in Server.parties[partyId].clients)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -19,7 +19,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
|
||||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("ClientSide"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -20,14 +20,14 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (args[1].Length == 0)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("AnyMessage"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("AnyMessage"));
|
||||
|
||||
if (!Utilities.IsConnect(soc))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("MustBeConnected"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("MustBeConnected"));
|
||||
|
||||
int party = -1;
|
||||
party = Utilities.GetParty(soc);
|
||||
Utilities.BroadcastParty(new EventData(EventTypes.ChatMessage, Common.Strings(Utilities.GetName(soc) + " : " + args[1])), party);
|
||||
Utilities.BroadcastParty(new EventData(EventTypes.ChatMessage, Strings.ArrayFromStrings(Utilities.GetName(soc) + " : " + args[1])), party);
|
||||
return new RequestResult(ResultTypes.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -20,7 +20,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (!Server._open)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Allready"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Allready"));
|
||||
|
||||
Server._open = false;
|
||||
Server.logger.Write("Server closed", Logger.logType.warm, Logger.logConsole.show);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -20,7 +20,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (Server._open)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Allready"));
|
||||
return new RequestResult(ResultTypes.Error, Strings.ArrayFromStrings("Allready"));
|
||||
|
||||
Server._open = true;
|
||||
Server.logger.Write("Server opened", Logger.logType.warm, Logger.logConsole.show);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Galactic_Colors_Control_Server.Commands
|
||||
|
@ -23,7 +23,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
text += "Server : " + (Server._open ? "open" : "close");
|
||||
text += "Clients : " + Server.clients.Count + "/" + Server.config.size;
|
||||
text += "Parties : " + Server.parties.Count;
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(text));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(text));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
|
||||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
return new RequestResult(ResultTypes.OK, Common.Strings(DateTime.Now.ToLongTimeString()));
|
||||
return new RequestResult(ResultTypes.OK, Strings.ArrayFromStrings(DateTime.Now.ToLongTimeString()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
|
|
@ -52,9 +52,6 @@
|
|||
<Reference Include="MyCommon">
|
||||
<HintPath>..\..\MyCommon\MyCommon\bin\Release\MyCommon.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MyConsole">
|
||||
<HintPath>..\..\MyConsole\MyConsole\bin\Release\MyConsole.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -7,9 +8,7 @@ using System.Net;
|
|||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using MyCommon;
|
||||
using Console = MyConsole.ConsoleIO;
|
||||
using MyConsole;
|
||||
using Console = MyCommon.ConsoleIO;
|
||||
|
||||
//TODO gui parties pages
|
||||
|
||||
|
@ -102,7 +101,7 @@ namespace Galactic_Colors_Control_Server
|
|||
while (_run)
|
||||
{
|
||||
string ConsoleInput = Console.Read();
|
||||
string[] args = Common.SplitArgs(ConsoleInput);
|
||||
string[] args = Strings.SplitArgs(ConsoleInput);
|
||||
Console.Write(new ColorStrings(Parser.GetResultText(new ResultData(-1, Commands.Manager.Execute(args, null, true)), config.lang, multilang)));
|
||||
ConsoleInput = null;
|
||||
}
|
||||
|
@ -114,7 +113,7 @@ namespace Galactic_Colors_Control_Server
|
|||
private static void CloseAllSockets()
|
||||
{
|
||||
logger.Write("Stoping server", Logger.logType.warm, Logger.logConsole.show);
|
||||
Utilities.Broadcast(new EventData(EventTypes.ServerKick, Common.Strings("Close")));
|
||||
Utilities.Broadcast(new EventData(EventTypes.ServerKick, Strings.ArrayFromStrings("Close")));
|
||||
config.Save();
|
||||
foreach (Socket socket in clients.Keys)
|
||||
{
|
||||
|
@ -151,14 +150,14 @@ namespace Galactic_Colors_Control_Server
|
|||
else
|
||||
{
|
||||
logger.Write("Client can't join from " + ((IPEndPoint)socket.LocalEndPoint).Address.ToString() + " no more space", Logger.logType.warm);
|
||||
Utilities.Send(socket, new EventData(EventTypes.ServerKick, Common.Strings("Space")));
|
||||
Utilities.Send(socket, new EventData(EventTypes.ServerKick, Strings.ArrayFromStrings("Space")));
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Write("Client can't join from " + ((IPEndPoint)socket.LocalEndPoint).Address.ToString() + " server closed", Logger.logType.info);
|
||||
Utilities.Send(socket, new EventData(EventTypes.ServerKick, Common.Strings("Close")));
|
||||
Utilities.Send(socket, new EventData(EventTypes.ServerKick, Strings.ArrayFromStrings("Close")));
|
||||
socket.Close();
|
||||
}
|
||||
serverSocket.BeginAccept(AcceptCallback, null);
|
||||
|
@ -273,7 +272,7 @@ namespace Galactic_Colors_Control_Server
|
|||
logger.Write("Size: " + clients.Count + "/" + config.size, Logger.logType.debug);
|
||||
current.Close(); // Don't shutdown because the socket may be disposed and its disconnected anyway.
|
||||
clients.Remove(current);
|
||||
if (connected) { Utilities.Broadcast(new EventData(EventTypes.ServerLeave, Common.Strings(username))); }
|
||||
if (connected) { Utilities.Broadcast(new EventData(EventTypes.ServerLeave, Strings.ArrayFromStrings(username))); }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Console = MyConsole.ConsoleIO;
|
||||
using MyConsole;
|
||||
using Console = MyCommon.ConsoleIO;
|
||||
|
||||
namespace Galactic_Colors_Control_Server
|
||||
{
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MyCommon, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\MyCommon\MyCommon\bin\Release\MyCommon.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Galactic_Colors_Control_Common;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using MyCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -203,7 +203,7 @@ namespace Galactic_Colors_Control
|
|||
RequestData req = new RequestData(GetRequestId(), args);
|
||||
|
||||
if (!Send(req))
|
||||
return new ResultData(req.id, ResultTypes.Error, Common.Strings("Send Exception"));
|
||||
return new ResultData(req.id, ResultTypes.Error, Strings.ArrayFromStrings("Send Exception"));
|
||||
|
||||
DateTime timeoutDate = DateTime.Now.AddMilliseconds(config.timeout); //Create timeout DataTime
|
||||
|
||||
|
@ -221,7 +221,7 @@ namespace Galactic_Colors_Control
|
|||
}
|
||||
}
|
||||
}
|
||||
return new ResultData(req.id, ResultTypes.Error, Common.Strings("Timeout"));
|
||||
return new ResultData(req.id, ResultTypes.Error, Strings.ArrayFromStrings("Timeout"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -235,9 +235,9 @@ namespace Galactic_Colors_Control
|
|||
|
||||
reply = ping.Send(IP);
|
||||
if (reply.Status == IPStatus.Success)
|
||||
return new ResultData(GetRequestId(), ResultTypes.OK, Common.SplitArgs(reply.RoundtripTime.ToString() + "ms"));
|
||||
return new ResultData(GetRequestId(), ResultTypes.OK, Strings.SplitArgs(reply.RoundtripTime.ToString() + "ms"));
|
||||
|
||||
return new ResultData(GetRequestId(), ResultTypes.Error, Common.SplitArgs("Timeout"));
|
||||
return new ResultData(GetRequestId(), ResultTypes.Error, Strings.SplitArgs("Timeout"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Reference in New Issue