Skip to content

Commit c3096fb

Browse files
authored
Merge pull request #218 from doghappy/support-v2
Support v2
2 parents e4932d1 + 5c0164e commit c3096fb

File tree

76 files changed

+1783
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1783
-263
lines changed

src/SocketIOClient.Sample/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ static async Task Main(string[] args)
1313
{
1414
//Console.OutputEncoding = Encoding.UTF8;
1515
//Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
16+
1617

17-
var uri = new Uri("http://localhost:11003/");
18+
var uri = new Uri("http://localhost:11002/");
1819

1920
var socket = new SocketIO(uri, new SocketIOOptions
2021
{
2122
Query = new Dictionary<string, string>
2223
{
23-
{"token", "V3" }
24-
}
24+
{"token", "V2" }
25+
},
26+
AutoUpgrade = false,
2527
});
2628

2729
socket.OnConnected += Socket_OnConnected;
@@ -36,7 +38,7 @@ static async Task Main(string[] args)
3638
});
3739
socket.On("hi", response =>
3840
{
39-
// Console.WriteLine(response.ToString());
41+
// Console.WriteLine(response.ToString());
4042
Console.WriteLine(response.GetValue<string>());
4143
});
4244

@@ -67,7 +69,8 @@ private static async void Socket_OnConnected(object sender, EventArgs e)
6769
//while (true)
6870
//{
6971
// await Task.Delay(1000);
70-
await socket.EmitAsync("hi", DateTime.Now.ToShortDateString());
72+
//await socket.EmitAsync("hi", DateTime.Now.ToShortDateString());
73+
await socket.EmitAsync("welcome");
7174
//}
7275
//byte[] bytes = Encoding.UTF8.GetBytes("ClientCallsServerCallback_1Params_0");
7376
//await socket.EmitAsync("client calls the server's callback 1", bytes);

src/SocketIOClient.Test/SocketIOClient.Test.csproj

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,6 @@
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<Compile Remove="SocketIOTests\V2\DisconnectionV2NspTest.cs" />
10-
<Compile Remove="SocketIOTests\V2\DisconnectionV2Test.cs" />
11-
<Compile Remove="SocketIOTests\V2\EmitV2NspTest.cs" />
12-
<Compile Remove="SocketIOTests\V2\EmitV2Test.cs" />
13-
<Compile Remove="SocketIOTests\V2\OffAnyV2NspTest.cs" />
14-
<Compile Remove="SocketIOTests\V2\OffAnyV2Test.cs" />
15-
<Compile Remove="SocketIOTests\V2\OffV2NspTest.cs" />
16-
<Compile Remove="SocketIOTests\V2\OffV2Test.cs" />
17-
<Compile Remove="SocketIOTests\V2\OnAnyV2NspTest.cs" />
18-
<Compile Remove="SocketIOTests\V2\OnAnyV2Test.cs" />
19-
<Compile Remove="SocketIOTests\V2\OnErrorV2NspTest.cs" />
20-
<Compile Remove="SocketIOTests\V2\OnErrorV2Test.cs" />
21-
<Compile Remove="SocketIOTests\V2\ReconnectionV2NspTest.cs" />
22-
<Compile Remove="SocketIOTests\V2\ReconnectionV2Test.cs" />
23-
<Compile Remove="SocketIOTests\V2\ServerV2Manager.cs" />
24-
<Compile Remove="SocketIOTests\V2\SocketIOV2Creator.cs" />
25-
<Compile Remove="SocketIOTests\V2\SocketIOV2NspCreator.cs" />
26-
</ItemGroup>
27-
28-
<ItemGroup>
29-
<None Include="SocketIOTests\V2\DisconnectionV2NspTest.cs" />
30-
<None Include="SocketIOTests\V2\DisconnectionV2Test.cs" />
31-
<None Include="SocketIOTests\V2\EmitV2NspTest.cs" />
32-
<None Include="SocketIOTests\V2\EmitV2Test.cs" />
33-
<None Include="SocketIOTests\V2\OffAnyV2NspTest.cs" />
34-
<None Include="SocketIOTests\V2\OffAnyV2Test.cs" />
35-
<None Include="SocketIOTests\V2\OffV2NspTest.cs" />
36-
<None Include="SocketIOTests\V2\OffV2Test.cs" />
37-
<None Include="SocketIOTests\V2\OnAnyV2NspTest.cs" />
38-
<None Include="SocketIOTests\V2\OnAnyV2Test.cs" />
39-
<None Include="SocketIOTests\V2\OnErrorV2NspTest.cs" />
40-
<None Include="SocketIOTests\V2\OnErrorV2Test.cs" />
41-
<None Include="SocketIOTests\V2\ReconnectionV2NspTest.cs" />
42-
<None Include="SocketIOTests\V2\ReconnectionV2Test.cs" />
43-
<None Include="SocketIOTests\V2\ServerV2Manager.cs" />
44-
<None Include="SocketIOTests\V2\SocketIOV2Creator.cs" />
45-
<None Include="SocketIOTests\V2\SocketIOV2NspCreator.cs" />
46-
</ItemGroup>
47-
488
<ItemGroup>
499
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
5010
<PackageReference Include="Moq" Version="4.16.1" />

