summaryrefslogtreecommitdiff
path: root/vb/demo/IceGrid/sessionActivation/Client.vb
diff options
context:
space:
mode:
Diffstat (limited to 'vb/demo/IceGrid/sessionActivation/Client.vb')
-rwxr-xr-xvb/demo/IceGrid/sessionActivation/Client.vb182
1 files changed, 91 insertions, 91 deletions
diff --git a/vb/demo/IceGrid/sessionActivation/Client.vb b/vb/demo/IceGrid/sessionActivation/Client.vb
index e2107d4d7a9..860e7dc8602 100755
--- a/vb/demo/IceGrid/sessionActivation/Client.vb
+++ b/vb/demo/IceGrid/sessionActivation/Client.vb
@@ -29,12 +29,12 @@ Module SessionActivationC
While Not _terminated
System.Threading.Monitor.Wait(Me, _timeout)
If _terminated Then
- Exit While
+ Exit While
End If
Try
_session.keepAlive()
Catch ex As Ice.Exception
- Exit While
+ Exit While
End Try
End While
End SyncLock
@@ -52,95 +52,95 @@ Module SessionActivationC
Private _terminated As Boolean
End Class
- Private Sub menu()
- Console.WriteLine("usage:")
- Console.WriteLine("t: send greeting")
- Console.WriteLine("x: exit")
- Console.WriteLine("?: help")
- End Sub
-
- Public Overloads Overrides Function run(ByVal args() As String) As Integer
- Dim status As Integer = 0
- Dim registry As IceGrid.RegistryPrx
- registry = IceGrid.RegistryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Registry"))
- If registry Is Nothing Then
- Console.Error.WriteLine("could not contact registry")
- End If
-
- Dim session As IceGrid.SessionPrx = Nothing
- While True
- Console.Out.WriteLine("This demo accepts any user-id / password combination.")
-
- Console.Out.Write("user id: ")
- Console.Out.Flush()
- Dim id As String = Console.In.ReadLine()
-
- Console.Out.Write("password: ")
- Console.Out.Flush()
- Dim pw As String = Console.In.ReadLine()
-
- Try
- session = registry.createSession(id, pw)
- Exit While
- Catch ex As IceGrid.PermissionDeniedException
- Console.Error.WriteLine("permission denied:\n" + ex.reason)
- End Try
- End While
-
- Dim keepAlive As SessionKeepAliveThread = New SessionKeepAliveThread(session, registry.getSessionTimeout() / 2)
- Dim keepAliveThread As Thread = New Thread(New ThreadStart(AddressOf keepAlive.run))
- keepAliveThread.Start()
-
- Try
- Dim hello As HelloPrx = HelloPrxHelper.checkedCast(session.allocateObjectById(communicator().stringToIdentity("hello")))
-
- 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
- hello.sayHello()
- ElseIf line.Equals("x") Then
- ' Nothing to do
- ElseIf line.Equals("?") Then
- menu()
- Else
- Console.WriteLine("unknown command `" & line & "'")
- menu()
- End If
- Catch ex As System.Exception
- Console.Error.WriteLine(ex)
- End Try
- Loop While Not line.Equals("x")
- Catch ex As IceGrid.AllocationException
- Console.Error.WriteLine("could not allocate object: " + ex.reason)
- status = 1
- Catch ex As IceGrid.ObjectNotRegisteredException
- Console.Error.WriteLine("object not registered with registry")
- status = 1
- Catch ex As Exception
- Console.Error.WriteLine("unexpected exception: " + ex.ToString())
- status = 1
- End Try
-
- '
- ' Destroy the keepAlive thread and the sesion object otherwise
- ' the session will be kept allocated until the timeout occurs.
- ' Destroying the session will release all allocated objects.
- '
- keepAlive.terminate()
- keepAliveThread.Join()
- session.destroy()
-
- Return status
- End Function
+ Private Sub menu()
+ Console.WriteLine("usage:")
+ Console.WriteLine("t: send greeting")
+ Console.WriteLine("x: exit")
+ Console.WriteLine("?: help")
+ End Sub
+
+ Public Overloads Overrides Function run(ByVal args() As String) As Integer
+ Dim status As Integer = 0
+ Dim registry As IceGrid.RegistryPrx
+ registry = IceGrid.RegistryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Registry"))
+ If registry Is Nothing Then
+ Console.Error.WriteLine("could not contact registry")
+ End If
+
+ Dim session As IceGrid.SessionPrx = Nothing
+ While True
+ Console.Out.WriteLine("This demo accepts any user-id / password combination.")
+
+ Console.Out.Write("user id: ")
+ Console.Out.Flush()
+ Dim id As String = Console.In.ReadLine()
+
+ Console.Out.Write("password: ")
+ Console.Out.Flush()
+ Dim pw As String = Console.In.ReadLine()
+
+ Try
+ session = registry.createSession(id, pw)
+ Exit While
+ Catch ex As IceGrid.PermissionDeniedException
+ Console.Error.WriteLine("permission denied:\n" + ex.reason)
+ End Try
+ End While
+
+ Dim keepAlive As SessionKeepAliveThread = New SessionKeepAliveThread(session, registry.getSessionTimeout() / 2)
+ Dim keepAliveThread As Thread = New Thread(New ThreadStart(AddressOf keepAlive.run))
+ keepAliveThread.Start()
+
+ Try
+ Dim hello As HelloPrx = HelloPrxHelper.checkedCast(session.allocateObjectById(communicator().stringToIdentity("hello")))
+
+ 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
+ hello.sayHello()
+ ElseIf line.Equals("x") Then
+ ' Nothing to do
+ ElseIf line.Equals("?") Then
+ menu()
+ Else
+ Console.WriteLine("unknown command `" & line & "'")
+ menu()
+ End If
+ Catch ex As System.Exception
+ Console.Error.WriteLine(ex)
+ End Try
+ Loop While Not line.Equals("x")
+ Catch ex As IceGrid.AllocationException
+ Console.Error.WriteLine("could not allocate object: " + ex.reason)
+ status = 1
+ Catch ex As IceGrid.ObjectNotRegisteredException
+ Console.Error.WriteLine("object not registered with registry")
+ status = 1
+ Catch ex As Exception
+ Console.Error.WriteLine("unexpected exception: " + ex.ToString())
+ status = 1
+ End Try
+
+ '
+ ' Destroy the keepAlive thread and the sesion object otherwise
+ ' the session will be kept allocated until the timeout occurs.
+ ' Destroying the session will release all allocated objects.
+ '
+ keepAlive.terminate()
+ keepAliveThread.Join()
+ session.destroy()
+
+ Return status
+ End Function
End Class
Public Sub Main(ByVal args() As String)