Added NightAlert project for travel kit
This commit is contained in:
48
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global.cs
vendored
Normal file
48
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global.cs
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static string EncodeURIComponent(string str)
|
||||
{
|
||||
//http://stackoverflow.com/a/4550600/1109316
|
||||
return Uri.EscapeDataString(str);
|
||||
}
|
||||
|
||||
public static string DecodeURIComponent(string str)
|
||||
{
|
||||
return Uri.UnescapeDataString(str);
|
||||
}
|
||||
|
||||
public static string CallerName([CallerMemberName]string caller = "", [CallerLineNumber]int number = 0, [CallerFilePath]string path = "")
|
||||
{
|
||||
var s = path.Split('\\');
|
||||
var fileName = s.LastOrDefault();
|
||||
if (path.Contains("SocketIoClientDotNet.Tests"))
|
||||
{
|
||||
path = "SocketIoClientDotNet.Tests";
|
||||
}
|
||||
else if (path.Contains("SocketIoClientDotNet"))
|
||||
{
|
||||
path = "SocketIoClientDotNet";
|
||||
}
|
||||
else if (path.Contains("EngineIoClientDotNet"))
|
||||
{
|
||||
path = "EngineIoClientDotNet";
|
||||
}
|
||||
|
||||
return string.Format("{0}-{1}:{2}#{3}",path, fileName, caller, number);
|
||||
}
|
||||
|
||||
//from http://stackoverflow.com/questions/8767103/how-to-remove-invalid-code-points-from-a-string
|
||||
public static string StripInvalidUnicodeCharacters(string str)
|
||||
{
|
||||
var invalidCharactersRegex = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])");
|
||||
return invalidCharactersRegex.Replace(str, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
49
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global_net35.cs
vendored
Normal file
49
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global_net35.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static string EncodeURIComponent(string str)
|
||||
{
|
||||
//http://stackoverflow.com/a/4550600/1109316
|
||||
return Uri.EscapeDataString(str);
|
||||
}
|
||||
|
||||
public static string DecodeURIComponent(string str)
|
||||
{
|
||||
return Uri.UnescapeDataString(str);
|
||||
}
|
||||
|
||||
public static string CallerName(string caller = "", int number = 0, string path = "")
|
||||
{
|
||||
var s = path.Split('\\');
|
||||
var fileName = s.LastOrDefault();
|
||||
if (path.Contains("SocketIoClientDotNet.Tests"))
|
||||
{
|
||||
path = "SocketIoClientDotNet.Tests";
|
||||
}
|
||||
else if (path.Contains("SocketIoClientDotNet"))
|
||||
{
|
||||
path = "SocketIoClientDotNet";
|
||||
}
|
||||
else if (path.Contains("EngineIoClientDotNet"))
|
||||
{
|
||||
path = "EngineIoClientDotNet";
|
||||
}
|
||||
|
||||
return string.Format("{0}-{1}:{2}#{3}",path, fileName, caller, number);
|
||||
}
|
||||
|
||||
//from http://stackoverflow.com/questions/8767103/how-to-remove-invalid-code-points-from-a-string
|
||||
public static string StripInvalidUnicodeCharacters(string str)
|
||||
{
|
||||
var invalidCharactersRegex = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])");
|
||||
return invalidCharactersRegex.Replace(str, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
177
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global_netcore45.cs
vendored
Normal file
177
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global_netcore45.cs
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static string EncodeURIComponent(string str)
|
||||
{
|
||||
//http://stackoverflow.com/a/4550600/1109316
|
||||
return Uri.EscapeDataString(str);
|
||||
}
|
||||
|
||||
public static string DecodeURIComponent(string str)
|
||||
{
|
||||
return Uri.UnescapeDataString(str);
|
||||
}
|
||||
|
||||
public static string CallerName([CallerMemberName]string caller = "", [CallerLineNumber]int number = 0, [CallerFilePath]string path = "")
|
||||
{
|
||||
var s = path.Split('\\');
|
||||
var fileName = s.LastOrDefault();
|
||||
if (path.Contains("SocketIoClientDotNet.Tests"))
|
||||
{
|
||||
path = "SocketIoClientDotNet.Tests";
|
||||
}
|
||||
else if (path.Contains("SocketIoClientDotNet"))
|
||||
{
|
||||
path = "SocketIoClientDotNet";
|
||||
}
|
||||
else if (path.Contains("EngineIoClientDotNet"))
|
||||
{
|
||||
path = "EngineIoClientDotNet";
|
||||
}
|
||||
|
||||
return string.Format("{0}-{1}:{2}#{3}", path, fileName, caller, number);
|
||||
}
|
||||
|
||||
//from http://stackoverflow.com/questions/8767103/how-to-remove-invalid-code-points-from-a-string
|
||||
public static string StripInvalidUnicodeCharacters(string str)
|
||||
{
|
||||
var invalidCharactersRegex = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])");
|
||||
return invalidCharactersRegex.Replace(str, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// from http://social.msdn.microsoft.com/Forums/en-US/163ef755-ff7b-4ea5-b226-bbe8ef5f4796/is-there-a-pattern-for-calling-an-async-method-synchronously?forum=async
|
||||
public static class AsyncInline
|
||||
{
|
||||
public static void Run(Func<Task> item)
|
||||
{
|
||||
var oldContext = SynchronizationContext.Current;
|
||||
var synch = new ExclusiveSynchronizationContext();
|
||||
SynchronizationContext.SetSynchronizationContext(synch);
|
||||
synch.Post(async _ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await item();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
synch.InnerException = e;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
synch.EndMessageLoop();
|
||||
}
|
||||
}, null);
|
||||
synch.BeginMessageLoop();
|
||||
SynchronizationContext.SetSynchronizationContext(oldContext);
|
||||
}
|
||||
|
||||
public static T Run<T>(Func<Task<T>> item)
|
||||
{
|
||||
var oldContext = SynchronizationContext.Current;
|
||||
var synch = new ExclusiveSynchronizationContext();
|
||||
SynchronizationContext.SetSynchronizationContext(synch);
|
||||
T ret = default(T);
|
||||
synch.Post(async _ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ret = await
|
||||
item();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
synch.InnerException = e;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
synch.EndMessageLoop();
|
||||
}
|
||||
}, null);
|
||||
synch.BeginMessageLoop();
|
||||
SynchronizationContext.SetSynchronizationContext(oldContext);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private class ExclusiveSynchronizationContext : SynchronizationContext
|
||||
{
|
||||
private bool done;
|
||||
public Exception InnerException { get; set; }
|
||||
readonly AutoResetEvent workItemsWaiting = new AutoResetEvent(false);
|
||||
readonly Queue<Tuple<SendOrPostCallback, object>> items =
|
||||
new Queue<Tuple<SendOrPostCallback, object>>();
|
||||
|
||||
public override void Send(SendOrPostCallback d, object state)
|
||||
{
|
||||
throw new NotSupportedException("We cannot send to our same thread");
|
||||
}
|
||||
public override void Post(SendOrPostCallback d, object state)
|
||||
{
|
||||
lock (items)
|
||||
{
|
||||
items.Enqueue(Tuple.Create(d, state));
|
||||
}
|
||||
workItemsWaiting.Set();
|
||||
}
|
||||
public void EndMessageLoop()
|
||||
{
|
||||
Post(_ => done = true, null);
|
||||
}
|
||||
public void BeginMessageLoop()
|
||||
{
|
||||
while (!done)
|
||||
{
|
||||
Tuple<SendOrPostCallback, object> task = null;
|
||||
lock (items)
|
||||
{
|
||||
if (items.Count > 0)
|
||||
{
|
||||
task = items.Dequeue();
|
||||
}
|
||||
}
|
||||
if (task != null)
|
||||
{
|
||||
task.Item1(task.Item2);
|
||||
if (InnerException != null) // the method threw an exeption
|
||||
{
|
||||
throw new AggregateException("AsyncInline.Run method threw an exception.",
|
||||
InnerException);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
workItemsWaiting.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override SynchronizationContext CreateCopy()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
51
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global_windowsphone8.cs
vendored
Normal file
51
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/Global_windowsphone8.cs
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static string EncodeURIComponent(string str)
|
||||
{
|
||||
//http://stackoverflow.com/a/4550600/1109316
|
||||
return Uri.EscapeDataString(str);
|
||||
}
|
||||
|
||||
public static string DecodeURIComponent(string str)
|
||||
{
|
||||
return Uri.UnescapeDataString(str);
|
||||
}
|
||||
|
||||
public static string CallerName([CallerMemberName]string caller = "", [CallerLineNumber]int number = 0, [CallerFilePath]string path = "")
|
||||
{
|
||||
var s = path.Split('\\');
|
||||
var fileName = s.LastOrDefault();
|
||||
if (path.Contains("SocketIoClientDotNet.Tests"))
|
||||
{
|
||||
path = "SocketIoClientDotNet.Tests";
|
||||
}
|
||||
else if (path.Contains("SocketIoClientDotNet"))
|
||||
{
|
||||
path = "SocketIoClientDotNet";
|
||||
}
|
||||
else if (path.Contains("EngineIoClientDotNet"))
|
||||
{
|
||||
path = "EngineIoClientDotNet";
|
||||
}
|
||||
|
||||
return string.Format("{0}-{1}:{2}#{3}", path, fileName, caller, number);
|
||||
}
|
||||
|
||||
//from http://stackoverflow.com/questions/8767103/how-to-remove-invalid-code-points-from-a-string
|
||||
public static string StripInvalidUnicodeCharacters(string str)
|
||||
{
|
||||
var invalidCharactersRegex = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])");
|
||||
return invalidCharactersRegex.Replace(str, "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
109
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/LogManager.cs
vendored
Normal file
109
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/LogManager.cs
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public class LogManager
|
||||
{
|
||||
private const string LogFilePath = "XunitTrace.log";
|
||||
|
||||
private static readonly LogManager EmptyLogger = new LogManager(null);
|
||||
|
||||
private static StreamWriter writer;
|
||||
|
||||
private readonly string type;
|
||||
|
||||
#region Statics
|
||||
|
||||
public static void SetupLogManager()
|
||||
{}
|
||||
|
||||
public static LogManager GetLogger(string type)
|
||||
{
|
||||
return new LogManager(type);
|
||||
}
|
||||
|
||||
public static LogManager GetLogger(Type type)
|
||||
{
|
||||
return GetLogger(type.ToString());
|
||||
}
|
||||
|
||||
public static LogManager GetLogger(MethodBase methodBase)
|
||||
{
|
||||
#if DEBUG
|
||||
string declaringType = methodBase.DeclaringType != null
|
||||
? methodBase.DeclaringType.ToString()
|
||||
: string.Empty;
|
||||
string fullType = string.Format("{0}#{1}", declaringType, methodBase.Name);
|
||||
return GetLogger(fullType);
|
||||
#else
|
||||
return EmptyLogger;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public LogManager(string type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static bool Enabled { get; set; }
|
||||
|
||||
private static StreamWriter Writer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
FileStream fs = new FileStream(
|
||||
LogFilePath, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
writer = new StreamWriter(fs, Encoding.UTF8)
|
||||
{
|
||||
AutoFlush = true
|
||||
};
|
||||
}
|
||||
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Info(string msg)
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Writer.WriteLine(
|
||||
"{0:yyyy-MM-dd HH:mm:ss fff} [] {1} {2}",
|
||||
DateTime.Now,
|
||||
this.type,
|
||||
Global.StripInvalidUnicodeCharacters(msg));
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Error(string p, Exception exception)
|
||||
{
|
||||
//this.Info($"ERROR {p} {exception.Message} {exception.StackTrace}");
|
||||
this.Info(String.Format("ERROR {0} {1} {2}", p, exception.Message, exception.StackTrace));
|
||||
if (exception.InnerException != null)
|
||||
{
|
||||
//this.Info($"ERROR exception.InnerException {p} {exception.InnerException.Message} {exception.InnerException.StackTrace}");
|
||||
this.Info(String.Format("ERROR {0} {1} {2} {3}", exception.InnerException, p,
|
||||
exception.InnerException.Message, exception.InnerException.StackTrace));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal void Error(Exception e)
|
||||
{
|
||||
this.Error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/ParseQS.cs
vendored
Normal file
79
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/ParseQS.cs
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
/// <remarks>
|
||||
/// Provides methods for parsing a query string into an object, and vice versa.
|
||||
/// Ported from the JavaScript module.
|
||||
/// <see href="https://www.npmjs.org/package/parseqs">https://www.npmjs.org/package/parseqs</see>
|
||||
/// </remarks>
|
||||
public class ParseQS
|
||||
{
|
||||
/// <summary>
|
||||
/// Compiles a querystring
|
||||
/// Returns string representation of the object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string Encode(ImmutableDictionary<string, string> obj)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var key in obj.Keys.OrderBy(x=>x))
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Append("&");
|
||||
}
|
||||
sb.Append(Global.EncodeURIComponent(key));
|
||||
sb.Append("=");
|
||||
sb.Append(Global.EncodeURIComponent(obj[key]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles a querystring
|
||||
/// Returns string representation of the object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
internal static string Encode(System.Collections.Generic.Dictionary<string, string> obj)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var key in obj.Keys)
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Append("&");
|
||||
}
|
||||
sb.Append(Global.EncodeURIComponent(key));
|
||||
sb.Append("=");
|
||||
sb.Append(Global.EncodeURIComponent(obj[key]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a simple querystring into an object
|
||||
/// </summary>
|
||||
/// <param name="qs"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> Decode(string qs)
|
||||
{
|
||||
var qry = new Dictionary<string, string>();
|
||||
var pairs = qs.Split('&');
|
||||
for (int i = 0; i < pairs.Length; i++)
|
||||
{
|
||||
var pair = pairs[i].Split('=');
|
||||
|
||||
qry.Add(Global.DecodeURIComponent(pair[0]), Global.DecodeURIComponent(pair[1]));
|
||||
}
|
||||
return qry;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
82
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/ParseQS_net35.cs
vendored
Normal file
82
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/ParseQS_net35.cs
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
/// <remarks>
|
||||
/// Provides methods for parsing a query string into an object, and vice versa.
|
||||
/// Ported from the JavaScript module.
|
||||
/// <see href="https://www.npmjs.org/package/parseqs">https://www.npmjs.org/package/parseqs</see>
|
||||
/// </remarks>
|
||||
public class ParseQS
|
||||
{
|
||||
/// <summary>
|
||||
/// Compiles a querystring
|
||||
/// Returns string representation of the object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string Encode(ConcurrentDictionary<string, string> obj)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var key in obj.Keys.OrderBy(x=>x))
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Append("&");
|
||||
}
|
||||
sb.Append(Global.EncodeURIComponent(key));
|
||||
sb.Append("=");
|
||||
sb.Append(Global.EncodeURIComponent(obj[key]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles a querystring
|
||||
/// Returns string representation of the object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
internal static string Encode(System.Collections.Generic.Dictionary<string, string> obj)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var key in obj.Keys)
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Append("&");
|
||||
}
|
||||
sb.Append(Global.EncodeURIComponent(key));
|
||||
sb.Append("=");
|
||||
sb.Append(Global.EncodeURIComponent(obj[key]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a simple querystring into an object
|
||||
/// </summary>
|
||||
/// <param name="qs"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> Decode(string qs)
|
||||
{
|
||||
var qry = new Dictionary<string, string>();
|
||||
var pairs = qs.Split('&');
|
||||
for (int i = 0; i < pairs.Length; i++)
|
||||
{
|
||||
var pair = pairs[i].Split('=');
|
||||
|
||||
qry.Add(Global.DecodeURIComponent(pair[0]), Global.DecodeURIComponent(pair[1]));
|
||||
}
|
||||
return qry;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/ServerCertificate.cs
vendored
Normal file
20
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/ServerCertificate.cs
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Net;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public class ServerCertificate
|
||||
{
|
||||
public static bool Ignore { get; set; }
|
||||
|
||||
static ServerCertificate()
|
||||
{
|
||||
Ignore = false;
|
||||
}
|
||||
|
||||
public static void IgnoreServerCertificateValidation()
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
Ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public class ServerCertificate
|
||||
{
|
||||
public static bool Ignore { get; set; }
|
||||
|
||||
static ServerCertificate()
|
||||
{
|
||||
Ignore = false;
|
||||
}
|
||||
|
||||
public static void IgnoreServerCertificateValidation()
|
||||
{
|
||||
//ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
Ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public class ServerCertificate
|
||||
{
|
||||
public static bool Ignore { get; set; }
|
||||
|
||||
static ServerCertificate()
|
||||
{
|
||||
Ignore = false;
|
||||
}
|
||||
|
||||
public static void IgnoreServerCertificateValidation()
|
||||
{
|
||||
Ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public class ServerCertificate
|
||||
{
|
||||
public static bool Ignore { get; set; }
|
||||
|
||||
static ServerCertificate()
|
||||
{
|
||||
Ignore = false;
|
||||
}
|
||||
|
||||
public static void IgnoreServerCertificateValidation()
|
||||
{
|
||||
//ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
Ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
228
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/UTF8.cs
vendored
Normal file
228
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/UTF8.cs
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
/// <remarks>
|
||||
/// UTF-8 encoder/decoder ported from utf8.js.
|
||||
/// Ported from the JavaScript module.
|
||||
/// <see href="https://github.com/mathiasbynens/utf8.js">https://github.com/mathiasbynens/utf8.js</see>
|
||||
/// </remarks>
|
||||
public class UTF8
|
||||
{
|
||||
private static List<int> byteArray;
|
||||
private static int byteCount;
|
||||
private static int byteIndex;
|
||||
|
||||
public static string Encode(string str)
|
||||
{
|
||||
List<int> codePoints = Ucs2Decode(str);
|
||||
var length = codePoints.Count;
|
||||
var index = -1;
|
||||
var byteString = new StringBuilder();
|
||||
while (++index < length)
|
||||
{
|
||||
var codePoint = codePoints[index];
|
||||
byteString.Append(EncodeCodePoint(codePoint));
|
||||
}
|
||||
return byteString.ToString();
|
||||
}
|
||||
|
||||
public static string Decode(string byteString)
|
||||
{
|
||||
byteArray = Ucs2Decode(byteString);
|
||||
byteCount = byteArray.Count;
|
||||
byteIndex = 0;
|
||||
|
||||
var codePoints = new List<int>();
|
||||
int tmp;
|
||||
while ((tmp = DecodeSymbol()) != -1)
|
||||
{
|
||||
codePoints.Add(tmp);
|
||||
}
|
||||
return Ucs2Encode(codePoints);
|
||||
}
|
||||
|
||||
private static int DecodeSymbol()
|
||||
{
|
||||
int byte1;
|
||||
int byte2;
|
||||
int byte3;
|
||||
int byte4;
|
||||
int codePoint;
|
||||
|
||||
if (byteIndex > byteCount)
|
||||
{
|
||||
throw new UTF8Exception("Invalid byte index");
|
||||
}
|
||||
|
||||
if (byteIndex == byteCount)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte1 = byteArray[byteIndex] & 0xFF;
|
||||
byteIndex++;
|
||||
|
||||
if ((byte1 & 0x80) == 0)
|
||||
{
|
||||
return byte1;
|
||||
}
|
||||
|
||||
if ((byte1 & 0xE0) == 0xC0)
|
||||
{
|
||||
byte2 = ReadContinuationByte();
|
||||
codePoint = ((byte1 & 0x1F) << 6) | byte2;
|
||||
if (codePoint >= 0x80)
|
||||
{
|
||||
return codePoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UTF8Exception("Invalid continuation byte");
|
||||
}
|
||||
}
|
||||
|
||||
if ((byte1 & 0xF0) == 0xE0)
|
||||
{
|
||||
byte2 = ReadContinuationByte();
|
||||
byte3 = ReadContinuationByte();
|
||||
codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
|
||||
if (codePoint >= 0x0800)
|
||||
{
|
||||
return codePoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UTF8Exception("Invalid continuation byte");
|
||||
}
|
||||
}
|
||||
|
||||
if ((byte1 & 0xF8) == 0xF0)
|
||||
{
|
||||
byte2 = ReadContinuationByte();
|
||||
byte3 = ReadContinuationByte();
|
||||
byte4 = ReadContinuationByte();
|
||||
codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) | (byte3 << 0x06) | byte4;
|
||||
if (codePoint >= 0x010000 && codePoint <= 0x10FFFF)
|
||||
{
|
||||
return codePoint;
|
||||
}
|
||||
}
|
||||
|
||||
throw new UTF8Exception("Invalid continuation byte");
|
||||
}
|
||||
|
||||
private static int ReadContinuationByte()
|
||||
{
|
||||
if (byteIndex >= byteCount)
|
||||
{
|
||||
throw new UTF8Exception("Invalid byte index");
|
||||
}
|
||||
|
||||
int continuationByte = byteArray[byteIndex] & 0xFF;
|
||||
byteIndex++;
|
||||
|
||||
if ((continuationByte & 0xC0) == 0x80)
|
||||
{
|
||||
return continuationByte & 0x3F;
|
||||
}
|
||||
|
||||
throw new UTF8Exception("Invalid continuation byte");
|
||||
}
|
||||
|
||||
|
||||
private static string EncodeCodePoint(int codePoint)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if ((codePoint & 0xFFFFFF80) == 0)
|
||||
{
|
||||
// 1-byte sequence
|
||||
sb.Append((char) codePoint);
|
||||
return sb.ToString();
|
||||
}
|
||||
if ((codePoint & 0xFFFFF800) == 0)
|
||||
{
|
||||
// 2-byte sequence
|
||||
sb.Append((char) (((codePoint >> 6) & 0x1F) | 0xC0));
|
||||
}
|
||||
else if ((codePoint & 0xFFFF0000) == 0)
|
||||
{
|
||||
// 3-byte sequence
|
||||
sb.Append((char) (((codePoint >> 12) & 0x0F) | 0xE0));
|
||||
sb.Append( CreateByte(codePoint, 6));
|
||||
}
|
||||
else if ((codePoint & 0xFFE00000) == 0)
|
||||
{
|
||||
// 4-byte sequence
|
||||
sb.Append((char) (((codePoint >> 18) & 0x07) | 0xF0));
|
||||
sb.Append( CreateByte(codePoint, 12));
|
||||
sb.Append( CreateByte(codePoint, 6));
|
||||
}
|
||||
sb.Append((char) ((codePoint & 0x3F) | 0x80));
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static char CreateByte(int codePoint, int shift)
|
||||
{
|
||||
return (char)(((codePoint >> shift) & 0x3F) | 0x80);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static List<int> Ucs2Decode(string str)
|
||||
{
|
||||
var output = new List<int>();
|
||||
var counter = 0;
|
||||
var length = str.Length;
|
||||
|
||||
while (counter < length)
|
||||
{
|
||||
var value = (int)str[counter++];
|
||||
|
||||
if (value >= 0xD800 && value <= 0xDBFF && counter < length)
|
||||
{
|
||||
// high surrogate, and there is a next character
|
||||
var extra = (int)str[counter++];
|
||||
if ((extra & 0xFC00) == 0xDC00)
|
||||
{
|
||||
// low surrogate
|
||||
output.Add(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// unmatched surrogate; only append this code unit, in case the next
|
||||
// code unit is the high surrogate of a surrogate pair
|
||||
output.Add(value);
|
||||
counter--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Add(value);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private static string Ucs2Encode(List<int> array)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var index = -1;
|
||||
while (++index < array.Count)
|
||||
{
|
||||
var value = array[index];
|
||||
if (value > 0xFFFF)
|
||||
{
|
||||
value -= 0x10000;
|
||||
sb.Append((char)(((int)((uint)value >> 10)) & 0x3FF | 0xD800));
|
||||
value = 0xDC00 | value & 0x3FF;
|
||||
}
|
||||
sb.Append((char)value);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
10
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/UTF8Exception.cs
vendored
Normal file
10
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.mono/Modules/UTF8Exception.cs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Modules
|
||||
{
|
||||
public class UTF8Exception : Exception
|
||||
{
|
||||
public UTF8Exception(string message) : base(message)
|
||||
{}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user