1 ' **********************************************************************
3 ' Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 ' This copy of Ice is licensed to you under the terms described in the
6 ' ICE_LICENSE file included in this distribution.
8 ' **********************************************************************
16 Inherits Ice
.Application
18 Public Overloads Overrides
Function run(ByVal args() As String) As Integer
19 Dim properties
As Ice
.Properties
= communicator().getProperties()
21 Dim proxyProperty
As String = "IceStorm.TopicManager.Proxy"
22 Dim proxy
As String = properties
.getProperty(proxyProperty
)
23 If proxy
.Length
= 0 Then
24 Console
.Error.WriteLine("property `" & proxyProperty
& "' not set")
28 Dim basePrx
As Ice
.ObjectPrx
= communicator().propertyToProxy("IceStorm.TopicManager.Proxy")
29 Dim manager
As IceStorm
.TopicManagerPrx
= IceStorm
.TopicManagerPrxHelper
.checkedCast(basePrx
)
30 If manager Is
Nothing Then
31 Console
.Error.WriteLine("invalid proxy")
35 Dim topicName
as String = "time"
36 Dim datagram
as Boolean = false
37 Dim twoway
as Boolean = false
38 Dim optsSet
as Integer = 0
39 For i
As Integer = 0 To args
.Length
-1
40 If args(i
).Equals("--datagram") Then
43 Elseif args(i
).Equals("--twoway") Then
46 Elseif args(i
).Equals("--oneway") Then
48 Elseif args(i
).StartsWith("--") Then
65 Dim topic
As IceStorm
.TopicPrx
67 topic
= manager
.retrieve(topicName
)
68 Catch ex
As IceStorm
.NoSuchTopic
70 topic
= manager
.create(topicName
)
71 Catch e
As IceStorm
.TopicExists
72 Console
.Error.WriteLine("temporary error. try again.")
78 ' Get the topic's publisher object, and create a Clock proxy with
79 ' the mode specified as an argument of this application.
81 Dim publisher
as Ice
.ObjectPrx
= topic
.getPublisher()
83 publisher
= publisher
.ice_datagram()
87 publisher
= publisher
.ice_oneway()
89 Dim clock
As ClockPrx
= ClockPrxHelper
.uncheckedCast(publisher
)
91 Console
.Out
.WriteLine("publishing tick events. Press ^C to terminate the application.")
94 clock
.tick(DateTime
.Now
.ToString("MM/dd/yyyy HH:mm:ss"))
96 System
.Threading
.Thread
.Sleep(1000)
98 Catch ex
As Ice
.CommunicatorDestroyedException
105 Console
.WriteLine("Usage: " + appName() + " [--datagram|--twoway|--oneway] [topic]")
109 Public Sub Main(ByVal args() As String)
110 Dim app
As Publisher
= New Publisher
111 Dim status
As Integer = app
.Main(args
, "config.pub")
112 System
.Environment
.Exit(status
)