blob: b24c6fd16d1d82e4dea2e138a2e8fe975a980acf (
plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
' **********************************************************************
'
' Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
'
' This copy of Ice is licensed to you under the terms described in the
' ICE_LICENSE file included in this distribution.
'
' **********************************************************************
Imports System
Imports Demo
Module CallbackC
Class Client
Inherits Ice.Application
Private Sub menu()
Console.Out.WriteLine("usage:")
Console.Out.WriteLine("t: send callback as twoway")
Console.Out.WriteLine("o: send callback as oneway")
Console.Out.WriteLine("O: send callback as batch oneway")
Console.Out.WriteLine("d: send callback as datagram")
Console.Out.WriteLine("D: send callback as batch datagram")
Console.Out.WriteLine("f: flush all batch requests")
If _haveSSL Then
Console.Out.WriteLine("S: switch secure mode on/off")
End If
Console.Out.WriteLine("s: shutdown server")
Console.Out.WriteLine("x: exit")
Console.Out.WriteLine("?: help")
End Sub
Public Overloads Overrides Function run(ByVal args() As String) As Integer
Try
communicator().getPluginManager().getPlugin("IceSSL")
_haveSSL = True
Catch ex As Ice.NotRegisteredException
End Try
Dim twoway As CallbackSenderPrx = CallbackSenderPrxHelper.checkedCast(communicator().propertyToProxy("Callback.Client.CallbackServer").ice_twoway().ice_timeout(-1).ice_secure(False))
If twoway Is Nothing Then
Console.Error.WriteLine("invalid proxy")
Return 1
End If
Dim oneway As CallbackSenderPrx = CallbackSenderPrxHelper.uncheckedCast(twoway.ice_oneway())
Dim batchOneway As CallbackSenderPrx = CallbackSenderPrxHelper.uncheckedCast(twoway.ice_batchOneway())
Dim datagram As CallbackSenderPrx = CallbackSenderPrxHelper.uncheckedCast(twoway.ice_datagram())
Dim batchDatagram As CallbackSenderPrx = CallbackSenderPrxHelper.uncheckedCast(twoway.ice_batchDatagram())
Dim adapter As Ice.ObjectAdapter = communicator().createObjectAdapter("Callback.Client")
adapter.add(New CallbackReceiverI, communicator().stringToIdentity("callbackReceiver"))
adapter.activate()
Dim twowayR As CallbackReceiverPrx = CallbackReceiverPrxHelper.uncheckedCast( _
adapter.createProxy(communicator().stringToIdentity("callbackReceiver")))
Dim onewayR As CallbackReceiverPrx = CallbackReceiverPrxHelper.uncheckedCast( _
twowayR.ice_oneway())
Dim datagramR As CallbackReceiverPrx = CallbackReceiverPrxHelper.uncheckedCast(twowayR.ice_datagram())
Dim secure As Boolean = False
menu()
Dim line As String = Nothing
Do
Try
Console.Out.Write("==> ")
Console.Out.Flush()
line = Console.In.ReadLine()
If line Is Nothing Then
Exit Try
End If
If line.Equals("t") Then
twoway.initiateCallback(twowayR)
ElseIf line.Equals("o") Then
oneway.initiateCallback(onewayR)
ElseIf line.Equals("O") Then
batchOneway.initiateCallback(onewayR)
ElseIf line.Equals("d") Then
If secure Then
Console.WriteLine("secure datagrams are not supported")
Else
datagram.initiateCallback(datagramR)
End If
ElseIf line.Equals("D") Then
If secure Then
Console.WriteLine("secure datagrams are not supported")
Else
batchDatagram.initiateCallback(datagramR)
End If
ElseIf line.Equals("f") Then
communicator().flushBatchRequests()
ElseIf _haveSSL And line.Equals("S") Then
secure = Not secure
twoway = CallbackSenderPrxHelper.uncheckedCast(twoway.ice_secure(secure))
oneway = CallbackSenderPrxHelper.uncheckedCast(oneway.ice_secure(secure))
batchOneway = CallbackSenderPrxHelper.uncheckedCast(batchOneway.ice_secure(secure))
datagram = CallbackSenderPrxHelper.uncheckedCast(datagram.ice_secure(secure))
batchDatagram = CallbackSenderPrxHelper.uncheckedCast(batchDatagram.ice_secure(secure))
twowayR = CallbackReceiverPrxHelper.uncheckedCast(twowayR.ice_secure(secure))
onewayR = CallbackReceiverPrxHelper.uncheckedCast(onewayR.ice_secure(secure))
datagramR = CallbackReceiverPrxHelper.uncheckedCast(datagramR.ice_secure(secure))
If secure Then
Console.Out.WriteLine("secure mode is now on")
Else
Console.Out.WriteLine("secure mode is now off")
End If
ElseIf line.Equals("s") Then
twoway.shutdown()
ElseIf line.Equals("x") Then
' Nothing to do
ElseIf line.Equals("?") Then
menu()
Else
Console.Out.WriteLine("unknown command `" & line & "'")
menu()
End If
Catch ex As System.Exception
Console.Error.WriteLine(ex)
End Try
Loop While Not line.Equals("x")
Return 0
End Function
Private Shared _haveSSL As Boolean = False
End Class
Public Sub Main(ByVal args() As String)
Dim app As Client = New Client
Dim status As Integer = app.main(args, "config.client")
System.Environment.Exit(status)
End Sub
End Module
|