Skip to content

Commit 5a164d8

Browse files
committed
refactor
1 parent 7b34976 commit 5a164d8

Some content is hidden

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

43 files changed

+2244
-1082
lines changed

src/SocketIOClient.Sample/Program.cs

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
using System;
1+
using Newtonsoft.Json;
2+
using SocketIOClient.Newtonsoft.Json;
3+
using System;
24
using System.Collections.Generic;
35
using System.Diagnostics;
6+
using System.Linq;
47
using System.Text;
58
using System.Threading.Tasks;
69

710
namespace SocketIOClient.Sample
811
{
9-
1012
class Program
1113
{
1214
static async Task Main(string[] args)
@@ -15,13 +17,26 @@ static async Task Main(string[] args)
1517
Console.OutputEncoding = Encoding.UTF8;
1618
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
1719

18-
var uri = new Uri("http://localhost:11003/");
20+
//var uri = new Uri("http://localhost:11003/");
21+
22+
//var socket = new SocketIO(uri, new SocketIOOptions
23+
//{
24+
// Transport = Transport.TransportProtocol.WebSocket,
25+
// Query = new Dictionary<string, string>
26+
// {
27+
// {"token", "V3" }
28+
// },
29+
//});
30+
var uri = new Uri("http://localhost:11002/");
1931

2032
var socket = new SocketIO(uri, new SocketIOOptions
2133
{
34+
Transport = Transport.TransportProtocol.Polling,
35+
AutoUpgrade = false,
36+
EIO = 3,
2237
Query = new Dictionary<string, string>
2338
{
24-
{"token", "V3" }
39+
{"token", "V2" }
2540
},
2641
});
2742

@@ -68,8 +83,9 @@ private static async void Socket_OnConnected(object sender, EventArgs e)
6883
//while (true)
6984
//{
7085
// await Task.Delay(1000);
71-
await socket.EmitAsync("hi", DateTime.Now.ToString());
72-
//await socket.EmitAsync("welcome");
86+
//await socket.EmitAsync("hi", DateTime.Now.ToString());
87+
//await socket.EmitAsync("welcome");
88+
await socket.EmitAsync("1 params", Encoding.UTF8.GetBytes("test"));
7389
//}
7490
//byte[] bytes = Encoding.UTF8.GetBytes("ClientCallsServerCallback_1Params_0");
7591
//await socket.EmitAsync("client calls the server's callback 1", bytes);
@@ -86,4 +102,68 @@ private static void Socket_OnPong(object sender, TimeSpan e)
86102
Console.WriteLine("Pong: " + e.TotalMilliseconds);
87103
}
88104
}
105+
106+
//class Program
107+
//{
108+
// public static void Main(string[] args)
109+
// => new Program().Main().GetAwaiter().GetResult();
110+
111+
// private static string GenerateToken()
112+
// {
113+
// string chars = "abcdefghi1234567890";
114+
115+
// StringBuilder token = new StringBuilder("WDN");
116+
117+
// while (token.Length < 35)
118+
// token.Append(chars.OrderBy(r => Guid.NewGuid()).FirstOrDefault());
119+
120+
// return token.ToString().Trim();
121+
// }
122+
123+
// public async Task Main()
124+
// {
125+
// var socket = new SocketIO("https://v3-rc.palringo.com:3051/",
126+
// new SocketIOOptions()
127+
// {
128+
// Transport = SocketIOClient.Transport.TransportProtocol.WebSocket,
129+
// Query = new Dictionary<string, string>()
130+
// {
131+
// ["token"] = GenerateToken(),
132+
// ["device"] = "wolfnetframework",
133+
// ["state"] = "1",// Online State = 1 (Online)
134+
// },
135+
// }
136+
// ); ;
137+
138+
// socket.JsonSerializer = new NewtonsoftJsonSerializer()
139+
// {
140+
// OptionsProvider = () => new JsonSerializerSettings()
141+
// {
142+
// NullValueHandling = NullValueHandling.Ignore,
143+
// ReferenceLoopHandling = ReferenceLoopHandling.Ignore
144+
// }
145+
// };
146+
147+
148+
// socket.OnConnected += (s, e) => Console.WriteLine("Connected To V3 Server");
149+
150+
// socket.OnDisconnected += (s, reason) => Console.WriteLine($"Disconnected From V3 Server -${reason}");
151+
152+
// socket.OnError += (s, error) => Console.WriteLine($"Connection Error Occurred - {error}");
153+
154+
// /*
155+
// socket.OnPing += (s, e) => Console.WriteLine($"Ping");
156+
// socket.OnPong += (s, timespan) => Console.WriteLine($"Pong"); // 0 Ms???
157+
// */
158+
// socket.OnAny((name, body) => Console.WriteLine($"Recieved Packet - {name}"));
159+
160+
// socket.OnReconnectAttempt += (sender, attmept) => Console.WriteLine($"Reconnecting To V3 Servers - Attempt {attmept}");
161+
162+
// socket.OnReconnectFailed += (sender, reason) => Console.WriteLine($"Failed to reconnect to V3 servers - {reason}");
163+
164+
// await socket.ConnectAsync();
165+
166+
// await Task.Delay(-1); // Prevent program from exiting
167+
// }
168+
//}
89169
}