src/SocketIOClient.Test/SocketIOTests/AssemblyIntegrationTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using SocketIOClient.Test.Configuration;
3+
using SocketIOClient.Test.SocketIOTests.V2;
4+
using SocketIOClient.Test.SocketIOTests.V3;
35
using SocketIOClient.Test.SocketIOTests.V4;
46
using System;
57
using System.Collections.Generic;
@@ -13,7 +15,7 @@ public class AssemblyIntegrationTest
1315
{
1416
private static readonly IEnumerable<IServerManager> Servers = new List<IServerManager>()
1517
{
16-
//new ServerV2Manager(),
18+
new ServerV2Manager(),
1719
new ServerV3Manager(),
1820
new ServerV4Manager()
1921
};

src/SocketIOClient.Test/SocketIOTests/DisconnectionHttpTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public virtual async Task ServerDisconnect()
3434

3535
await client.ConnectAsync();
3636

37-
await Task.Delay(200);
37+
await Task.Delay(400);
3838
await client.DisconnectAsync();
3939

4040
Assert.IsFalse(client.Connected);

src/SocketIOClient.Test/SocketIOTests/EmitTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ public virtual async Task ClientCallsServerCallback_NoParams_0()
774774
Assert.IsTrue(flag2);
775775
Assert.IsTrue(flag1);
776776
Assert.IsFalse(flag0);
777+
client.Dispose();
777778
}
778779

779780
public virtual async Task ClientCallsServerCallback_NoParams_1()
@@ -827,6 +828,7 @@ public virtual async Task ClientCallsServerCallback_1Params_0()
827828

828829
Assert.AreEqual(1, result.InComingBytes.Count);
829830
Assert.AreEqual("ClientCallsServerCallback_1Params_0...", Encoding.UTF8.GetString(result.GetValue<byte[]>()));
831+
client.Dispose();
830832
}
831833
#endregion
832834
}

src/SocketIOClient.Test/SocketIOTests/OffTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public async virtual Task Test()
2525
await Task.Delay(200);
2626
Assert.AreEqual($"{SocketIOCreator.Prefix}.net core", result);
2727
Assert.AreEqual(1, hiCount);
28+
await Task.Delay(200);
2829

2930
client.Off("hi");
3031
await client.EmitAsync("hi", ".net core 1");
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Threading.Tasks;
3+
4+
namespace SocketIOClient.Test.SocketIOTests.V2
5+
{
6+
[TestClass]
7+
public class HeadersV2Test : HeadersTest
8+
{
9+
public HeadersV2Test()
10+
{
11+
SocketIOCreator = new SocketIOV2Creator();
12+
}
13+
14+
protected override ISocketIOCreateable SocketIOCreator { get; }
15+
16+
[TestMethod]
17+
public override async Task CustomHeader()
18+
{
19+
await base.CustomHeader();
20+
}
21+
}
22+
}

src/SocketIOClient.Test/SocketIOTests/V2/OffAnyV2NspTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace SocketIOClient.Test.SocketIOTests.V2
55
{
66
[TestClass]
7-
public class OffAnyV2NspTest : OnAnyTest
7+
public class OffAnyV2NspTest : OffTest
88
{
99
public OffAnyV2NspTest()
1010
{

src/SocketIOClient.Test/SocketIOTests/V2/OnErrorV2NspTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public OnErrorV2NspTest()
1313

1414
protected override ISocketIOCreateable SocketIOCreator { get; }
1515

16+
1617
[TestMethod]
1718
public override async Task Test()
1819
{

src/SocketIOClient.Test/SocketIOTests/V2/ReconnectionV2NspTest.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ public override async Task ReconnectionFalseTest()
4040
// await base.ReconnectionAttemptsExceededTest();
4141
//}
4242

43-
[TestMethod]
44-
public override async Task ManuallyReconnectionTest()
45-
{
46-
await base.ManuallyReconnectionTest();
47-
}
43+
// NOTE: This test takes a long time, disable it.
44+
//[TestMethod]
45+
//public override async Task ManuallyReconnectionTest()
46+
//{
47+
// await base.ManuallyReconnectionTest();
48+
//}
4849
}
4950
}

0 commit comments

Comments
 (0)