0001-Add-factory-singleton-for-participants_cc5776.patch
rsb-cil-test/Program.cs | ||
---|---|---|
74 | 74 | |
75 | 75 |
listener.Deactivate(); |
76 | 76 | |
77 |
Console.WriteLine("\nConverter test:"); |
|
77 |
Console.WriteLine("\nFactory Test:"); |
|
78 | ||
79 |
SocketConfiguration.Hostname = host; |
|
80 |
SocketConfiguration.Port = port; |
|
78 | 81 | |
79 | 82 |
DefaultConverterRepository.Instance.addConverter(new ProtocolBufferConverter(JointAngles.Descriptor)); |
80 | 83 | |
81 |
Informer repoInformer = new Informer("/test/repo", new OutConnector(new BusClientConnection(host, port), DefaultConverterRepository.Instance.SerializationConverterSelector));
|
|
82 |
Listener repoListener = new Listener(new InPushConnector(new BusClientConnection(host, port), new Scope("/"), DefaultConverterRepository.Instance.DeserializationConverterSelector));
|
|
84 |
Informer repoInformer = Factory.Instance.CreateInformer("/test/repo");
|
|
85 |
Listener repoListener = Factory.Instance.CreateListener("/");
|
|
83 | 86 | |
84 | 87 |
repoListener.EventReceived += (e) => |
85 | 88 |
{ |
rsb-cil/Rsb/Factory.cs | ||
---|---|---|
1 |
using Rsb.Transport.Socket; |
|
2 |
using Rsb.Converter; |
|
3 | ||
4 |
namespace Rsb |
|
5 |
{ |
|
6 |
public class Factory |
|
7 |
{ |
|
8 |
private static readonly Factory instance = new Factory(); |
|
9 |
|
|
10 |
// Explicit static constructor to tell C# compiler |
|
11 |
// not to mark type as beforefieldinit |
|
12 |
static Factory() |
|
13 |
{ |
|
14 |
} |
|
15 | ||
16 |
private Factory() |
|
17 |
{ |
|
18 |
} |
|
19 | ||
20 |
public static Factory Instance |
|
21 |
{ |
|
22 |
get |
|
23 |
{ |
|
24 |
return instance; |
|
25 |
} |
|
26 |
} |
|
27 | ||
28 |
public Informer CreateInformer(Scope scope) { |
|
29 | ||
30 |
return new Informer(scope, |
|
31 |
new OutConnector( |
|
32 |
new BusClientConnection(SocketConfiguration.Hostname, SocketConfiguration.Port), |
|
33 |
DefaultConverterRepository.Instance.SerializationConverterSelector)); |
|
34 |
} |
|
35 | ||
36 |
public Informer CreateInformer(string scope) { |
|
37 |
return CreateInformer(new Scope(scope)); |
|
38 |
} |
|
39 | ||
40 |
public Listener CreateListener(Scope scope) |
|
41 |
{ |
|
42 | ||
43 |
return new Listener( |
|
44 |
new InPushConnector( |
|
45 |
new BusClientConnection(SocketConfiguration.Hostname, SocketConfiguration.Port), |
|
46 |
scope, |
|
47 |
DefaultConverterRepository.Instance.DeserializationConverterSelector |
|
48 |
)); |
|
49 |
} |
|
50 | ||
51 |
public Listener CreateListener(string scope) { |
|
52 |
return CreateListener(new Scope(scope)); |
|
53 |
} |
|
54 | ||
55 |
} |
|
56 |
} |
rsb-cil/Rsb/Transport/Socket/SocketConfiguration.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 | ||
7 |
namespace Rsb.Transport.Socket |
|
8 |
{ |
|
9 |
public static class SocketConfiguration |
|
10 |
{ |
|
11 |
public static int Port = 55555; |
|
12 |
public static string Hostname = "localhost"; |
|
13 |
} |
|
14 |
} |
rsb-cil/rsb-cil.csproj | ||
---|---|---|
51 | 51 |
<Compile Include="Rsb\Converter\StringConverter.cs" /> |
52 | 52 |
<Compile Include="Rsb\Converter\UInt32Converter.cs" /> |
53 | 53 |
<Compile Include="Rsb\Converter\UInt64Converter.cs" /> |
54 |
<Compile Include="Rsb\Factory.cs" /> |
|
54 | 55 |
<Compile Include="Rsb\Protocol\EventId.cs" /> |
55 | 56 |
<Compile Include="Rsb\Protocol\EventMetaData.cs" /> |
56 | 57 |
<Compile Include="Rsb\Protocol\Notification.cs" /> |
... | ... | |
60 | 61 |
<Compile Include="Rsb\Scope.cs" /> |
61 | 62 |
<Compile Include="Rsb\EventId.cs" /> |
62 | 63 |
<Compile Include="Rsb\MetaData.cs" /> |
64 |
<Compile Include="Rsb\Transport\Socket\SocketConfiguration.cs" /> |
|
63 | 65 |
<Compile Include="Rsb\Util\ExactTime.cs" /> |
64 | 66 |
<Compile Include="Rsb\Transport\Socket\OutConnector.cs" /> |
65 | 67 |
<Compile Include="Rsb\Protocol\ProtocolConversion.cs" /> |
... | ... | |
88 | 90 |
</Properties> |
89 | 91 |
</MonoDevelop> |
90 | 92 |
</ProjectExtensions> |
91 |
</Project> |
|
93 |
</Project> |
|
92 |
- |