src/SocketIOClient.Sample/SocketIOClient.Sample.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
<ItemGroup>
1010
<ProjectReference Include="..\SocketIOClient.Newtonsoft.Json\SocketIOClient.Newtonsoft.Json.csproj" />
11-
<ProjectReference Include="..\SocketIOClient.Windows7\SocketIOClient.Windows7.csproj" />
1211
<ProjectReference Include="..\SocketIOClient\SocketIOClient.csproj" />
1312
</ItemGroup>
1413

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = false,
12+
AutoUpgrade = false,
13+
Transport = Transport.TransportProtocol.WebSocket,
1214
EIO = EIO,
1315
Query = new Dictionary<string, string>
1416
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = false,
12+
AutoUpgrade = false,
13+
Transport = Transport.TransportProtocol.WebSocket,
1214
EIO = EIO,
1315
Query = new Dictionary<string, string>
1416
{

src/SocketIOClient.Test/SocketIOTests/V2Http/SocketIOV2Creator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = reconnection,
12+
AutoUpgrade = false,
1213
Transport = Transport.TransportProtocol.Polling,
1314
EIO = EIO,
1415
Query = new Dictionary<string, string>

src/SocketIOClient.Test/SocketIOTests/V2Http/SocketIOV2NspCreator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = reconnection,
12+
AutoUpgrade = false,
1213
Transport = Transport.TransportProtocol.Polling,
1314
EIO = EIO,
1415
Query = new Dictionary<string, string>

src/SocketIOClient.Test/SocketIOTests/V3/SocketIOV3Creator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = reconnection,
12+
AutoUpgrade = false,
13+
Transport = Transport.TransportProtocol.WebSocket,
1214
Query = new Dictionary<string, string>
1315
{
1416
{ "token", Token }

src/SocketIOClient.Test/SocketIOTests/V3/SocketIOV3NspCreator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = reconnection,
12+
AutoUpgrade = false,
13+
Transport = Transport.TransportProtocol.WebSocket,
1214
Query = new Dictionary<string, string>
1315
{
1416
{ "token", Token }

src/SocketIOClient.Test/SocketIOTests/V3Http/SocketIOV3Creator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = reconnection,
12+
AutoUpgrade = false,
1213
Transport = Transport.TransportProtocol.Polling,
1314
Query = new Dictionary<string, string>
1415
{

src/SocketIOClient.Test/SocketIOTests/V3Http/SocketIOV3NspCreator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public SocketIO Create(bool reconnection = false)
99
return new SocketIO(Url, new SocketIOOptions
1010
{
1111
Reconnection = reconnection,
12+
AutoUpgrade = false,
1213
Transport = Transport.TransportProtocol.Polling,
1314
Query = new Dictionary<string, string>
1415
{

0 commit comments

Comments
 (0)