-
Notifications
You must be signed in to change notification settings - Fork 215
/
Copy pathclient.m
74 lines (66 loc) · 2.33 KB
/
client.m
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
%
% Copyright (c) ZeroC, Inc. All rights reserved.
%
function client()
addpath('generated');
if ~libisloaded('ice')
loadlibrary('ice', @iceproto);
end
import Demo.*;
try
% Initializes a communicator and then destroys it when cleanup is collected
communicator = Ice.initialize({'--Ice.Config=config.client'});
cleanup = onCleanup(@() communicator.destroy());
proxy = ContextPrx.checkedCast(communicator.propertyToProxy('Context.Proxy'));
if isempty(proxy)
fprintf('invalid proxy\n');
return;
end
menu();
while true
line = input('==> ', 's');
switch line
case '1'
proxy.call();
case '2'
ctx = containers.Map('KeyType', 'char', 'ValueType', 'char');
ctx('type') = 'Explicit';
proxy.ice_context(ctx).call();
case '3'
ctx = containers.Map('KeyType', 'char', 'ValueType', 'char');
ctx('type') = 'Per-Proxy';
proxy.ice_context(ctx).call();
case '4'
implicitContext = communicator.getImplicitContext();
ctx = containers.Map('KeyType', 'char', 'ValueType', 'char');
ctx('type') = 'Implicit';
implicitContext.setContext(ctx);
proxy.call();
implicitContext.setContext(containers.Map('KeyType', 'char', 'ValueType', 'char'));
case 's'
proxy.shutdown();
case 'x'
break;
case '?'
menu();
case ''
otherwise
fprintf('unknown command `%s''\n', line);
menu();
end
end
catch ex
fprintf('%s\n', getReport(ex));
end
rmpath('generated');
end
function menu()
fprintf(['usage:\n'...
'1: call with no request context\n'...
'2: call with explicit request context\n'...
'3: call with per-proxy request context\n'...
'4: call with implicit request context\n'...
's: shutdown server\n'...
'x: exit\n'...
'?: help\n']);
end