-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO.cs
More file actions
79 lines (63 loc) · 1.87 KB
/
Copy pathIO.cs
File metadata and controls
79 lines (63 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Socket.IO.NET35.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Socket.IO.NET35
{
public class IO
{
private static readonly ConcurrentDictionary<string, Manager> Managers =
new ConcurrentDictionary<string, Manager>();
/// <summary>
/// Protocol version
/// </summary>
public static int Protocol = Parser.protocol;
private IO()
{
}
public static Socket Socket(string uri)
{
return Socket(uri, null);
}
public static Socket Socket(string uri, Options opts)
{
return Socket(Url.Parse(uri), opts);
}
public static Socket Socket(Uri uri)
{
return Socket(uri, null);
}
public static Socket Socket(Uri uri, Options opts)
{
var log = LogManager.GetLogger(GlobalHelper.CallerName());
if (opts == null)
{
opts = new Options();
}
Manager io;
if (opts.ForceNew || !opts.Multiplex)
{
log.Info(string.Format("ignoring socket cache for {0}", uri.ToString()));
io = new Manager(uri, opts);
}
else
{
var id = Url.ExtractId(uri);
if (!Managers.ContainsKey(id))
{
log.Info(string.Format("new io instance for {0}", id));
Managers.TryAdd(id, new Manager(uri, opts));
}
io = Managers[id];
}
return io.Socket(uri.PathAndQuery);
}
public class Options : ManagerOptions
{
public bool ForceNew = true;
public bool Multiplex = true;
}
}
}