forked from emgucv/emgucv
-
Notifications
You must be signed in to change notification settings - Fork 10
/
RpcClient.cs
87 lines (77 loc) · 2.05 KB
/
RpcClient.cs
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
80
81
82
83
84
85
86
87
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using Emgu.RPC.Serial;
using Emgu.RPC.Speech;
using Emgu.CV;
using Emgu.Util;
using System.ServiceModel;
namespace Emgu.RPC
{
public class RpcClient : DisposableObject
{
private Uri _baseUri;
private System.ServiceModel.Channels.Binding _binding;
private ISpeechService _speech;
private CaptureClient _captureClient;
private SerialClient _serialClient;
public RpcClient(Uri baseUri, System.ServiceModel.Channels.Binding binding)
{
_baseUri = baseUri;
_binding = binding;
}
public ISpeechService Speech
{
get
{
return _speech;
}
}
public CaptureClient Capture
{
get
{
return _captureClient;
}
}
public SerialClient Serial
{
get
{
return _serialClient;
}
}
public void AddSpeechClient(String uri)
{
if (_speech == null)
{
_speech = new ChannelFactory<ISpeechService>(
_binding,
new EndpointAddress(_baseUri.ToString() + uri)
).CreateChannel();
}
}
public void AddCaptureClient(String uri)
{
if (_captureClient == null)
{
_captureClient = new CaptureClient(_binding, _baseUri.ToString() + uri);
}
}
public void AddSerialClient(String uri)
{
if (_serialClient == null)
{
_serialClient = new SerialClient(_binding, _baseUri.ToString() + uri);
}
}
protected override void DisposeObject()
{
if (_serialClient != null) _serialClient.Dispose();
if (_captureClient != null) _captureClient.Dispose();
}
}
}