Added NightAlert project for travel kit
This commit is contained in:
137
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/EngineIoClientDotNet.net35.csproj
vendored
Normal file
137
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/EngineIoClientDotNet.net35.csproj
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{568D67D0-3253-4601-9B04-7730A9EC5CC0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>EngineIoClientDotNet</RootNamespace>
|
||||
<AssemblyName>EngineIoClientDotNet</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>daa4bcba</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net35\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SuperSocket.ClientEngine, Version=0.9.0.0, Culture=neutral, PublicKeyToken=ee9af13f57f00acc, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SuperSocket.ClientEngine.Core.0.9.0\lib\net35-client\SuperSocket.ClientEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Threading.Tasks.NET35, Version=3.0.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Threading.Tasks.Unofficial.3.1\lib\net35\System.Threading.Tasks.NET35.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WebSocket4Net, Version=0.15.1.10, Culture=neutral, PublicKeyToken=eb4e154b696bf72a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\WebSocket4Net.0.15.1\lib\net35\WebSocket4Net.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\EngineIOException.cs">
|
||||
<Link>Client\EngineIOException.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\HandshakeData_net35.cs">
|
||||
<Link>Client\HandshakeData_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\Socket_net35.cs">
|
||||
<Link>Client\Socket_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\Transports\PollingXHR_net35.cs">
|
||||
<Link>Client\Transports\PollingXHR_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\Transports\Polling_net35.cs">
|
||||
<Link>Client\Transports\Polling_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\Transports\WebSocket_net35.cs">
|
||||
<Link>Client\Transports\WebSocket_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Client\Transport_net35.cs">
|
||||
<Link>Client\Transport_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\ComponentEmitter\Emitter_net35.cs">
|
||||
<Link>ComponentEmitter\Emitter_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Modules\Global_net35.cs">
|
||||
<Link>Modules\Global_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Modules\LogManager.cs">
|
||||
<Link>Modules\LogManager.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Modules\ParseQS_net35.cs">
|
||||
<Link>Modules\ParseQS_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Modules\ServerCertificate.cs">
|
||||
<Link>Modules\ServerCertificate.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Modules\UTF8.cs">
|
||||
<Link>Modules\UTF8.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Modules\UTF8Exception.cs">
|
||||
<Link>Modules\UTF8Exception.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Parser\Buffer.cs">
|
||||
<Link>Parser\Buffer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Parser\ByteBuffer.cs">
|
||||
<Link>Parser\ByteBuffer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Parser\IDecodePayloadCallback.cs">
|
||||
<Link>Parser\IDecodePayloadCallback.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Parser\IEncodeCallback.cs">
|
||||
<Link>Parser\IEncodeCallback.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Parser\Parser.cs">
|
||||
<Link>Parser\Parser.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Thread\EasyTimer_net35.cs">
|
||||
<Link>Thread\EasyTimer_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Thread\Heartbeat_net35.cs">
|
||||
<Link>Thread\Heartbeat_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\EngineIoClientDotNet.mono\Thread\TriggeredLoopTimer_net35.cs">
|
||||
<Link>Thread\TriggeredLoopTimer_net35.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Parser\Packet_net35.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
78
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/EngineIoClientDotNet.net35.sln
vendored
Normal file
78
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/EngineIoClientDotNet.net35.sln
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26430.16
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EngineIoClientDotNet.net35", "EngineIoClientDotNet.net35.csproj", "{568D67D0-3253-4601-9B04-7730A9EC5CC0}"
|
||||
EndProject
|
||||
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "grunt(2)", "http://localhost:8528", "{7F5CBDD0-5537-4B8B-AD7E-9F7E88600084}"
|
||||
ProjectSection(WebsiteProperties) = preProject
|
||||
UseIISExpress = "true"
|
||||
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
|
||||
Debug.AspNetCompiler.VirtualPath = "/localhost_8528"
|
||||
Debug.AspNetCompiler.PhysicalPath = "..\..\grunt\"
|
||||
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_8528\"
|
||||
Debug.AspNetCompiler.Updateable = "true"
|
||||
Debug.AspNetCompiler.ForceOverwrite = "true"
|
||||
Debug.AspNetCompiler.FixedNames = "false"
|
||||
Debug.AspNetCompiler.Debug = "True"
|
||||
Release.AspNetCompiler.VirtualPath = "/localhost_8528"
|
||||
Release.AspNetCompiler.PhysicalPath = "..\..\grunt\"
|
||||
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_8528\"
|
||||
Release.AspNetCompiler.Updateable = "true"
|
||||
Release.AspNetCompiler.ForceOverwrite = "true"
|
||||
Release.AspNetCompiler.FixedNames = "false"
|
||||
Release.AspNetCompiler.Debug = "False"
|
||||
SlnRelativePath = "..\..\grunt\"
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EngineIoClientDotNet.Tests.net35", "..\EngineIoClientDotNet.Tests.net35\EngineIoClientDotNet.Tests.net35.csproj", "{BA788BBE-0FE8-4C2F-8A02-457A5E9E2703}"
|
||||
EndProject
|
||||
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "EngineIoClientDotNet", "..\..\", "{3EB481DF-5B0B-4E72-90A1-039165F580E1}"
|
||||
ProjectSection(WebsiteProperties) = preProject
|
||||
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
|
||||
Debug.AspNetCompiler.VirtualPath = "/localhost_11863"
|
||||
Debug.AspNetCompiler.PhysicalPath = "..\..\..\EngineIoClientDotNet\"
|
||||
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_11863\"
|
||||
Debug.AspNetCompiler.Updateable = "true"
|
||||
Debug.AspNetCompiler.ForceOverwrite = "true"
|
||||
Debug.AspNetCompiler.FixedNames = "false"
|
||||
Debug.AspNetCompiler.Debug = "True"
|
||||
Release.AspNetCompiler.VirtualPath = "/localhost_11863"
|
||||
Release.AspNetCompiler.PhysicalPath = "..\..\..\EngineIoClientDotNet\"
|
||||
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_11863\"
|
||||
Release.AspNetCompiler.Updateable = "true"
|
||||
Release.AspNetCompiler.ForceOverwrite = "true"
|
||||
Release.AspNetCompiler.FixedNames = "false"
|
||||
Release.AspNetCompiler.Debug = "False"
|
||||
VWDPort = "11863"
|
||||
SlnRelativePath = "..\..\..\EngineIoClientDotNet\"
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{568D67D0-3253-4601-9B04-7730A9EC5CC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{568D67D0-3253-4601-9B04-7730A9EC5CC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{568D67D0-3253-4601-9B04-7730A9EC5CC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{568D67D0-3253-4601-9B04-7730A9EC5CC0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7F5CBDD0-5537-4B8B-AD7E-9F7E88600084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7F5CBDD0-5537-4B8B-AD7E-9F7E88600084}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7F5CBDD0-5537-4B8B-AD7E-9F7E88600084}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7F5CBDD0-5537-4B8B-AD7E-9F7E88600084}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA788BBE-0FE8-4C2F-8A02-457A5E9E2703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BA788BBE-0FE8-4C2F-8A02-457A5E9E2703}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA788BBE-0FE8-4C2F-8A02-457A5E9E2703}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BA788BBE-0FE8-4C2F-8A02-457A5E9E2703}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3EB481DF-5B0B-4E72-90A1-039165F580E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3EB481DF-5B0B-4E72-90A1-039165F580E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3EB481DF-5B0B-4E72-90A1-039165F580E1}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3EB481DF-5B0B-4E72-90A1-039165F580E1}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
412
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/Parser/Packet_net35.cs
vendored
Normal file
412
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/Parser/Packet_net35.cs
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
using Quobject.EngineIoClientDotNet.Modules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Quobject.EngineIoClientDotNet.Parser
|
||||
{
|
||||
/// <remarks>
|
||||
/// Packet type which is ported from the JavaScript module.
|
||||
/// This is the JavaScript parser for the engine.io protocol encoding,
|
||||
/// shared by both engine.io-client and engine.io.
|
||||
/// <see href="https://github.com/Automattic/engine.io-parser">https://github.com/Automattic/engine.io-parser</see>
|
||||
/// </remarks>
|
||||
public class Packet
|
||||
{
|
||||
public static readonly string OPEN = "open";
|
||||
public static readonly string CLOSE = "close";
|
||||
public static readonly string PING = "ping";
|
||||
public static readonly string PONG = "pong";
|
||||
public static readonly string UPGRADE = "upgrade";
|
||||
public static readonly string MESSAGE = "message";
|
||||
public static readonly string NOOP = "noop";
|
||||
public static readonly string ERROR = "error";
|
||||
|
||||
private static readonly int MAX_INT_CHAR_LENGTH = int.MaxValue.ToString().Length;
|
||||
|
||||
//TODO: suport binary?
|
||||
private bool SupportsBinary = false;
|
||||
|
||||
private static readonly Dictionary<string, byte> _packets = new Dictionary<string, byte>()
|
||||
{
|
||||
{Packet.OPEN, 0},
|
||||
{Packet.CLOSE, 1},
|
||||
{Packet.PING, 2},
|
||||
{Packet.PONG, 3},
|
||||
{Packet.MESSAGE, 4},
|
||||
{Packet.UPGRADE, 5},
|
||||
{Packet.NOOP, 6}
|
||||
};
|
||||
|
||||
private static readonly Dictionary<byte, string> _packetsList = new Dictionary<byte, string>();
|
||||
|
||||
static Packet()
|
||||
{
|
||||
foreach (var entry in _packets)
|
||||
{
|
||||
_packetsList.Add(entry.Value, entry.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Packet _err = new Packet(Packet.ERROR, "parser error");
|
||||
|
||||
public string Type { get; set; }
|
||||
public object Data { get; set; }
|
||||
|
||||
|
||||
public Packet(string type, object data)
|
||||
{
|
||||
this.Type = type;
|
||||
this.Data = data;
|
||||
}
|
||||
|
||||
public Packet(string type)
|
||||
{
|
||||
this.Type = type;
|
||||
this.Data = null;
|
||||
}
|
||||
|
||||
internal void Encode(IEncodeCallback callback, bool utf8encode = false)
|
||||
{
|
||||
if (Data is byte[])
|
||||
{
|
||||
if (!SupportsBinary)
|
||||
{
|
||||
EncodeBase64Packet(callback);
|
||||
return;
|
||||
}
|
||||
EncodeByteArray(callback);
|
||||
return;
|
||||
}
|
||||
var encodedStringBuilder = new StringBuilder();
|
||||
encodedStringBuilder.Append(_packets[Type]);
|
||||
|
||||
if (Data != null)
|
||||
{
|
||||
encodedStringBuilder.Append(utf8encode ? UTF8.Encode((string)Data) : (string)Data);
|
||||
}
|
||||
|
||||
callback.Call(encodedStringBuilder.ToString());
|
||||
}
|
||||
|
||||
private void EncodeBase64Packet(IEncodeCallback callback)
|
||||
{
|
||||
var byteData = Data as byte[];
|
||||
if (byteData != null)
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
result.Append("b");
|
||||
result.Append(_packets[Type]);
|
||||
result.Append(Convert.ToBase64String(byteData));
|
||||
callback.Call(result.ToString());
|
||||
return;
|
||||
}
|
||||
throw new Exception("byteData == null");
|
||||
}
|
||||
|
||||
private void EncodeByteArray(IEncodeCallback callback)
|
||||
{
|
||||
var byteData = Data as byte[];
|
||||
if (byteData != null)
|
||||
{
|
||||
var resultArray = new byte[1 + byteData.Length];
|
||||
resultArray[0] = _packets[Type];
|
||||
Array.Copy(byteData, 0, resultArray, 1, byteData.Length);
|
||||
callback.Call(resultArray);
|
||||
return;
|
||||
}
|
||||
throw new Exception("byteData == null");
|
||||
}
|
||||
|
||||
internal static Packet DecodePacket(string data, bool utf8decode = false)
|
||||
{
|
||||
if (data.StartsWith("b"))
|
||||
{
|
||||
return DecodeBase64Packet(data.Substring(1));
|
||||
}
|
||||
|
||||
int type;
|
||||
var s = data.Substring(0, 1);
|
||||
if (!int.TryParse(s, out type))
|
||||
{
|
||||
type = -1;
|
||||
}
|
||||
|
||||
if (utf8decode)
|
||||
{
|
||||
try
|
||||
{
|
||||
data = UTF8.Decode(data);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return _err;
|
||||
}
|
||||
}
|
||||
|
||||
if (type < 0 || type >= _packetsList.Count)
|
||||
{
|
||||
return _err;
|
||||
}
|
||||
|
||||
if (data.Length > 1)
|
||||
{
|
||||
return new Packet(_packetsList[(byte)type], data.Substring(1));
|
||||
}
|
||||
return new Packet(_packetsList[(byte)type], null);
|
||||
}
|
||||
|
||||
private static Packet DecodeBase64Packet(string msg)
|
||||
{
|
||||
int type;
|
||||
var s = msg.Substring(0, 1);
|
||||
if (!int.TryParse(s, out type))
|
||||
{
|
||||
type = -1;
|
||||
}
|
||||
if (type < 0 || type >= _packetsList.Count)
|
||||
{
|
||||
return _err;
|
||||
}
|
||||
msg = msg.Substring(1);
|
||||
byte[] decodedFromBase64 = Convert.FromBase64String(msg);
|
||||
return new Packet(_packetsList[(byte)type], decodedFromBase64);
|
||||
}
|
||||
|
||||
internal static Packet DecodePacket(byte[] data)
|
||||
{
|
||||
int type = data[0];
|
||||
var byteArray = new byte[data.Length - 1];
|
||||
Array.Copy(data, 1, byteArray, 0, byteArray.Length);
|
||||
return new Packet(_packetsList[(byte)type], byteArray);
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal static void EncodePayload(Packet[] packets, IEncodeCallback callback)
|
||||
{
|
||||
if (packets.Length == 0)
|
||||
{
|
||||
callback.Call(new byte[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
var results = new List<byte[]>(packets.Length);
|
||||
var encodePayloadCallback = new EncodePayloadCallback(results);
|
||||
foreach (var packet in packets)
|
||||
{
|
||||
packet.Encode(encodePayloadCallback, true);
|
||||
}
|
||||
|
||||
callback.Call(Buffer.Concat(results.ToArray()));//new byte[results.Count][]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes data when a payload is maybe expected.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="callback"></param>
|
||||
public static void DecodePayload(string data, IDecodePayloadCallback callback)
|
||||
{
|
||||
if (String.IsNullOrEmpty(data))
|
||||
{
|
||||
callback.Call(_err, 0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
var length = new StringBuilder();
|
||||
for (int i = 0, l = data.Length; i < l; i++)
|
||||
{
|
||||
var chr = Convert.ToChar(data.Substring(i, 1));
|
||||
|
||||
if (chr != ':')
|
||||
{
|
||||
length.Append(chr);
|
||||
}
|
||||
else
|
||||
{
|
||||
int n;
|
||||
if (!int.TryParse(length.ToString(), out n))
|
||||
{
|
||||
callback.Call(_err, 0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
string msg;
|
||||
try
|
||||
{
|
||||
msg = data.Substring(i + 1, n);
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
callback.Call(_err, 0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.Length != 0)
|
||||
{
|
||||
Packet packet = DecodePacket(msg, true);
|
||||
if (_err.Type == packet.Type && _err.Data == packet.Data)
|
||||
{
|
||||
callback.Call(_err, 0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = callback.Call(packet, i + n, l);
|
||||
if (!ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
i += n;
|
||||
length = new StringBuilder();
|
||||
}
|
||||
}
|
||||
if (length.Length > 0)
|
||||
{
|
||||
callback.Call(_err, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes data when a payload is maybe expected.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="callback"></param>
|
||||
public static void DecodePayload(byte[] data, IDecodePayloadCallback callback)
|
||||
{
|
||||
var bufferTail = ByteBuffer.Wrap(data);
|
||||
|
||||
var buffers = new List<object>();
|
||||
int bufferTail_offset = 0;
|
||||
while (bufferTail.Capacity - bufferTail_offset > 0)
|
||||
{
|
||||
var strLen = new StringBuilder();
|
||||
var isString = (bufferTail.Get(0 + bufferTail_offset) & 0xFF) == 0;
|
||||
var numberTooLong = false;
|
||||
for (int i = 1; ; i++)
|
||||
{
|
||||
int b = bufferTail.Get(i + bufferTail_offset) & 0xFF;
|
||||
if (b == 255)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// support only integer
|
||||
if (strLen.Length > MAX_INT_CHAR_LENGTH)
|
||||
{
|
||||
numberTooLong = true;
|
||||
break;
|
||||
}
|
||||
strLen.Append(b);
|
||||
}
|
||||
if (numberTooLong)
|
||||
{
|
||||
callback.Call(_err, 0, 1);
|
||||
return;
|
||||
}
|
||||
bufferTail_offset += strLen.Length + 1;
|
||||
|
||||
int msgLength = int.Parse(strLen.ToString());
|
||||
|
||||
bufferTail.Position(1 + bufferTail_offset);
|
||||
bufferTail.Limit(msgLength + 1 + bufferTail_offset);
|
||||
var msg = new byte[bufferTail.Remaining()];
|
||||
bufferTail.Get(msg, 0, msg.Length);
|
||||
|
||||
if (isString)
|
||||
{
|
||||
buffers.Add(ByteArrayToString(msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
buffers.Add(msg);
|
||||
}
|
||||
bufferTail.Clear();
|
||||
bufferTail.Position(msgLength + 1 + bufferTail_offset);
|
||||
bufferTail_offset += msgLength + 1;
|
||||
}
|
||||
|
||||
var total = buffers.Count;
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
var buffer = buffers[i];
|
||||
if (buffer is string)
|
||||
{
|
||||
callback.Call(DecodePacket((string)buffer, true), i, total);
|
||||
}
|
||||
else if (buffer is byte[])
|
||||
{
|
||||
callback.Call(DecodePacket((byte[])buffer), i, total);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal static byte[] StringToByteArray(string str)
|
||||
{
|
||||
int len = str.Length;
|
||||
var bytes = new byte[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
bytes[i] = (byte)str[i];
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
internal static string ByteArrayToString(byte[] bytes)
|
||||
{
|
||||
//return Encoding.ASCII.GetString(bytes);
|
||||
//http://stackoverflow.com/questions/7750850/encoding-ascii-getstring-in-windows-phone-platform
|
||||
// return string.Concat(bytes.Select(b => b <= 0x7f ? (char)b : '?')); //.net 4.0 only
|
||||
return string.Concat(
|
||||
(bytes.Select(b => (b <= 0x7f ? (char)b : '?').ToString()))
|
||||
.ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
private class EncodePayloadCallback : IEncodeCallback
|
||||
{
|
||||
private readonly List<byte[]> _results;
|
||||
|
||||
public EncodePayloadCallback(List<byte[]> results)
|
||||
{
|
||||
this._results = results;
|
||||
}
|
||||
|
||||
public void Call(object data)
|
||||
{
|
||||
if (data is string)
|
||||
{
|
||||
var packet = (string)data;
|
||||
var encodingLength = packet.Length.ToString();
|
||||
var sizeBuffer = new byte[encodingLength.Length + 2];
|
||||
sizeBuffer[0] = (byte)0; // is a string
|
||||
for (var i = 0; i < encodingLength.Length; i++)
|
||||
{
|
||||
sizeBuffer[i + 1] = byte.Parse(encodingLength.Substring(i, 1));
|
||||
}
|
||||
sizeBuffer[sizeBuffer.Length - 1] = (byte)255;
|
||||
_results.Add(Buffer.Concat(new byte[][] { sizeBuffer, StringToByteArray(packet) }));
|
||||
return;
|
||||
}
|
||||
|
||||
var packet1 = (byte[])data;
|
||||
var encodingLength1 = packet1.Length.ToString();
|
||||
var sizeBuffer1 = new byte[encodingLength1.Length + 2];
|
||||
sizeBuffer1[0] = (byte)1; // is binary
|
||||
for (var i = 0; i < encodingLength1.Length; i++)
|
||||
{
|
||||
sizeBuffer1[i + 1] = byte.Parse(encodingLength1.Substring(i, 1));
|
||||
}
|
||||
sizeBuffer1[sizeBuffer1.Length - 1] = (byte)255;
|
||||
_results.Add(Buffer.Concat(new byte[][] { sizeBuffer1, packet1 }));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
35
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/Properties/AssemblyInfo.cs
vendored
Normal file
35
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/Properties/AssemblyInfo.cs
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("EngineIoClientDotNet")]
|
||||
[assembly: AssemblyDescription("Engine.IO Client Library for .Net")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Quobject Software")]
|
||||
[assembly: AssemblyProduct("EngineIoClientDotNet")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a95e75cd-35e6-4e88-9e22-631e3fd01546")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.5")]
|
||||
[assembly: AssemblyFileVersion("1.0.5")]
|
||||
7
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/packages.config
vendored
Normal file
7
ThirdParty/EngineIoClientDotNet/Src/EngineIoClientDotNet.net35/packages.config
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net35" />
|
||||
<package id="SuperSocket.ClientEngine.Core" version="0.9.0" targetFramework="net35" />
|
||||
<package id="System.Threading.Tasks.Unofficial" version="3.1" targetFramework="net35" />
|
||||
<package id="WebSocket4Net" version="0.15.1" targetFramework="net35" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user