summaryrefslogtreecommitdiff
path: root/cs
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2009-10-02 02:23:52 +0200
committerJose <jose@zeroc.com>2009-10-02 02:23:52 +0200
commit1d9f29e281770ecdad4a245271f2b828bd64a32f (patch)
treeac083f28b06a444e484c24f8fcf1b12a36202c84 /cs
parentUpdated demo README (diff)
downloadice-1d9f29e281770ecdad4a245271f2b828bd64a32f.tar.bz2
ice-1d9f29e281770ecdad4a245271f2b828bd64a32f.tar.xz
ice-1d9f29e281770ecdad4a245271f2b828bd64a32f.zip
3772. Recovering from Glacier2 / Ice router session failure.
Diffstat (limited to 'cs')
-rw-r--r--cs/demo/Glacier2/callback/Client.cs145
-rw-r--r--cs/demo/Glacier2/callback/Glacier2.callback.client.csproj4
-rwxr-xr-xcs/demo/Glacier2/callback/expect.py4
-rwxr-xr-xcs/demo/Glacier2/chat/App.xaml21
-rwxr-xr-xcs/demo/Glacier2/chat/App.xaml.cs25
-rwxr-xr-xcs/demo/Glacier2/chat/CancelDialog.xaml27
-rwxr-xr-xcs/demo/Glacier2/chat/CancelDialog.xaml.cs49
-rwxr-xr-xcs/demo/Glacier2/chat/Chat.ice31
-rwxr-xr-xcs/demo/Glacier2/chat/ChatCommands.cs58
-rwxr-xr-xcs/demo/Glacier2/chat/ChatWindow.xaml68
-rwxr-xr-xcs/demo/Glacier2/chat/ChatWindow.xaml.cs321
-rwxr-xr-xcs/demo/Glacier2/chat/Glacier2.chat.client.csproj148
-rwxr-xr-xcs/demo/Glacier2/chat/LoginDialog.xaml41
-rwxr-xr-xcs/demo/Glacier2/chat/LoginDialog.xaml.cs63
-rwxr-xr-xcs/demo/Glacier2/chat/Properties/AssemblyInfo.cs55
-rwxr-xr-xcs/demo/Glacier2/chat/Properties/Resources.Designer.cs71
-rwxr-xr-xcs/demo/Glacier2/chat/Properties/Resources.resx117
-rwxr-xr-xcs/demo/Glacier2/chat/Properties/Settings.Designer.cs30
-rwxr-xr-xcs/demo/Glacier2/chat/Properties/Settings.settings7
-rwxr-xr-xcs/demo/Glacier2/chat/config.client39
-rw-r--r--cs/demo/Ice/wpf/App.xaml18
-rw-r--r--cs/demo/Ice/wpf/App.xaml.cs25
-rw-r--r--cs/demo/Ice/wpf/Hello.ice24
-rw-r--r--cs/demo/Ice/wpf/HelloWindow.xaml91
-rw-r--r--cs/demo/Ice/wpf/HelloWindow.xaml.cs358
-rw-r--r--cs/demo/Ice/wpf/Ice.wpf.client.csproj154
-rwxr-xr-xcs/demo/Ice/wpf/Properties/AssemblyInfo.cs55
-rwxr-xr-xcs/demo/Ice/wpf/Properties/Resources.Designer.cs71
-rwxr-xr-xcs/demo/Ice/wpf/Properties/Resources.resx117
-rwxr-xr-xcs/demo/Ice/wpf/Properties/Settings.Designer.cs30
-rwxr-xr-xcs/demo/Ice/wpf/Properties/Settings.settings7
-rw-r--r--cs/demo/Ice/wpf/config.client45
-rwxr-xr-xcs/demo/demo.sln12
-rw-r--r--cs/src/Glacier2/Application.cs508
-rw-r--r--cs/src/Glacier2/Makefile3
-rw-r--r--cs/src/Glacier2/Makefile.mak7
-rw-r--r--cs/src/Glacier2/SessionFactoryHelper.cs360
-rw-r--r--cs/src/Glacier2/SessionHelper.cs485
-rw-r--r--cs/src/Ice/Application.cs198
39 files changed, 3676 insertions, 216 deletions
diff --git a/cs/demo/Glacier2/callback/Client.cs b/cs/demo/Glacier2/callback/Client.cs
index 19698a32bc1..aa50ad97bca 100644
--- a/cs/demo/Glacier2/callback/Client.cs
+++ b/cs/demo/Glacier2/callback/Client.cs
@@ -21,51 +21,8 @@ using System.Reflection;
public class Client
{
- public class App : Ice.Application
+ public class App : Glacier2.Application
{
- class SessionRefreshThread
- {
- public SessionRefreshThread(Glacier2.RouterPrx router, int timeout)
- {
- _router = router;
- _timeout = timeout;
- _terminated = false;
- }
-
- public void run()
- {
- lock(this)
- {
- while(!_terminated)
- {
- Monitor.Wait(this, _timeout);
- if(!_terminated)
- {
- try
- {
- _router.refreshSession();
- }
- catch(Ice.Exception)
- {
- }
- }
- }
- }
- }
-
- public void terminate()
- {
- lock(this)
- {
- _terminated = true;
- Monitor.Pulse(this);
- }
- }
-
- private Glacier2.RouterPrx _router;
- private int _timeout;
- private bool _terminated;
- }
private static void menu()
{
Console.WriteLine(
@@ -81,81 +38,70 @@ public class Client
"?: help\n");
}
- public override int run(string[] args)
+ public override Glacier2.SessionPrx createSession()
{
- if(args.Length > 0)
- {
- Console.Error.WriteLine(appName() + ": too many arguments");
- return 1;
- }
-
- Ice.RouterPrx defaultRouter = communicator().getDefaultRouter();
- if(defaultRouter == null)
- {
- Console.Error.WriteLine("no default router set");
- return 1;
- }
-
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.checkedCast(defaultRouter);
- if(router == null)
- {
- Console.Error.WriteLine("configured router is not a Glacier2 router");
- return 1;
- }
-
+ Glacier2.SessionPrx session;
while(true)
{
Console.WriteLine("This demo accepts any user-id / password combination.");
String id;
- Console.Write("user id: ");
- Console.Out.Flush();
- id = Console.In.ReadLine();
-
String pw;
- Console.Write("password: ");
- Console.Out.Flush();
- pw = Console.In.ReadLine();
+ try
+ {
+ Console.Write("user id: ");
+ Console.Out.Flush();
+ id = Console.In.ReadLine().Trim();
+
+ Console.Write("password: ");
+ Console.Out.Flush();
+ pw = Console.In.ReadLine().Trim();
+ }
+ catch(System.IO.IOException ex)
+ {
+ Console.WriteLine(ex.StackTrace.ToString());
+ continue;
+ }
try
{
- router.createSession(id, pw);
+ session = router().createSession(id, pw);
break;
}
catch(Glacier2.PermissionDeniedException ex)
{
- Console.Write("permission denied:\n" + ex.reason);
+ Console.WriteLine("permission denied:\n" + ex.reason);
}
catch(Glacier2.CannotCreateSessionException ex)
{
- Console.Write("cannot create session:\n" + ex.reason);
+ Console.WriteLine("cannot create session:\n" + ex.reason);
}
}
+ return session;
+ }
- SessionRefreshThread refresh = new SessionRefreshThread(router, (int)router.getSessionTimeout() * 500);
- Thread refreshThread = new Thread(new ThreadStart(refresh.run));
- refreshThread.Start();
+ public override int runWithSession(string[] args)
+ {
+ if(args.Length > 0)
+ {
+ Console.Error.WriteLine(appName() + ": too many arguments");
+ return 1;
+ }
- String category = router.getCategoryForClient();
- Ice.Identity callbackReceiverIdent = new Ice.Identity();
- callbackReceiverIdent.name = "callbackReceiver";
- callbackReceiverIdent.category = category;
- Ice.Identity callbackReceiverFakeIdent = new Ice.Identity();
- callbackReceiverFakeIdent.name = "callbackReceiver";
- callbackReceiverFakeIdent.category = "fake";
+
+ Ice.Identity callbackReceiverIdent = createCallbackIdentity("callbackReceiver");
+ Ice.Identity callbackReceiverFakeIdent = new Ice.Identity("fake", "callbackReceiver");
Ice.ObjectPrx @base = communicator().propertyToProxy("Callback.Proxy");
CallbackPrx twoway = CallbackPrxHelper.checkedCast(@base);
CallbackPrx oneway = CallbackPrxHelper.uncheckedCast(twoway.ice_oneway());
CallbackPrx batchOneway = CallbackPrxHelper.uncheckedCast(twoway.ice_batchOneway());
- Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithRouter("Callback.Client", defaultRouter);
- adapter.add(new CallbackReceiverI(), callbackReceiverIdent);
- adapter.add(new CallbackReceiverI(), callbackReceiverFakeIdent);
- adapter.activate();
+ objectAdapter().add(new CallbackReceiverI(), callbackReceiverFakeIdent);
CallbackReceiverPrx twowayR = CallbackReceiverPrxHelper.uncheckedCast(
- adapter.createProxy(callbackReceiverIdent));
+ objectAdapter().add(new CallbackReceiverI(), callbackReceiverIdent));
+
CallbackReceiverPrx onewayR = CallbackReceiverPrxHelper.uncheckedCast(twowayR.ice_oneway());
menu();
@@ -274,25 +220,6 @@ public class Client
// is set to 0 so that if session.destroy() raises an exception
// the thread will not be re-terminated and re-joined.
//
- refresh.terminate();
- refreshThread.Join();
- refresh = null;
-
- try
- {
- router.destroySession();
- }
- catch(Glacier2.SessionNotExistException ex)
- {
- Console.Error.WriteLine(ex);
- }
- catch(Ice.ConnectionLostException)
- {
- //
- // Expected: the router closed the connection.
- //
- }
-
return 0;
}
}
diff --git a/cs/demo/Glacier2/callback/Glacier2.callback.client.csproj b/cs/demo/Glacier2/callback/Glacier2.callback.client.csproj
index 8b92a462af5..669b64e062f 100644
--- a/cs/demo/Glacier2/callback/Glacier2.callback.client.csproj
+++ b/cs/demo/Glacier2/callback/Glacier2.callback.client.csproj
@@ -1,7 +1,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectType>Local</ProjectType>
- <ProductVersion>8.0.50727</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2AC78A13-497B-44B1-8BF0-156877B78293}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -113,7 +113,7 @@
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties ZerocIce_ConsoleOutput="True" ZerocIce_Enabled="True" ZerocIce_Home="..\..\..\.." ZerocIce_HomeExpanded="..\..\..\.." />
+ <UserProperties ZerocIce_HomeExpanded="..\..\..\.." ZerocIce_Home="..\..\..\.." ZerocIce_Enabled="True" ZerocIce_ConsoleOutput="True" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/cs/demo/Glacier2/callback/expect.py b/cs/demo/Glacier2/callback/expect.py
index a53d2f02678..0878334c2da 100755
--- a/cs/demo/Glacier2/callback/expect.py
+++ b/cs/demo/Glacier2/callback/expect.py
@@ -24,8 +24,6 @@ from demoscript.Glacier2 import callback
server = Util.spawn('./server.exe --Ice.PrintAdapterReady')
server.expect('.* ready')
-sessionserver = Util.spawn('./sessionserver.exe --Ice.PrintAdapterReady')
-sessionserver.expect('.* ready')
glacier2 = Util.spawn('glacier2router --Ice.Config=config.glacier2 --Ice.PrintAdapterReady --Glacier2.SessionTimeout=5')
glacier2.expect('Glacier2.Client ready')
@@ -33,4 +31,4 @@ glacier2.expect('Glacier2.Server ready')
client = Util.spawn('./client.exe')
-callback.run(client, server, sessionserver, glacier2)
+callback.run(client, server, glacier2)
diff --git a/cs/demo/Glacier2/chat/App.xaml b/cs/demo/Glacier2/chat/App.xaml
new file mode 100755
index 00000000000..dd7c8855d04
--- /dev/null
+++ b/cs/demo/Glacier2/chat/App.xaml
@@ -0,0 +1,21 @@
+<!--
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+-->
+<Application x:Class="Glacier2.chat.client.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ StartupUri="ChatWindow.xaml" ShutdownMode="OnLastWindowClose">
+ <Application.Resources>
+ <Style x:Key="Menu">
+ <Setter Property="MenuItem.FontFamily" Value="Times New Romans"/>
+ <Setter Property="MenuItem.FontSize" Value="12"/>
+ </Style>
+ </Application.Resources>
+</Application>
diff --git a/cs/demo/Glacier2/chat/App.xaml.cs b/cs/demo/Glacier2/chat/App.xaml.cs
new file mode 100755
index 00000000000..00a6e969446
--- /dev/null
+++ b/cs/demo/Glacier2/chat/App.xaml.cs
@@ -0,0 +1,25 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Windows;
+
+namespace Glacier2.chat.client
+{
+ /// <summary>
+ /// Interaction logic for App.xaml
+ /// </summary>
+ public partial class App : System.Windows.Application
+ {
+ }
+}
diff --git a/cs/demo/Glacier2/chat/CancelDialog.xaml b/cs/demo/Glacier2/chat/CancelDialog.xaml
new file mode 100755
index 00000000000..f70a96bb95c
--- /dev/null
+++ b/cs/demo/Glacier2/chat/CancelDialog.xaml
@@ -0,0 +1,27 @@
+<!--
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+-->
+<Window x:Class="Glacier2.chat.client.CancelDialog"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="Connecting" Height="80" Width="200" ResizeMode="NoResize">
+ <Grid>
+ <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Vertical">
+
+ <StackPanel Orientation="Vertical">
+ <TextBlock Margin="2" Name="txtInfo" Width="180" TextWrapping="Wrap">Please wait while connecting...</TextBlock>
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <Button Margin="2" MaxWidth="80" Click="cancel" IsDefault="True">Cancel</Button>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+</Window>
diff --git a/cs/demo/Glacier2/chat/CancelDialog.xaml.cs b/cs/demo/Glacier2/chat/CancelDialog.xaml.cs
new file mode 100755
index 00000000000..f6668b04fca
--- /dev/null
+++ b/cs/demo/Glacier2/chat/CancelDialog.xaml.cs
@@ -0,0 +1,49 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Glacier2.chat.client
+{
+ /// <summary>
+ /// Interaction logic for CancelDialog.xaml
+ /// </summary>
+ public partial class CancelDialog : Window
+ {
+ public CancelDialog()
+ {
+ InitializeComponent();
+ }
+
+ public void cancel(object sender, RoutedEventArgs args)
+ {
+ _cancel = true;
+ Close();
+ }
+
+ public bool ShowModal()
+ {
+ ShowDialog();
+ return _cancel;
+ }
+
+ private bool _cancel = false;
+ }
+}
diff --git a/cs/demo/Glacier2/chat/Chat.ice b/cs/demo/Glacier2/chat/Chat.ice
new file mode 100755
index 00000000000..d55ec11be98
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Chat.ice
@@ -0,0 +1,31 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+#ifndef CHAT_ICE
+#define CHAT_ICE
+
+#include <Glacier2/Session.ice>
+
+module Demo
+{
+
+interface ChatCallback
+{
+ void message(string data);
+};
+
+interface ChatSession extends Glacier2::Session
+{
+ ["ami"] void setCallback(ChatCallback* callback);
+ ["ami"] void say(string data);
+};
+
+};
+
+#endif
diff --git a/cs/demo/Glacier2/chat/ChatCommands.cs b/cs/demo/Glacier2/chat/ChatCommands.cs
new file mode 100755
index 00000000000..11c21a10160
--- /dev/null
+++ b/cs/demo/Glacier2/chat/ChatCommands.cs
@@ -0,0 +1,58 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Input;
+
+namespace Glacier2.chat.client
+{
+ public class ChatCommands
+ {
+ static ChatCommands()
+ {
+ // Initialize logout command
+ _loginCommand = new RoutedUICommand("Login", "Login", typeof(ChatCommands), null);
+ // Initialize logout command
+ _logoutCommand = new RoutedUICommand("Logout", "Logout", typeof(ChatCommands), null);
+ // Initialize exit commnad
+ _exitCommand = new RoutedUICommand("Exit", "&Exit", typeof(ChatCommands), null);
+ }
+
+ public static RoutedUICommand Login
+ {
+ get
+ {
+ return _loginCommand;
+ }
+ }
+
+ public static RoutedUICommand Logout
+ {
+ get
+ {
+ return _logoutCommand;
+ }
+ }
+
+ public static RoutedUICommand Exit
+ {
+ get
+ {
+ return _exitCommand;
+ }
+ }
+
+ private static RoutedUICommand _loginCommand;
+ private static RoutedUICommand _logoutCommand;
+ private static RoutedUICommand _exitCommand;
+ }
+}
diff --git a/cs/demo/Glacier2/chat/ChatWindow.xaml b/cs/demo/Glacier2/chat/ChatWindow.xaml
new file mode 100755
index 00000000000..3e78088256d
--- /dev/null
+++ b/cs/demo/Glacier2/chat/ChatWindow.xaml
@@ -0,0 +1,68 @@
+<!--
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+-->
+<Window x:Class="Glacier2.chat.client.ChatWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="clr-namespace:Glacier2.chat.client"
+ Title="Chat Window" Height="300" Width="300" Closed="windowClosed">
+ <Window.CommandBindings>
+ <CommandBinding Command="local:ChatCommands.Login" Executed="login" CanExecute="isLoginEnabled"/>
+ <CommandBinding Command="local:ChatCommands.Logout" Executed="logout" CanExecute="isLogoutEnabled"/>
+ <CommandBinding Command="local:ChatCommands.Exit" Executed="exit"/>
+ </Window.CommandBindings>
+ <DockPanel>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" DockPanel.Dock="Top">
+ <Menu Style="{StaticResource Menu}" Background="White">
+ <MenuItem Header="Connect">
+ <MenuItem Header="_Login" Command="local:ChatCommands.Login" Background="White"/>
+ <MenuItem Header="_Logout" Command="local:ChatCommands.Logout" Background="White"/>
+ <MenuItem Header="E_xit" Command="local:ChatCommands.Exit" Background="White"/>
+ </MenuItem>
+ </Menu>
+ </StackPanel>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="5*"></RowDefinition>
+ <RowDefinition Height="AUTO"></RowDefinition>
+ <RowDefinition Height="AUTO"></RowDefinition>
+ <RowDefinition Height="AUTO"></RowDefinition>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition></ColumnDefinition>
+ </Grid.ColumnDefinitions>
+
+ <!-- Define a text box to show chat messages. -->
+ <TextBox Grid.Column="0" Grid.Row="0" x:Name="txtMessages"
+ FontSize="12" Text="" TextWrapping="Wrap" IsEnabled="True"
+ ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto"
+ ScrollViewer.VerticalScrollBarVisibility="Auto" IsReadOnly="True"
+ MinLines="4" SizeChanged="scrollDown"/>
+
+ <!-- Define another splitter to separate the upper view and the text box used
+ for input messages. -->
+ <GridSplitter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Height="2"
+ ResizeDirection="Rows" HorizontalAlignment="Stretch"/>
+
+ <!--- Define an editable text box for the user to write messages. -->
+ <TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"
+ Name="input"
+ TextWrapping="Wrap"
+ ScrollViewer.CanContentScroll="True"
+ HorizontalScrollBarVisibility="Hidden"
+ VerticalScrollBarVisibility="Auto"
+ Background="WhiteSmoke" KeyDown="sendMessage" TabIndex="1"></TextBox>
+
+ <!-- TextBlock with the status message -->
+ <Label Grid.Row="3" Name="status" Grid.Column="0" VerticalAlignment="Bottom" Content="Disconnected"/>
+
+ </Grid>
+ </DockPanel>
+</Window>
diff --git a/cs/demo/Glacier2/chat/ChatWindow.xaml.cs b/cs/demo/Glacier2/chat/ChatWindow.xaml.cs
new file mode 100755
index 00000000000..cbc5affb56c
--- /dev/null
+++ b/cs/demo/Glacier2/chat/ChatWindow.xaml.cs
@@ -0,0 +1,321 @@
+// **********************************************************************
+//
+// Copyright(c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+
+using Demo;
+
+namespace Glacier2.chat.client
+{
+ public class LoginData
+ {
+ public LoginData()
+ {
+ routerHost = "127.0.0.1";
+ userName = "test";
+ password = "";
+ }
+
+ public String routerHost;
+ public String userName;
+ public String password;
+ }
+
+ class Util
+ {
+ static public void
+ locateOnScreen(System.Windows.Window window)
+ {
+ window.Left = (System.Windows.SystemParameters.PrimaryScreenWidth - window.Width) / 2;
+ window.Top = (System.Windows.SystemParameters.PrimaryScreenHeight - window.Height) / 2;
+ }
+
+ static public void
+ centerWindow(System.Windows.Window w1, System.Windows.Window w)
+ {
+ w1.Top = w.Top + ((w.Height - w1.Height) / 2);
+ w1.Left = w.Left + ((w.Width - w1.Width) / 2);
+ }
+ }
+
+ /// <summary>
+ /// Interaction logic for ChatWindow.xaml
+ /// </summary>
+ public partial class ChatWindow : Window, Glacier2.SessionFactoryHelper.Callback
+ {
+ private class ChatCallbackI : Demo.ChatCallbackDisp_
+ {
+ public ChatCallbackI(ChatWindow window)
+ {
+ _window = window;
+ }
+ public override void
+ message(string data, Ice.Current current)
+ {
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
+ {
+ _window.appendMessage(data);
+ }
+ );
+ }
+ ChatWindow _window;
+ }
+
+ class AMI_ChatSession_sayI : Demo.AMI_ChatSession_say
+ {
+ public AMI_ChatSession_sayI(ChatWindow window)
+ {
+ _window = window;
+ }
+
+ public override void
+ ice_exception(Ice.Exception ex)
+ {
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
+ {
+ _window.appendMessage("<system-message> - " + ex.ToString());
+ });
+ }
+
+ public override void
+ ice_response()
+ {
+ }
+
+ private ChatWindow _window;
+ }
+
+ class AMI_ChatSession_setCallbackI : Demo.AMI_ChatSession_setCallback
+ {
+ public AMI_ChatSession_setCallbackI(ChatWindow window)
+ {
+ _window = window;
+ }
+
+ public override void
+ ice_response()
+ {
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
+ {
+ _window.closeCancelDialog();
+ _window.input.IsEnabled = true;
+ _window.status.Content = "Connected with " + _window._loginData.routerHost;
+ });
+ }
+
+ public override void
+ ice_exception(Ice.Exception ex)
+ {
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
+ {
+ if(_window._session != null)
+ {
+ _window._session.destroy();
+ }
+ });
+ }
+ private ChatWindow _window;
+ }
+
+ public ChatWindow()
+ {
+ Ice.Properties properties = Ice.Util.createProperties();
+ properties.load("config.client");
+
+ _factory = new SessionFactoryHelper(properties, this);
+ InitializeComponent();
+ Util.locateOnScreen(this);
+ }
+
+ private void
+ login(object sender, ExecutedRoutedEventArgs args)
+ {
+ LoginDialog loginDialog = new LoginDialog(_loginData);
+ Util.centerWindow(loginDialog, this);
+ if(loginDialog.ShowModal())
+ {
+ status.Content = "Connecting";
+ _factory.setRouterHost(_loginData.routerHost);
+ _factory.setRouterIdentity(new Ice.Identity("router", "DemoGlacier2"));
+ _session = _factory.connect(_loginData.userName, _loginData.password);
+
+ _cancelDialog = new CancelDialog();
+ Util.centerWindow(_cancelDialog, this);
+ if(_cancelDialog.ShowModal())
+ {
+ if(_session != null)
+ {
+ _session.destroy();
+ _session = null;
+ status.Content = "Connection canceled";
+ }
+ }
+ }
+ }
+
+ private void
+ logout(object sender, ExecutedRoutedEventArgs args)
+ {
+ status.Content = "Disconnecting";
+ _session.destroy();
+ _session = null;
+ }
+
+ private void
+ exit(object sender, ExecutedRoutedEventArgs args)
+ {
+ Close();
+ }
+
+ private void
+ windowClosed(object sender, EventArgs e)
+ {
+ lock(this)
+ {
+ if(_session != null)
+ {
+ _session.destroy();
+ _session = null;
+ }
+ }
+ App.Current.Shutdown(0);
+ }
+
+ private void
+ isLogoutEnabled(object sender, CanExecuteRoutedEventArgs args)
+ {
+ args.CanExecute = _session != null && _session.isConnected();
+ }
+
+ private void
+ isLoginEnabled(object sender,CanExecuteRoutedEventArgs args)
+ {
+ args.CanExecute = _session == null || !_session.isConnected();
+ }
+
+ //
+ // Event handler attached to txtChatImputLine onKeyDown.
+ // If the key is the Enter key, it sends the message asynchronously
+ // and cleans the input line; otherwise, it does nothing.
+ //
+ private void
+ sendMessage(object sender, KeyEventArgs e)
+ {
+ if(e.Key == Key.Enter)
+ {
+ string message = input.Text.Trim();
+ if(message.Length > 0)
+ {
+ _chat.say_async(new AMI_ChatSession_sayI(this), message);
+ }
+ input.Text = "";
+ }
+ }
+
+ private void
+ scrollDown(object sender, SizeChangedEventArgs e)
+ {
+ txtMessages.ScrollToEnd();
+ }
+
+ private void
+ closeCancelDialog()
+ {
+ if(_cancelDialog != null)
+ {
+ _cancelDialog.Close();
+ _cancelDialog = null;
+ }
+ }
+
+ public void
+ appendMessage(string message)
+ {
+ txtMessages.AppendText(message);
+ txtMessages.ScrollToEnd();
+ }
+
+ private LoginData _loginData = new LoginData();
+ private CancelDialog _cancelDialog = new CancelDialog();
+ private Glacier2.SessionFactoryHelper _factory;
+ private Glacier2.SessionHelper _session;
+ private Demo.ChatSessionPrx _chat;
+
+ #region Callback Members
+
+ public void connectFailed(SessionHelper session, Exception ex)
+ {
+ // If the session has been reassigned avoid the
+ // spurious callback.
+ if(session != _session)
+ {
+ return;
+ }
+
+ closeCancelDialog();
+ status.Content = ex.GetType();
+ }
+
+ public void connected(SessionHelper session)
+ {
+ // If the session has been reassigned avoid the
+ // spurious callback.
+ if(session != _session)
+ {
+ return;
+ }
+
+ Ice.Object servant = new ChatCallbackI(this);
+
+ Demo.ChatCallbackPrx callback = Demo.ChatCallbackPrxHelper.uncheckedCast(
+ _session.addWithUUID(servant));
+ _chat = Demo.ChatSessionPrxHelper.uncheckedCast(_session.session());
+ _chat.setCallback_async(new AMI_ChatSession_setCallbackI(this), callback);
+ }
+
+ public void createdCommunicator(SessionHelper session)
+ {
+ }
+
+ public void disconnected(SessionHelper session)
+ {
+ // If the session has been reassigned avoid the
+ // spurious callback.
+ if(session != _session)
+ {
+ return;
+ }
+ closeCancelDialog();
+ _session = null;
+ _chat = null;
+ input.IsEnabled = false;
+ status.Content = "Disconnected";
+ }
+
+ public Dispatcher getDispatcher()
+ {
+ return this.Dispatcher;// System.Windows.Application.Current.Dispatcher;
+ }
+
+ #endregion
+ }
+}
diff --git a/cs/demo/Glacier2/chat/Glacier2.chat.client.csproj b/cs/demo/Glacier2/chat/Glacier2.chat.client.csproj
new file mode 100755
index 00000000000..67b88ed8dda
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Glacier2.chat.client.csproj
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{53DCED47-A722-48EF-86D8-A10AD0594F21}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Glacier2.chat.client</RootNamespace>
+ <AssemblyName>Glacier2.chat.client</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>.\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Glacier2, Version=3.4.51.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\Glacier2.dll</HintPath>
+ </Reference>
+ <Reference Include="Ice, Version=3.4.51.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\Ice.dll</HintPath>
+ </Reference>
+ <Reference Include="IceSSL, Version=3.4.51.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\IceSSL.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="UIAutomationProvider">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="WindowsBase">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="PresentationCore">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="PresentationFramework">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Page Include="CancelDialog.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="ChatWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Page Include="LoginDialog.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="ChatWindow.xaml.cs">
+ <DependentUpon>ChatWindow.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CancelDialog.xaml.cs">
+ <DependentUpon>CancelDialog.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Chat.cs" />
+ <Compile Include="ChatCommands.cs" />
+ <Compile Include="LoginDialog.xaml.cs">
+ <DependentUpon>LoginDialog.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <None Include="Chat.ice" />
+ <None Include="config.client" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <ProjectExtensions>
+ <VisualStudio>
+ <UserProperties ZerocIce_Enabled="True" ZerocIce_Home="..\..\..\.." ZerocIce_HomeExpanded="..\..\..\.." />
+ </VisualStudio>
+ </ProjectExtensions>
+</Project> \ No newline at end of file
diff --git a/cs/demo/Glacier2/chat/LoginDialog.xaml b/cs/demo/Glacier2/chat/LoginDialog.xaml
new file mode 100755
index 00000000000..6a1791f5d45
--- /dev/null
+++ b/cs/demo/Glacier2/chat/LoginDialog.xaml
@@ -0,0 +1,41 @@
+<!--
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+-->
+<Window x:Class="Glacier2.chat.client.LoginDialog"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="LoginDialog" Height="160" Width="240" ResizeMode="NoResize">
+ <Grid>
+ <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Vertical"
+ MaxWidth="240">
+ <!-- Connection data -->
+ <StackPanel Orientation="Vertical">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Margin="2" Name="lblHost" Width="60">Host:</TextBlock>
+ <TextBox Margin="2" Name="txtHost" Width="120"></TextBox>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Margin="2" Name="lblUsername" Width="60">Username:</TextBlock>
+ <TextBox Margin="2" Name="txtUsername" Width="120"></TextBox>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Margin="2" TextWrapping="NoWrap" Width="60">Password:</TextBlock>
+ <PasswordBox Margin="2" Name="txtPassword" Width="120"></PasswordBox>
+ </StackPanel>
+ </StackPanel>
+
+ <!-- Login / Cancel buttons -->
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+ <Button Margin="2" MaxWidth="80" Click="login" IsDefault="True">Login</Button>
+ <Button Margin="2" MaxWidth="80" Click="cancel" IsDefault="True">Cancel</Button>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+</Window>
diff --git a/cs/demo/Glacier2/chat/LoginDialog.xaml.cs b/cs/demo/Glacier2/chat/LoginDialog.xaml.cs
new file mode 100755
index 00000000000..b9fbf56969e
--- /dev/null
+++ b/cs/demo/Glacier2/chat/LoginDialog.xaml.cs
@@ -0,0 +1,63 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Glacier2.chat.client
+{
+ /// <summary>
+ /// Interaction logic for LoginDialog.xaml
+ /// </summary>
+ public partial class LoginDialog : Window
+ {
+ public LoginDialog(LoginData loginData)
+ {
+ InitializeComponent();
+ _loginData = loginData;
+ txtHost.Text = _loginData.routerHost;
+ txtUsername.Text = _loginData.userName;
+ txtPassword.Password = _loginData.password;
+ }
+
+ public void login(object sender, RoutedEventArgs e)
+ {
+ _loginData.routerHost = txtHost.Text;
+ _loginData.userName = txtUsername.Text;
+ _loginData.password = txtPassword.Password;
+ _cancel = false;
+ Close();
+ }
+
+ public void cancel(object sender, RoutedEventArgs args)
+ {
+ _cancel = true;
+ Close();
+ }
+
+ public bool ShowModal()
+ {
+ ShowDialog();
+ return !_cancel;
+ }
+
+ private bool _cancel = true;
+ private LoginData _loginData;
+ }
+}
diff --git a/cs/demo/Glacier2/chat/Properties/AssemblyInfo.cs b/cs/demo/Glacier2/chat/Properties/AssemblyInfo.cs
new file mode 100755
index 00000000000..2d92f4d8b8e
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Glacier2.chat.client")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Glacier2.chat.client")]
+[assembly: AssemblyCopyright("Copyright © 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
+//inside a <PropertyGroup>. For example, if you are using US english
+//in your source files, set the <UICulture> to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/cs/demo/Glacier2/chat/Properties/Resources.Designer.cs b/cs/demo/Glacier2/chat/Properties/Resources.Designer.cs
new file mode 100755
index 00000000000..a96435df6e7
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Glacier2.chat.client.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Glacier2.chat.client.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/cs/demo/Glacier2/chat/Properties/Resources.resx b/cs/demo/Glacier2/chat/Properties/Resources.resx
new file mode 100755
index 00000000000..ffecec851ab
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Properties/Resources.resx
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file
diff --git a/cs/demo/Glacier2/chat/Properties/Settings.Designer.cs b/cs/demo/Glacier2/chat/Properties/Settings.Designer.cs
new file mode 100755
index 00000000000..6b363ea5353
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Glacier2.chat.client.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/cs/demo/Glacier2/chat/Properties/Settings.settings b/cs/demo/Glacier2/chat/Properties/Settings.settings
new file mode 100755
index 00000000000..8f2fd95d626
--- /dev/null
+++ b/cs/demo/Glacier2/chat/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile> \ No newline at end of file
diff --git a/cs/demo/Glacier2/chat/config.client b/cs/demo/Glacier2/chat/config.client
new file mode 100755
index 00000000000..46cdd0d9b20
--- /dev/null
+++ b/cs/demo/Glacier2/chat/config.client
@@ -0,0 +1,39 @@
+#
+# Warn about connection exceptions
+#
+#Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
+
+#
+# Security Tracing
+#
+# 0 = no security tracing
+# 1 = trace messages
+#
+#IceSSL.Trace.Security=1
+
+#
+# SSL Configuration
+#
+Ice.Plugin.IceSSL=IceSSL:IceSSL.PluginFactory
+IceSSL.DefaultDir=../../../../certs
+IceSSL.ImportCert.CurrentUser.Root=cacert.pem
+IceSSL.CertFile=c_rsa1024.pfx
+IceSSL.Password=password
diff --git a/cs/demo/Ice/wpf/App.xaml b/cs/demo/Ice/wpf/App.xaml
new file mode 100644
index 00000000000..1495236cb4e
--- /dev/null
+++ b/cs/demo/Ice/wpf/App.xaml
@@ -0,0 +1,18 @@
+<!--
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+-->
+<Application x:Class="Ice.wpf.client.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ StartupUri="HelloWindow.xaml">
+ <Application.Resources>
+
+ </Application.Resources>
+</Application>
diff --git a/cs/demo/Ice/wpf/App.xaml.cs b/cs/demo/Ice/wpf/App.xaml.cs
new file mode 100644
index 00000000000..4f42b9a436a
--- /dev/null
+++ b/cs/demo/Ice/wpf/App.xaml.cs
@@ -0,0 +1,25 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Windows;
+
+namespace Ice.wpf.client
+{
+ /// <summary>
+ /// Interaction logic for App.xaml
+ /// </summary>
+ public partial class App : System.Windows.Application
+ {
+ }
+}
diff --git a/cs/demo/Ice/wpf/Hello.ice b/cs/demo/Ice/wpf/Hello.ice
new file mode 100644
index 00000000000..b5c9e4a599e
--- /dev/null
+++ b/cs/demo/Ice/wpf/Hello.ice
@@ -0,0 +1,24 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+#ifndef HELLO_ICE
+#define HELLO_ICE
+
+module Demo
+{
+
+interface Hello
+{
+ ["ami"] idempotent void sayHello(int delay);
+ ["ami"] void shutdown();
+};
+
+};
+
+#endif
diff --git a/cs/demo/Ice/wpf/HelloWindow.xaml b/cs/demo/Ice/wpf/HelloWindow.xaml
new file mode 100644
index 00000000000..7202bf843ab
--- /dev/null
+++ b/cs/demo/Ice/wpf/HelloWindow.xaml
@@ -0,0 +1,91 @@
+<!--
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+-->
+<Window x:Class="Ice.wpf.client.HelloWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="Ice - Hello World!" SizeToContent="WidthAndHeight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
+ Loaded="Window_Loaded" Closed="Window_Closed" Width="300" Height="190" MinWidth="300" MinHeight="190">
+ <Grid Margin="10">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+
+ <Grid Grid.Row="0" Grid.Column="0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="2*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" MinHeight="23" />
+ <RowDefinition Height="Auto" MinHeight="23" />
+ <RowDefinition Height="Auto" MinHeight="28" />
+ <RowDefinition Height="Auto" MinHeight="23" />
+ </Grid.RowDefinitions>
+ <Label Grid.Row="0" Grid.Column="0" Name="label4" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" >Hostname</Label>
+ <Label Grid.Row="1" Grid.Column="0" Name="label2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70">Mode</Label>
+ <Label Grid.Row="2" Grid.Column="0" Name="label1" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top" Width="70">Timeout</Label>
+ <Label Grid.Row="3" Grid.Column="0" Name="label3" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70">Delay</Label>
+
+ <TextBox Grid.Row="0" Grid.Column="1" Name="hostname" VerticalAlignment="Top">127.0.0.1</TextBox>
+ <ComboBox Grid.Row="1" Grid.Column="1" Name="deliveryMode" VerticalAlignment="Top" IsReadOnly="True" SelectedIndex="0">
+ <ComboBoxItem>Twoway</ComboBoxItem>
+ <ComboBoxItem>Twoway Secure</ComboBoxItem>
+ <ComboBoxItem>Oneway</ComboBoxItem>
+ <ComboBoxItem>Oneway Batch</ComboBoxItem>
+ <ComboBoxItem>Oneway Secure</ComboBoxItem>
+ <ComboBoxItem>Oneway Secure Batch</ComboBoxItem>
+ <ComboBoxItem>Datagram</ComboBoxItem>
+ <ComboBoxItem>Datagram Batch</ComboBoxItem>
+ </ComboBox>
+ <Grid Grid.Row="2" Grid.Column="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="4*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Slider Grid.Row="0" Grid.Column="0" Name="timeoutSlider" VerticalAlignment="Top" Maximum="5000" Height="22" ValueChanged="timeoutSlider_ValueChanged" />
+ <Label Grid.Row="0" Grid.Column="1" Name="timeoutLabel" VerticalAlignment="Top" HorizontalAlignment="Left">0.0</Label>
+ </Grid>
+ <Grid Grid.Row="3" Grid.Column="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="4*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Slider Grid.Row="0" Grid.Column="0" Name="delaySlider" VerticalAlignment="Top" Maximum="5000" Height="22" ValueChanged="delaySlider_ValueChanged" />
+ <Label Grid.Row="0" Grid.Column="1" Name="delayLabel" VerticalAlignment="Top" HorizontalAlignment="Left">0.0</Label>
+ </Grid>
+ </Grid>
+ <Grid Grid.Row="1" Grid.Column="0" Margin="0 10 0 5">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Button Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Name="sayHello" Click="sayHello_Click">Hello World!</Button>
+ <Button Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Name="shutdown" Click="shutdown_Click">Shutdown</Button>
+ <Button Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Name="flush" Click="flush_Click">Flush</Button>
+ </Grid>
+ <Label Grid.Row="2" Grid.Column="0" Name="status">Ready</Label>
+ </Grid>
+</Window>
diff --git a/cs/demo/Ice/wpf/HelloWindow.xaml.cs b/cs/demo/Ice/wpf/HelloWindow.xaml.cs
new file mode 100644
index 00000000000..ed71cad4e14
--- /dev/null
+++ b/cs/demo/Ice/wpf/HelloWindow.xaml.cs
@@ -0,0 +1,358 @@
+// **********************************************************************
+//
+// Copyright(c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+using System.Diagnostics;
+
+namespace Ice.wpf.client
+{
+ /// <summary>
+ /// Interaction logic for HelloWindow.xaml
+ /// </summary>
+ public partial class HelloWindow : Window
+ {
+ public HelloWindow()
+ {
+ InitializeComponent();
+ locateOnScreen(this);
+ }
+
+ static String TWOWAY = "Twoway";
+ static String TWOWAY_SECURE = "Twoway Secure";
+ static String ONEWAY = "Oneway";
+ static String ONEWAY_BATCH = "Oneway Batch";
+ static String ONEWAY_SECURE = "Oneway Secure";
+ static String ONEWAY_SECURE_BATCH = "Oneway Secure Batch";
+ static String DATAGRAM = "Datagram";
+ static String DATAGRAM_BATCH = "Datagram Batch";
+
+ private void Window_Loaded(object sender, EventArgs e)
+ {
+ try
+ {
+ Ice.InitializationData initData = new Ice.InitializationData();
+ initData.properties = Ice.Util.createProperties();
+ initData.properties.load("config.client");
+ _communicator = Ice.Util.initialize(initData);
+ }
+ catch(Ice.LocalException ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ private void Window_Closed(object sender, EventArgs e)
+ {
+ if(_communicator == null)
+ {
+ return;
+ }
+
+ _communicator.destroy();
+ _communicator = null;
+ }
+
+ private bool deliveryModeIsBatch()
+ {
+ return deliveryMode.Text.Equals(ONEWAY_BATCH) ||
+ deliveryMode.Text.Equals(ONEWAY_SECURE_BATCH) ||
+ deliveryMode.Text.Equals(DATAGRAM_BATCH);
+ }
+
+ private Ice.ObjectPrx deliveryModeApply(Ice.ObjectPrx prx)
+ {
+ if(deliveryMode.Text.Equals(TWOWAY))
+ {
+ prx = prx.ice_twoway();
+ }
+ else if(deliveryMode.Text.Equals(TWOWAY_SECURE))
+ {
+ prx = prx.ice_twoway().ice_secure(true);
+ }
+ else if(deliveryMode.Text.Equals(ONEWAY))
+ {
+ prx = prx.ice_oneway();
+ }
+ else if(deliveryMode.Text.Equals(ONEWAY_BATCH))
+ {
+ prx = prx.ice_batchOneway();
+ }
+ else if(deliveryMode.Text.Equals(ONEWAY_SECURE))
+ {
+ prx = prx.ice_oneway().ice_secure(true);
+ }
+ else if(deliveryMode.Text.Equals(ONEWAY_SECURE_BATCH))
+ {
+ prx = prx.ice_batchOneway().ice_secure(true);
+ }
+ else if(deliveryMode.Text.Equals(DATAGRAM))
+ {
+ prx = prx.ice_datagram();
+ }
+ else if(deliveryMode.Text.Equals(DATAGRAM_BATCH))
+ {
+ prx = prx.ice_batchDatagram();
+ }
+
+ return prx;
+ }
+
+ class SayHelloI : Demo.AMI_Hello_sayHello, Ice.AMISentCallback
+ {
+ public SayHelloI(HelloWindow window)
+ {
+ _window = window;
+ }
+
+ public override void ice_response()
+ {
+ lock(this)
+ {
+ Debug.Assert(!_response);
+ _response = true;
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ _window.status.Content = "Ready";
+ });
+ }
+ }
+
+ public override void ice_exception(Exception ex)
+ {
+ lock(this)
+ {
+ Debug.Assert(!_response);
+ _response = true;
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ _window.handleException(ex);
+ });
+ }
+ }
+
+ #region AMISentCallback Members
+
+ public void ice_sent()
+ {
+ lock(this)
+ {
+ if(_response)
+ {
+ return;
+ }
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ if(_window.deliveryMode.Text.Equals(TWOWAY) || _window.deliveryMode.Text.Equals(TWOWAY_SECURE))
+ {
+ _window.status.Content = "Waiting for response";
+ }
+ else
+ {
+ _window.status.Content = "Ready";
+ }
+ });
+ }
+ }
+
+ #endregion
+
+ private bool _response = false;
+ private HelloWindow _window;
+ }
+
+ private void sayHello_Click(object sender, RoutedEventArgs e)
+ {
+ Demo.HelloPrx hello = createProxy();
+ if(hello == null)
+ {
+ return;
+ }
+
+ int delay =(int)delaySlider.Value;
+ try
+ {
+ if(!deliveryModeIsBatch())
+ {
+ if(hello.sayHello_async(new SayHelloI(this), delay))
+ {
+ if(deliveryMode.Text.Equals(TWOWAY) || deliveryMode.Text.Equals(TWOWAY_SECURE))
+ {
+ status.Content = "Waiting for response";
+ }
+ }
+ else
+ {
+ status.Content = "Sending request";
+ }
+ }
+ else
+ {
+ flush.IsEnabled = true;
+ hello.sayHello(delay);
+ status.Content = "Queued sayHello request";
+ }
+ }
+ catch(Ice.LocalException ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ private void handleException(Exception ex)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ status.Content = ex.GetType();
+ });
+ }
+
+ class ShutdownI : Demo.AMI_Hello_shutdown
+ {
+ public ShutdownI(HelloWindow window)
+ {
+ _window = window;
+ }
+
+ public override void ice_response()
+ {
+ lock(this)
+ {
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ _window.status.Content = "Ready";
+ });
+ }
+ }
+
+ public override void ice_exception(Exception ex)
+ {
+ lock(this)
+ {
+ _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ _window.handleException(ex);
+ });
+ }
+ }
+
+ private HelloWindow _window;
+ }
+
+ private void shutdown_Click(object sender, RoutedEventArgs e)
+ {
+ Demo.HelloPrx hello = createProxy();
+ if(hello == null)
+ {
+ return;
+ }
+
+ int delay =(int)delaySlider.Value;
+
+ try
+ {
+ if(!deliveryModeIsBatch())
+ {
+ if(hello.shutdown_async(new ShutdownI(this)))
+ {
+ if(deliveryMode.Text.Equals("Twoway") || deliveryMode.Text.Equals("Twoway Secure"))
+ {
+ status.Content = "Waiting for response";
+ }
+ }
+ else
+ {
+ status.Content = "Sending request";
+ }
+ }
+ else
+ {
+ flush.IsEnabled = true;
+ hello.shutdown();
+ status.Content = "Queued shutdown request";
+ }
+ }
+ catch(Ice.LocalException ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ private void flush_Click(object sender, RoutedEventArgs e)
+ {
+ new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
+ {
+ try
+ {
+ _communicator.flushBatchRequests();
+ }
+ catch(Ice.LocalException ex)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)delegate()
+ {
+ handleException(ex);
+ });
+ }
+ })).Start();
+ flush.IsEnabled = false;
+ status.Content = "Flushed batch requests";
+ }
+
+ Demo.HelloPrx
+ createProxy()
+ {
+ String host = hostname.Text.Trim();
+ if(host.Length == 0)
+ {
+ status.Content = "No hostname";
+ return null;
+ }
+
+ String s = "hello:tcp -h " + host + " -p 10000:ssl -h " + host + " -p 10001:udp -h " + host + " -p 10000";
+ Ice.ObjectPrx prx = _communicator.stringToProxy(s);
+ prx = deliveryModeApply(prx);
+ int timeout =(int)timeoutSlider.Value;
+ if(timeout != 0)
+ {
+ prx = prx.ice_timeout(timeout);
+ }
+ return Demo.HelloPrxHelper.uncheckedCast(prx);
+ }
+
+ private void timeoutSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+ {
+ timeoutLabel.Content =(timeoutSlider.Value / 1000.0).ToString("F1");
+ }
+
+ private void delaySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+ {
+ delayLabel.Content =(delaySlider.Value / 1000.0).ToString("F1");
+ }
+
+ static private void locateOnScreen(System.Windows.Window window)
+ {
+ window.Left =(System.Windows.SystemParameters.PrimaryScreenWidth - window.Width) / 2;
+ window.Top =(System.Windows.SystemParameters.PrimaryScreenHeight - window.Height) / 2;
+ }
+
+ private Ice.Communicator _communicator = null;
+ }
+}
diff --git a/cs/demo/Ice/wpf/Ice.wpf.client.csproj b/cs/demo/Ice/wpf/Ice.wpf.client.csproj
new file mode 100644
index 00000000000..8332c86fbf4
--- /dev/null
+++ b/cs/demo/Ice/wpf/Ice.wpf.client.csproj
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{1EB710F0-E760-499B-BFD6-24E3B7A132E8}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Ice.wpf.client</RootNamespace>
+ <AssemblyName>client</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>.\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Ice, Version=3.4.51.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\Ice.dll</HintPath>
+ </Reference>
+ <Reference Include="IceSSL, Version=3.4.51.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\IceSSL.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="WindowsBase" />
+ <Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Page Include="HelloWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="HelloWindow.xaml.cs">
+ <DependentUpon>HelloWindow.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Hello.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <None Include="Hello.ice" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <ProjectExtensions>
+ <VisualStudio>
+ <UserProperties ZerocIce_Home="..\..\..\.." ZerocIce_HomeExpanded="..\..\..\.." ZerocIce_Enabled="True" />
+ </VisualStudio>
+ </ProjectExtensions>
+</Project> \ No newline at end of file
diff --git a/cs/demo/Ice/wpf/Properties/AssemblyInfo.cs b/cs/demo/Ice/wpf/Properties/AssemblyInfo.cs
new file mode 100755
index 00000000000..83b624aa550
--- /dev/null
+++ b/cs/demo/Ice/wpf/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Ice.wpf.client")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Ice.wpf.client")]
+[assembly: AssemblyCopyright("Copyright © 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
+//inside a <PropertyGroup>. For example, if you are using US english
+//in your source files, set the <UICulture> to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/cs/demo/Ice/wpf/Properties/Resources.Designer.cs b/cs/demo/Ice/wpf/Properties/Resources.Designer.cs
new file mode 100755
index 00000000000..f40e7d965b2
--- /dev/null
+++ b/cs/demo/Ice/wpf/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Ice.wpf.client.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ice.wpf.client.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/cs/demo/Ice/wpf/Properties/Resources.resx b/cs/demo/Ice/wpf/Properties/Resources.resx
new file mode 100755
index 00000000000..ffecec851ab
--- /dev/null
+++ b/cs/demo/Ice/wpf/Properties/Resources.resx
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file
diff --git a/cs/demo/Ice/wpf/Properties/Settings.Designer.cs b/cs/demo/Ice/wpf/Properties/Settings.Designer.cs
new file mode 100755
index 00000000000..f3bff7a3a95
--- /dev/null
+++ b/cs/demo/Ice/wpf/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Ice.wpf.client.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/cs/demo/Ice/wpf/Properties/Settings.settings b/cs/demo/Ice/wpf/Properties/Settings.settings
new file mode 100755
index 00000000000..8f2fd95d626
--- /dev/null
+++ b/cs/demo/Ice/wpf/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile> \ No newline at end of file
diff --git a/cs/demo/Ice/wpf/config.client b/cs/demo/Ice/wpf/config.client
new file mode 100644
index 00000000000..35fc5c8b060
--- /dev/null
+++ b/cs/demo/Ice/wpf/config.client
@@ -0,0 +1,45 @@
+#
+# The client reads this property to create the reference to the
+# "hello" object in the server.
+#
+Hello.Proxy=hello:tcp -p 10000:udp -p 10000:ssl -p 10001
+
+#
+# Warn about connection exceptions.
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
+
+#
+# Security Tracing
+#
+# 0 = no security tracing
+# 1 = trace messages
+#
+#IceSSL.Trace.Security=1
+
+#
+# SSL Configuration
+#
+Ice.Plugin.IceSSL=IceSSL:IceSSL.PluginFactory
+IceSSL.DefaultDir=../../../../certs
+IceSSL.ImportCert.CurrentUser.Root=cacert.pem
+IceSSL.CertFile=c_rsa1024.pfx
+IceSSL.Password=password
diff --git a/cs/demo/demo.sln b/cs/demo/demo.sln
index 0e56951020e..898f59a661c 100755
--- a/cs/demo/demo.sln
+++ b/cs/demo/demo.sln
@@ -169,6 +169,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ice.plugin.server", "Ice\pl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ice.plugin.hello", "Ice\plugin\Ice.plugin.hello.csproj", "{8D371651-BFA4-43C9-B143-77F0CCEEBB10}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ice.wpf.client", "Ice\wpf\Ice.wpf.client.csproj", "{1EB710F0-E760-499B-BFD6-24E3B7A132E8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glacier2.chat.client", "Glacier2\chat\Glacier2.chat.client.csproj", "{53DCED47-A722-48EF-86D8-A10AD0594F21}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -363,6 +367,14 @@ Global
{8D371651-BFA4-43C9-B143-77F0CCEEBB10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D371651-BFA4-43C9-B143-77F0CCEEBB10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D371651-BFA4-43C9-B143-77F0CCEEBB10}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1EB710F0-E760-499B-BFD6-24E3B7A132E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1EB710F0-E760-499B-BFD6-24E3B7A132E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1EB710F0-E760-499B-BFD6-24E3B7A132E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1EB710F0-E760-499B-BFD6-24E3B7A132E8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {53DCED47-A722-48EF-86D8-A10AD0594F21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {53DCED47-A722-48EF-86D8-A10AD0594F21}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {53DCED47-A722-48EF-86D8-A10AD0594F21}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {53DCED47-A722-48EF-86D8-A10AD0594F21}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/cs/src/Glacier2/Application.cs b/cs/src/Glacier2/Application.cs
new file mode 100644
index 00000000000..a082f943af0
--- /dev/null
+++ b/cs/src/Glacier2/Application.cs
@@ -0,0 +1,508 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Diagnostics;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace Glacier2
+{
+
+/// <sumary>
+/// Utility base class that makes it easy to to correctly initialize and finalize
+/// the Ice run time, as well as handle signals. Unless the application specifies
+/// a logger, Application installs a per-process logger that logs to the standard
+/// error output.
+///
+/// Applications must create a derived class that implements the {@link #run} method.
+///
+/// A program can contain only one instance of this class.
+/// </sumary>
+public abstract class Application : Ice.Application
+{
+ /// <sumary>
+ /// This exception is raised if the session should be restarted.
+ /// </sumary>
+ public class RestartSessionException : System.Exception
+ {
+ }
+
+ /// <sumary>
+ /// Initializes an instance that calls Communicator.shutdown if
+ /// a signal is received.
+ /// </sumary>
+ public
+ Application()
+ {
+ }
+
+ /// <sumary>
+ /// Initializes an instance that handles signals according to the signal
+ /// policy.
+ /// </sumary>
+ /// <param name="signalPolicy">@param signalPolicy Determines how to
+ /// respond to signals.</param>
+ public
+ Application(Ice.SignalPolicy signalPolicy) : base(signalPolicy)
+ {
+ }
+
+
+ /// <sumary>
+ /// Called once the communicator has been initialized and the Glacier2 session
+ /// has been established. A derived class must implement <code>runWithSession</code>,
+ /// which is the application's starting method.
+ /// </sumary>
+ /// <param name="args"> The argument vector for the application. Application
+ /// scans the argument vector passed to <code>main</code> for options that are
+ /// specific to the Ice run time and removes them; therefore, the vector passed
+ /// to <code>run</code> is free from Ice-related options and contains only options
+ /// and arguments that are application-specific.</param>
+ ///
+ /// <returns> The runWithSession method should return zero for successful
+ /// termination, and non-zero otherwise. Application.main returns the
+ /// value returned by runWithSession.</returns>
+ ///
+ public abstract int
+ runWithSession(string[] args);
+
+ /// <sumary>
+ /// Run should not be overridden for Glacier2.Application. Instead
+ /// runWithSession should be used.
+ /// </sumary>
+ public override int
+ run(string[] args)
+ {
+ // This shouldn't be called.
+ Debug.Assert(false);
+ return 0;
+ }
+
+ /// <sumary>
+ /// Called to restart the application's Glacier2 session. This
+ /// method never returns.
+ /// </sumary>
+ /// <returns>throws RestartSessionException This exception is
+ /// always thrown.</returns>
+ ///
+ public void
+ restart()
+ {
+ throw new RestartSessionException();
+ }
+
+ /// <sumary>
+ /// Creates a new Glacier2 session. A call to createSession always
+ /// precedes a call to runWithSession. If Ice.LocalException is thrown
+ /// from this method, the application is terminated.
+ /// </sumary>
+ /// <returns> The Glacier2 session.</returns>
+ public abstract Glacier2.SessionPrx
+ createSession();
+
+ /// <sumary>
+ /// Called when the base class detects that the session has been destroyed.
+ /// A subclass can override this method to take action after the loss of
+ /// connectivity with the Glacier2 router.
+ /// </sumary>
+ public virtual void
+ sessionDestroyed()
+ {
+ }
+
+ /// <sumary>
+ /// Returns the Glacier2 router proxy
+ /// </sumary>
+ /// <returns>The router proxy.</returns>
+ public static Glacier2.RouterPrx
+ router()
+ {
+ return _router;
+ }
+
+ /// <sumary>
+ /// Returns the Glacier2 session proxy
+ /// </sumary>
+ /// <returns>The session proxy.</returns>
+ public static Glacier2.SessionPrx
+ session()
+ {
+ return _session;
+ }
+
+ /// <sumary>
+ /// Returns the category to be used in the identities of all of the client's
+ /// callback objects. Clients must use this category for the router to
+ /// forward callback requests to the intended client.
+ /// Throws SessionNotExistException if no session exists.
+ /// </sumary>
+ /// <returns>The category.</returns>
+ public string
+ categoryForClient()
+ {
+ if(_router == null)
+ {
+ throw new SessionNotExistException();
+ }
+ return router().getCategoryForClient();
+ }
+
+ /// <sumary>
+ /// Create a new Ice identity for callback objects with the given
+ /// identity name field.
+ /// </sumary>
+ /// <returns>The identity.</returns>
+ public Ice.Identity
+ createCallbackIdentity(string name)
+ {
+ return new Ice.Identity(name, categoryForClient());
+ }
+
+ /// <sumary>
+ /// Adds a servant to the callback object adapter's Active Servant Map with a UUID.
+ /// </sumary>
+ /// <param name="servant">The servant to add.</param>
+ /// <returns>The proxy for the servant.</returns>
+ public Ice.ObjectPrx
+ addWithUUID(Ice.Object servant)
+ {
+ return objectAdapter().add(servant, createCallbackIdentity(Guid.NewGuid().ToString()));
+ }
+
+ /// <sumary>
+ /// Creates an object adapter for callback objects.
+ /// </sumary>
+ /// <returns>The object adapter.</returns>
+ public Ice.ObjectAdapter
+ objectAdapter()
+ {
+ lock(this)
+ {
+ if(_adapter == null)
+ {
+ if(_router == null)
+ {
+ throw new SessionNotExistException();
+ }
+ // TODO: Depending on the resolution of
+ // http://bugzilla/bugzilla/show_bug.cgi?id=4264 the OA
+ // name could be an empty string.
+ _adapter = communicator().createObjectAdapterWithRouter(Guid.NewGuid().ToString(), _router);
+ _adapter.activate();
+ }
+ return _adapter;
+ }
+ }
+
+ private class SessionPingThread
+ {
+ public SessionPingThread(Application app, Glacier2.RouterPrx router, long period)
+ {
+ _app = app;
+ _router = router;
+ _period = period;
+ _done = false;
+ }
+
+ private class AMI_Router_refreshSessionI : Glacier2.AMI_Router_refreshSession
+ {
+ public AMI_Router_refreshSessionI(Application app, SessionPingThread ping)
+ {
+ _app = app;
+ _ping = ping;
+ }
+
+ public override void
+ ice_response()
+ {
+ }
+
+ public override void
+ ice_exception(Ice.Exception ex)
+ {
+ // Here the session has gone. The thread
+ // terminates, and we notify the
+ // application that the session has been
+ // destroyed.
+ _ping.done();
+ _app.sessionDestroyed();
+ }
+
+ private SessionPingThread _ping;
+ private Application _app;
+ }
+
+ public void
+ run()
+ {
+ lock(this)
+ {
+ while(!_done)
+ {
+ _router.refreshSession_async(new AMI_Router_refreshSessionI(_app, this));
+ if(!_done)
+ {
+ Monitor.Wait(this, (int)_period);
+ }
+ }
+ }
+ }
+
+ public void
+ done()
+ {
+ lock(this)
+ {
+ if(!_done)
+ {
+ _done = true;
+ Monitor.PulseAll(this);
+ }
+ }
+ }
+
+ private Application _app;
+ private Glacier2.RouterPrx _router;
+ private long _period;
+ private bool _done = false;
+ }
+
+ protected override int
+ doMain(string[] originArgs, Ice.InitializationData initData)
+ {
+ // Set the default properties for all Glacier2 applications.
+ initData.properties.setProperty("Ice.ACM.Client", "0");
+ initData.properties.setProperty("Ice.RetryIntervals", "-1");
+
+ bool restart;
+ int ret = 0;
+ do
+ {
+ // A copy of the initialization data and the string seq
+ // needs to be passed to doMainInternal, as these can be
+ // changed by the application.
+ Ice.InitializationData id = (Ice.InitializationData)initData.Clone();
+ id.properties = id.properties.ice_clone_();
+ string[] args = (string[]) originArgs.Clone();
+
+ restart = doMain(args, id, out ret);
+ }
+ while(restart);
+ return ret;
+ }
+
+ private bool
+ doMain(string[] args, Ice.InitializationData initData, out int status)
+ {
+ // Reset internal state variables from Ice.Application. The
+ // remainder are reset at the end of this method.
+ callbackInProgress__ = false;
+ destroyed__ = false;
+ interrupted__ = false;
+
+ bool restart = false;
+ status = 0;
+
+ SessionPingThread ping = null;
+ Thread pingThread = null;
+ try
+ {
+ communicator__ = Ice.Util.initialize(ref args, initData);
+
+ _router = Glacier2.RouterPrxHelper.uncheckedCast(communicator().getDefaultRouter());
+ if(_router == null)
+ {
+ Ice.Util.getProcessLogger().error(appName__ + ": no glacier2 router configured");
+ status = 1;
+ }
+ else
+ {
+ //
+ // The default is to destroy when a signal is received.
+ //
+ if(signalPolicy__ == Ice.SignalPolicy.HandleSignals)
+ {
+ destroyOnInterrupt();
+ }
+
+ // If createSession throws, we're done.
+ try
+ {
+ _session = createSession();
+ _createdSession = true;
+ }
+ catch(Ice.LocalException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ status = 1;
+ }
+
+ if(_createdSession)
+ {
+ ping = new SessionPingThread(this, _router, (_router.getSessionTimeout() * 1000) / 2);
+ pingThread = new Thread(new ThreadStart(ping.run));
+ pingThread.Start();
+ status = runWithSession(args);
+ }
+ }
+ }
+ // We want to restart on those exceptions which indicate a
+ // break down in communications, but not those exceptions that
+ // indicate a programming logic error (ie: marshal, protocol
+ // failure, etc).
+ catch(RestartSessionException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ restart = true;
+ }
+ catch(Ice.ConnectionRefusedException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ restart = true;
+ }
+ catch(Ice.ConnectionLostException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ restart = true;
+ }
+ catch(Ice.UnknownLocalException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ restart = true;
+ }
+ catch(Ice.RequestFailedException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ restart = true;
+ }
+ catch(Ice.TimeoutException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ restart = true;
+ }
+ catch(Ice.LocalException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ status = 1;
+ }
+ catch(System.Exception ex)
+ {
+ Ice.Util.getProcessLogger().error("unknown exception" + ex.ToString());
+ status = 1;
+ }
+
+ //
+ // Don't want any new interrupt. And at this point
+ // (post-run), it would not make sense to release a held
+ // signal to run shutdown or destroy.
+ //
+ if(signalPolicy__ == Ice.SignalPolicy.HandleSignals)
+ {
+ ignoreInterrupt();
+ }
+
+ lock(mutex__)
+ {
+ while(callbackInProgress__)
+ {
+ Monitor.Wait(mutex__);
+ }
+
+ if(destroyed__)
+ {
+ communicator__ = null;
+ }
+ else
+ {
+ destroyed__ = true;
+ //
+ // And communicator__ != null, meaning will be
+ // destroyed next, destroyed__ = true also ensures that
+ // any remaining callback won't do anything
+ //
+ }
+ }
+
+ if(ping != null)
+ {
+ ping.done();
+ ping = null;
+ while(true)
+ {
+ try
+ {
+ pingThread.Join();
+ break;
+ }
+ catch(ThreadInterruptedException)
+ {
+ }
+ }
+ pingThread = null;
+ }
+
+ if(_createdSession && _router != null)
+ {
+ try
+ {
+ _router.destroySession();
+ }
+ catch(Ice.ConnectionLostException)
+ {
+ // Expected: the router closed the connection.
+ }
+ catch(Glacier2.SessionNotExistException)
+ {
+ // This can also occur.
+ }
+ catch(System.Exception ex)
+ {
+ // Not expected.
+ Ice.Util.getProcessLogger().error("unexpected exception when destroying the session" + ex.ToString());
+ }
+ _router = null;
+ }
+
+ if(communicator__ != null)
+ {
+ try
+ {
+ communicator__.destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ Ice.Util.getProcessLogger().error(ex.ToString());
+ status = 1;
+ }
+ catch(System.Exception ex)
+ {
+ Ice.Util.getProcessLogger().error("unknown exception " + ex.ToString());
+ status = 1;
+ }
+ communicator__ = null;
+ }
+
+ // Reset internal state. We cannot reset the Application state
+ // here, since destroyed__ must remain true until we re-run
+ // this method.
+ _adapter = null;
+ _router = null;
+ _session = null;
+ _createdSession = false;
+
+ return restart;
+ }
+
+ private static Ice.ObjectAdapter _adapter;
+ private static Glacier2.RouterPrx _router;
+ private static Glacier2.SessionPrx _session;
+ private static bool _createdSession = false;
+}
+} \ No newline at end of file
diff --git a/cs/src/Glacier2/Makefile b/cs/src/Glacier2/Makefile
index 02031b947ef..f82d108bf6e 100644
--- a/cs/src/Glacier2/Makefile
+++ b/cs/src/Glacier2/Makefile
@@ -14,7 +14,8 @@ LIBNAME = $(PKG).dll
TARGETS = $(bindir)/$(LIBNAME)
POLICY_TARGET = $(POLICY).dll
-SRCS = AssemblyInfo.cs
+SRCS = AssemblyInfo.cs \
+ Application.cs
SLICE_SRCS = $(SDIR)/PermissionsVerifier.ice \
$(SDIR)/Router.ice \
diff --git a/cs/src/Glacier2/Makefile.mak b/cs/src/Glacier2/Makefile.mak
index e89d2930bfe..8876f7e9336 100644
--- a/cs/src/Glacier2/Makefile.mak
+++ b/cs/src/Glacier2/Makefile.mak
@@ -14,7 +14,10 @@ LIBNAME = $(PKG).dll
TARGETS = $(bindir)\$(LIBNAME)
POLICY_TARGET = $(POLICY).dll
-SRCS = AssemblyInfo.cs
+SRCS = SessionFactoryHelper.cs \
+ SessionHelper.cs \
+ Application.cs \
+ AssemblyInfo.cs
GEN_SRCS = $(GDIR)\PermissionsVerifier.cs \
$(GDIR)\Router.cs \
@@ -28,7 +31,7 @@ GDIR = generated
MCSFLAGS = $(MCSFLAGS) -target:library -out:$(TARGETS) -warnaserror-
MCSFLAGS = $(MCSFLAGS) -keyfile:$(KEYFILE)
-MCSFLAGS = $(MCSFLAGS) /doc:$(bindir)\$(PKG).xml /nowarn:1591
+MCSFLAGS = $(MCSFLAGS) /doc:$(bindir)\$(PKG).xml /nowarn:1591 -r:WindowsBase.dll
SLICE2CSFLAGS = $(SLICE2CSFLAGS) -I$(slicedir)
diff --git a/cs/src/Glacier2/SessionFactoryHelper.cs b/cs/src/Glacier2/SessionFactoryHelper.cs
new file mode 100644
index 00000000000..1f939a27422
--- /dev/null
+++ b/cs/src/Glacier2/SessionFactoryHelper.cs
@@ -0,0 +1,360 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Text;
+
+namespace Glacier2
+{
+
+/// <sumary>
+/// A helper class for using Glacier2 with GUI applications.
+///
+/// Applications should create a session factory for each Glacier2 router to which the application will
+/// connect. To connect with the Glacier2 router, call SessionFactory.connect. The callback object is
+/// notified of the various life cycle events. Once the session is torn down for whatever reason, the application
+/// can use the session factory to create another connection.
+/// </sumary>
+public class SessionFactoryHelper
+{
+ /// <sumary>
+ /// A callback class to get notifications of status changes in the Glacier2 session.
+ /// All callbacks on the <code>Callback</code> interface occur in the main swing thread.
+ /// </sumary>
+ public interface Callback
+ {
+ /// <sumary>
+ /// Notifies the application that the communicator was created.
+ /// </sumary>
+ /// <param name="session">The Glacier2 session.</param>
+ void
+ createdCommunicator(SessionHelper session);
+
+ /// <sumary>
+ /// Notifies the application that the Glacier2 session has been established.
+ /// </sumary>
+ /// <param name="session">The established session.</param>
+ void
+ connected(SessionHelper session);
+
+ /// <sumary>
+ /// Notifies the application that the Glacier2 session has been disconnected.
+ /// </sumary>
+ /// <param name="session">The disconnected session.</param>
+ void
+ disconnected(SessionHelper session);
+
+ /// <sumary>
+ /// Notifies the application that the Glacier2 session establishment failed.
+ /// </sumary>
+ /// <param name="session">The session reporting the connection failure.</param>
+ /// <param name="ex">The exception.</param>
+ void
+ connectFailed(SessionHelper session, Exception ex);
+
+ System.Windows.Threading.Dispatcher
+ getDispatcher();
+ }
+
+ /// <sumary>
+ /// Creates a SessionFactory object.
+ /// </sumary>
+ /// <param name="callback">The callback object for notifications.</param>
+ public
+ SessionFactoryHelper(Callback callback)
+ {
+ _callback = callback;
+ _initData = new Ice.InitializationData();
+ _initData.properties = Ice.Util.createProperties();
+ setDefaultProperties();
+ }
+
+ /// <sumary>
+ /// Creates a SessionFactory object.
+ /// </sumary>
+ /// <param name="initData">The initialization data to use when creating the communicator.</param>
+ /// <param name="callback">The callback object for notifications.</param>
+ public
+ SessionFactoryHelper(Ice.InitializationData initData, Callback callback)
+ {
+ _callback = callback;
+ _initData = initData;
+ setDefaultProperties();
+ }
+
+ /// <sumary>
+ /// Creates a SessionFactory object.
+ /// </sumary>
+ /// <param name="properties">The properties to use when creating the communicator.</param>
+ /// <param name="callback">The callback object for notifications.</param>
+ public
+ SessionFactoryHelper(Ice.Properties properties, Callback callback)
+ {
+ _callback = callback;
+ _initData = new Ice.InitializationData();
+ _initData.properties = properties;
+ setDefaultProperties();
+ }
+
+ /// <sumary>
+ /// Set the router object identity.
+ /// </sumary>
+ public void
+ setRouterIdentity(Ice.Identity identity)
+ {
+ lock(this)
+ {
+ _identity = identity;
+ }
+ }
+
+ /// <sumary>
+ /// Returns the object identity of the Glacier2 router.
+ /// </sumary>
+ /// <returns> The Glacier2 router's identity.</returns>
+ public Ice.Identity
+ getRouterIdentity()
+ {
+ lock(this)
+ {
+ return _identity;
+ }
+ }
+
+ /// <sumary>
+ /// Sets the host on which the Glacier2 router runs.
+ /// </sumary>
+ /// <param name="hostname">The host name (or IP address) of the router host.</param>
+ public void
+ setRouterHost(string hostname)
+ {
+ lock(this)
+ {
+ _routerHost = hostname;
+ }
+ }
+
+ /// <sumary>
+ /// Returns the host on which the Glacier2 router runs.
+ /// </sumary>
+ /// <returns>The Glacier2 router host.</returns>
+ public string
+ getRouterHost()
+ {
+ lock(this)
+ {
+ return _routerHost;
+ }
+ }
+
+ /// <sumary>
+ /// Sets whether to connect with the Glacier2 router securely.
+ /// </sumary>
+ /// <param name="secure">If true, the client connects to the router
+ /// via SSL; otherwise, the client connects via TCP.</param>
+ public void
+ setSecure(bool secure)
+ {
+ lock(this)
+ {
+ _secure = secure;
+ }
+ }
+
+ /// <sumary>
+ /// Returns whether the session factory will establish a secure connection to the Glacier2 router.
+ /// </sumary>
+ /// <returns>The secure flag.</returns>
+ public bool
+ getSecure()
+ {
+ lock(this)
+ {
+ return _secure;
+ }
+ }
+
+ /// <sumary>
+ /// Sets the connect and connection timeout for the Glacier2 router.
+ /// </sumary>
+ /// <param name="timeoutMillisecs">The timeout in milliseconds. A zero
+ /// or negative timeout value indicates that the router proxy has no
+ /// associated timeout.</param>
+ public void
+ setTimeout(int timeoutMillisecs)
+ {
+ lock(this)
+ {
+ _timeout = timeoutMillisecs;
+ }
+ }
+
+ /// <sumary>
+ /// Returns the connect and connection timeout associated with the Glacier2 router.
+ /// </sumary>
+ /// <returns>The timeout.</returns>
+ public int
+ getTimeout()
+ {
+ lock(this)
+ {
+ return _timeout;
+ }
+ }
+
+ /// <sumary>
+ /// Sets the Glacier2 router port to connect to.
+ /// </sumary>
+ /// <param name="port">The port. If 0, then the default port (4063 for TCP or
+ /// 4064 for SSL) is used.</param>
+ public void
+ setPort(int port)
+ {
+ lock(this)
+ {
+ _port = port;
+ }
+ }
+
+ /// <sumary>
+ /// Returns the Glacier2 router port to connect to.
+ /// </sumary>
+ /// <returns>The port.</returns>
+ public int
+ getPort()
+ {
+ lock(this)
+ {
+ return _port == 0 ? (_secure ? GLACIER2_TCP_PORT : GLACIER2_SSL_PORT) : _port;
+ }
+ }
+
+ /**
+ * Returns the initialization data used to initialize the communicator.
+ *
+ * @return The initialization data.
+ */
+ public Ice.InitializationData
+ getInitializationData()
+ {
+ lock(this)
+ {
+ return _initData;
+ }
+ }
+
+ /// <sumary>
+ /// Connects to the Glacier2 router using the associated SSL credentials.
+ ///
+ /// Once the connection is established, Callback.connected is called on
+ /// the callback object; upon failure, Callback.connectFailed is called
+ /// with the exception.
+ /// </sumary>
+ /// <returns>The connected session.</returns>
+ public SessionHelper
+ connect()
+ {
+ lock(this)
+ {
+ SessionHelper session = new SessionHelper(_callback, createInitData());
+ session.connect();
+ return session;
+ }
+ }
+
+ /// <sumary>
+ /// Connect the Glacier2 session using user name and password credentials.
+ ///
+ /// Once the connection is established, Callback.connected is called on
+ /// the callback object; upon failure, Callback.connectFailed is called
+ /// with the exception.
+ /// </sumary>
+ /// <param name="username">The user name.</param>
+ /// <param name="password">The password.</param>
+ /// <returns>The connected session.</returns>
+ public SessionHelper
+ connect( string username, string password)
+ {
+ lock(this)
+ {
+ SessionHelper session = new SessionHelper(_callback, createInitData());
+ session.connect(username, password);
+ return session;
+ }
+ }
+
+ private Ice.InitializationData
+ createInitData()
+ {
+ // Clone the initialization data and properties.
+ Ice.InitializationData initData = (Ice.InitializationData)_initData.Clone();
+ initData.properties = initData.properties.ice_clone_();
+
+ if(initData.properties.getProperty("Ice.Default.Router").Length == 0)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("\"");
+ sb.Append(Ice.Util.identityToString(_identity));
+ sb.Append("\"");
+ sb.Append(":");
+ if(_secure)
+ {
+ sb.Append("ssl -p ");
+ }
+ else
+ {
+ sb.Append("tcp -p ");
+ }
+ if(_port != 0)
+ {
+ sb.Append(_port);
+ }
+ else
+ {
+ if(_secure)
+ {
+ sb.Append(GLACIER2_SSL_PORT);
+ }
+ else
+ {
+ sb.Append(GLACIER2_TCP_PORT);
+ }
+ }
+
+ sb.Append(" -h ");
+ sb.Append(_routerHost);
+ if(_timeout > 0)
+ {
+ sb.Append(" -t ");
+ sb.Append(_timeout);
+ }
+ initData.properties.setProperty("Ice.Default.Router", sb.ToString());
+ }
+ return initData;
+ }
+
+ private void
+ setDefaultProperties()
+ {
+ _initData.properties.setProperty("Ice.ACM.Client", "0");
+ _initData.properties.setProperty("Ice.RetryIntervals", "-1");
+ }
+
+ private Callback _callback;
+ private string _routerHost = "127.0.0.1";
+ private Ice.InitializationData _initData;
+ private Ice.Identity _identity = new Ice.Identity("router", "Glacier2");
+ private bool _secure = true;
+ private int _port = 0;
+ private int _timeout = 10000;
+ private static int GLACIER2_SSL_PORT = 4064;
+ private static int GLACIER2_TCP_PORT = 4063;
+}
+
+}
diff --git a/cs/src/Glacier2/SessionHelper.cs b/cs/src/Glacier2/SessionHelper.cs
new file mode 100644
index 00000000000..9cb8d4e3803
--- /dev/null
+++ b/cs/src/Glacier2/SessionHelper.cs
@@ -0,0 +1,485 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 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.
+//
+// **********************************************************************
+
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Windows.Threading;
+
+namespace Glacier2
+{
+
+/// <sumary>
+/// A helper class for using Glacier2 with GUI applications.
+/// </sumary>
+public class SessionHelper
+{
+ private class SessionRefreshThread
+ {
+ private class RefreshI : Glacier2.AMI_Router_refreshSession
+ {
+ public
+ RefreshI(SessionHelper helper, SessionRefreshThread thread)
+ {
+ _thread = thread;
+ _helper = helper;
+ }
+
+ public override void ice_response()
+ {
+ }
+
+ public override void ice_exception(Ice.Exception ex)
+ {
+ _thread.done();
+ _helper.destroy();
+ }
+
+ public void ice_exception(Ice.UserException ex)
+ {
+ _thread.done();
+ _helper.destroy();
+ }
+
+ SessionRefreshThread _thread;
+ SessionHelper _helper;
+ }
+
+ public SessionRefreshThread(SessionHelper session, Glacier2.RouterPrx router, int period)
+ {
+ _session = session;
+ _router = router;
+ _period = period;
+ _done = false;
+ }
+
+ public void
+ run()
+ {
+ lock(this)
+ {
+ while(true)
+ {
+ _router.refreshSession_async(new RefreshI(_session, this));
+ if(!_done)
+ {
+ try
+ {
+ System.Threading.Monitor.Wait(this, _period);
+ }
+ catch(ThreadInterruptedException)
+ {
+ }
+ }
+ if(_done)
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ public void
+ done()
+ {
+ lock(this)
+ {
+ if(!_done)
+ {
+ _done = true;
+ System.Threading.Monitor.Pulse(this);
+ }
+ }
+ }
+
+ private SessionHelper _session;
+ private Glacier2.RouterPrx _router;
+ private int _period;
+ private bool _done = false;
+ }
+
+ /// <sumary>
+ /// Creates a Glacier2 session.
+ /// </sumary>
+ /// <param name="callback">The callback for notifications about session
+ /// establishment.</param>
+ /// <param name="initData">The Ice.InitializationData for initializing
+ /// the communicator.</param>
+ public SessionHelper(SessionFactoryHelper.Callback callback, Ice.InitializationData initData)
+ {
+ _callback = callback;
+ _initData = initData;
+ }
+
+ /// <sumary>
+ /// Destroys the Glacier2 session.
+ ///
+ /// Once the session has been destroyed, Callback.disconnected is
+ /// called on the associated callback object.
+ /// </sumary>
+ public void
+ destroy()
+ {
+ lock(this)
+ {
+ if(_destroy)
+ {
+ return;
+ }
+ _destroy = true;
+
+ if(_sessionRefresh == null)
+ {
+ // In this case a connecting session is being
+ // destroyed. The communicator and session will be
+ // destroyed when the connection establishment has
+ // completed.
+ return;
+ }
+ _session = null;
+
+ // Run the destroyInternal in a thread. This is because it
+ // destroyInternal makes remote invocations.
+ Thread t = new Thread(new ThreadStart(destroyInternal));
+ t.Start();
+ }
+ }
+
+ /// <sumary>
+ /// Returns the session's communicator object.
+ /// </sumary>
+ /// <returns>The communicator.</returns>
+ public Ice.Communicator
+ communicator()
+ {
+ lock(this)
+ {
+ return _communicator;
+ }
+ }
+
+ /// <sumary>
+ /// Returns the category to be used in the identities of all of
+ /// the client's callback objects. Clients must use this category
+ /// for the router to forward callback requests to the intended
+ /// client.
+ /// </sumary>
+ /// <returns>The category. Throws SessionNotExistException
+ /// No session exists</returns>
+ public string
+ categoryForClient()
+ {
+ lock(this)
+ {
+ if(_router == null)
+ {
+ throw new SessionNotExistException();
+ }
+
+ return _router.getCategoryForClient();
+ }
+ }
+
+ /// <sumary>
+ /// Adds a servant to the callback object adapter's Active Servant
+ /// Map with a UUID.
+ /// </sumary>
+ /// <param name="servant">The servant to add.</param>
+ /// <returns>The proxy for the servant. Throws SessionNotExistException
+ /// if no session exists.</returns>
+ public Ice.ObjectPrx
+ addWithUUID(Ice.Object servant)
+ {
+ lock(this)
+ {
+ if(_router == null)
+ {
+ throw new SessionNotExistException();
+ }
+
+ return internalObjectAdapter().add(servant, new Ice.Identity(Guid.NewGuid().ToString(),
+ _router.getCategoryForClient()));
+ }
+ }
+
+ /// <sumary>
+ /// Returns the Glacier2 session proxy. If the session hasn't been
+ /// established yet, or the session has already been destroyed,
+ /// throws SessionNotExistException.
+ /// </sumary>
+ /// <returns>The session proxy, or throws SessionNotExistException
+ /// if no session exists.</returns>
+ public Glacier2.SessionPrx
+ session()
+ {
+ lock(this)
+ {
+ if(_session == null)
+ {
+ throw new SessionNotExistException();
+ }
+ return _session;
+ }
+ }
+
+ /// <sumary>
+ /// Returns true if there is an active session, otherwise returns false.
+ /// </sumary>
+ /// <returns>true if session exists or false if no session exists.</returns>
+ public bool
+ isConnected()
+ {
+ lock(this)
+ {
+ return _connected;
+ }
+ }
+
+ /// <sumary>
+ /// Creates an object adapter for callback objects.
+ /// </sumary>
+ /// <return>The object adapter. throws SessionNotExistException
+ /// if no session exists.</return>
+ public Ice.ObjectAdapter
+ objectAdapter()
+ {
+ return internalObjectAdapter();
+ }
+
+ // Only call this method when the calling thread owns the lock
+ private Ice.ObjectAdapter
+ internalObjectAdapter()
+ {
+ lock(this)
+ {
+ if(_router == null)
+ {
+ throw new SessionNotExistException();
+ }
+ if(_adapter == null)
+ {
+ // TODO: Depending on the resolution of
+ // http://bugzilla/bugzilla/show_bug.cgi?id=4264 the OA
+ // name could be an empty string.
+ _adapter = _communicator.createObjectAdapterWithRouter(Guid.NewGuid().ToString(), _router);
+ _adapter.activate();
+ }
+ return _adapter;
+ }
+ }
+
+ /// <sumary>
+ /// Connects to the Glacier2 router using the associated SSL credentials.
+ ///
+ /// Once the connection is established, Callback.connected} is called on
+ /// the callback object; upon failure, Callback.exception is called with
+ /// the exception.
+ /// </sumary>
+ public void
+ connect()
+ {
+ lock(this)
+ {
+ connectImpl(delegate(RouterPrx router)
+ {
+ return router.createSessionFromSecureConnection();
+ });
+ }
+ }
+
+ /// <sumary>
+ /// Connects a Glacier2 session using user name and password credentials.
+ ///
+ /// Once the connection is established, {@link Callback#connected} is called on the callback object;
+ /// upon failure {@link Callback.exception} is called with the exception.
+ /// </sumary>
+ /// <param name="username">The user name.</param>
+ /// <param name="password">The password.</param>
+ public void
+ connect(string username, string password)
+ {
+ lock(this)
+ {
+ connectImpl(delegate(RouterPrx router)
+ {
+ return router.createSession(username, password);
+ });
+ }
+ }
+
+ private void
+ connected(RouterPrx router, SessionPrx session)
+ {
+ lock(this)
+ {
+ _router = router;
+
+ if(_destroy)
+ {
+ destroyInternal();
+ return;
+ }
+
+ // Assign the session after _destroy is checked.
+ _session = session;
+ _connected = true;
+
+ Debug.Assert(_sessionRefresh == null);
+ _sessionRefresh = new SessionRefreshThread(this, _router, (int)(_router.getSessionTimeout() * 1000)/2);
+ _refreshThread = new Thread(new ThreadStart(_sessionRefresh.run));
+ _refreshThread.Start();
+
+
+ _callback.getDispatcher().Invoke(DispatcherPriority.Normal,
+ (Action)delegate()
+ {
+ try
+ {
+ _callback.connected(this);
+ }
+ catch(Glacier2.SessionNotExistException)
+ {
+ destroy();
+ }
+ });
+ }
+ }
+
+ private void
+ destroyInternal()
+ {
+ lock(this)
+ {
+ Debug.Assert(_destroy);
+
+ try
+ {
+ _router.destroySession();
+ }
+ catch(Ice.ConnectionLostException)
+ {
+ // Expected
+ }
+ catch(SessionNotExistException)
+ {
+ // This can also occur.
+ }
+ catch(Exception e)
+ {
+ // Not expected.
+ _communicator.getLogger().warning("SessionHelper: unexpected exception when destroying the session:\n"
+ + e);
+ }
+ _router = null;
+ _connected = false;
+ if(_sessionRefresh != null)
+ {
+ _sessionRefresh.done();
+ while(true)
+ {
+ try
+ {
+ _refreshThread.Join();
+ break;
+ }
+ catch(ThreadInterruptedException)
+ {
+ }
+ }
+ _sessionRefresh = null;
+ _refreshThread = null;
+ }
+
+ try
+ {
+ _communicator.destroy();
+ }
+ catch(Exception)
+ {
+ }
+ _communicator = null;
+
+ // Notify the callback that the session is gone.
+ _callback.getDispatcher().BeginInvoke(DispatcherPriority.Normal,
+ (Action)delegate()
+ {
+ _callback.disconnected(this);
+ });
+ }
+ }
+
+ delegate Glacier2.SessionPrx
+ ConnectStrategy(Glacier2.RouterPrx router);
+
+ private void
+ connectImpl(ConnectStrategy factory)
+ {
+ Debug.Assert(!_destroy);
+
+ try
+ {
+ _communicator = Ice.Util.initialize(_initData);
+ }
+ catch(Ice.LocalException ex)
+ {
+ _destroy = true;
+ _callback.getDispatcher().BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
+ {
+ _callback.connectFailed(this, ex);
+ });
+ return;
+ }
+
+ new Thread(new ThreadStart(delegate()
+ {
+ try
+ {
+ _callback.getDispatcher().BeginInvoke(DispatcherPriority.Normal,
+ (Action)delegate()
+ {
+ _callback.createdCommunicator(this);
+ });
+
+ Glacier2.RouterPrx routerPrx = Glacier2.RouterPrxHelper.uncheckedCast(
+ _communicator.getDefaultRouter());
+ Glacier2.SessionPrx session = factory(routerPrx);
+ connected(routerPrx, session);
+ }
+ catch (Exception ex)
+ {
+ try
+ {
+ _communicator.destroy();
+ }
+ catch(Exception)
+ {
+ }
+
+ _callback.getDispatcher().BeginInvoke(DispatcherPriority.Normal, (Action)delegate()
+ {
+ _callback.connectFailed(this, ex);
+ });
+ }
+ })).Start();
+ }
+
+ private Ice.InitializationData _initData;
+ private Ice.Communicator _communicator;
+ private Ice.ObjectAdapter _adapter;
+ private Glacier2.RouterPrx _router;
+ private Glacier2.SessionPrx _session;
+ private bool _connected = false;
+
+ private SessionRefreshThread _sessionRefresh;
+ private Thread _refreshThread;
+ private SessionFactoryHelper.Callback _callback;
+ private bool _destroy = false;
+}
+
+}
diff --git a/cs/src/Ice/Application.cs b/cs/src/Ice/Application.cs
index 9aacbf0888b..5192916adca 100644
--- a/cs/src/Ice/Application.cs
+++ b/cs/src/Ice/Application.cs
@@ -82,7 +82,7 @@ namespace Ice
/// <param name="signalPolicy">Determines how to respond to signals.</param>
public Application(SignalPolicy signalPolicy)
{
- _signalPolicy = signalPolicy;
+ signalPolicy__ = signalPolicy;
}
/// <summary>
@@ -122,7 +122,7 @@ namespace Ice
{
if(Util.getProcessLogger() is ConsoleLoggerI)
{
- Util.setProcessLogger(new ConsoleLoggerI(_appName));
+ Util.setProcessLogger(new ConsoleLoggerI(appName__));
}
InitializationData initData = new InitializationData();
@@ -165,10 +165,10 @@ namespace Ice
{
if(Util.getProcessLogger() is ConsoleLoggerI)
{
- Util.setProcessLogger(new ConsoleLoggerI(_appName));
+ Util.setProcessLogger(new ConsoleLoggerI(appName__));
}
- if(_communicator != null)
+ if(communicator__ != null)
{
Util.getProcessLogger().error("only one instance of the Application class can be used");
return 1;
@@ -176,7 +176,7 @@ namespace Ice
int status;
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows)
{
@@ -188,13 +188,13 @@ namespace Ice
}
_signals.register(_handler);
- status = mainInternal(args, initData);
+ status = doMain(args, initData);
_signals = null;
}
else
{
- status = mainInternal(args, initData);
+ status = doMain(args, initData);
}
return status;
@@ -209,7 +209,7 @@ namespace Ice
/// <returns>The name of the application.</returns>
public static string appName()
{
- return _appName;
+ return appName__;
}
/// <summary>
@@ -220,7 +220,7 @@ namespace Ice
/// <returns>The communicator for the application.</returns>
public static Communicator communicator()
{
- return _communicator;
+ return communicator__;
}
/// <summary>
@@ -229,14 +229,14 @@ namespace Ice
/// </summary>
public static void destroyOnInterrupt()
{
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- lock(_mutex)
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
- _released = true;
- Monitor.Pulse(_mutex);
+ released__ = true;
+ Monitor.Pulse(mutex__);
}
_callback = _destroyCallback;
}
@@ -253,14 +253,14 @@ namespace Ice
/// </summary>
public static void shutdownOnInterrupt()
{
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- lock(_mutex)
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
- _released = true;
- Monitor.Pulse(_mutex);
+ released__ = true;
+ Monitor.Pulse(mutex__);
}
_callback = _shutdownCallback;
}
@@ -277,14 +277,14 @@ namespace Ice
/// </summary>
public static void ignoreInterrupt()
{
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- lock(_mutex)
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
- _released = true;
- Monitor.Pulse(_mutex);
+ released__ = true;
+ Monitor.Pulse(mutex__);
}
_callback = null;
}
@@ -302,14 +302,14 @@ namespace Ice
/// </summary>
public static void callbackOnInterrupt()
{
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- lock(_mutex)
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
- _released = true;
- Monitor.Pulse(_mutex);
+ released__ = true;
+ Monitor.Pulse(mutex__);
}
_callback = _userCallback;
}
@@ -326,14 +326,14 @@ namespace Ice
/// </summary>
public static void holdInterrupt()
{
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- lock(_mutex)
+ lock(mutex__)
{
if(_callback != _holdCallback)
{
_previousCallback = _callback;
- _released = false;
+ released__ = false;
_callback = _holdCallback;
}
// else, we were already holding signals
@@ -352,22 +352,22 @@ namespace Ice
/// </summary>
public static void releaseInterrupt()
{
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- lock(_mutex)
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
//
// Note that it's very possible no signal is held;
// in this case the callback is just replaced and
- // setting _released to true and signalling _mutex
+ // setting released__ to true and signalling mutex__
// do no harm.
//
- _released = true;
+ released__ = true;
_callback = _previousCallback;
- Monitor.Pulse(_mutex);
+ Monitor.Pulse(mutex__);
}
// Else nothing to release.
}
@@ -386,13 +386,13 @@ namespace Ice
/// <returns>True if a signal caused the communicator to shut down; false otherwise.</returns>
public static bool interrupted()
{
- lock(_mutex)
+ lock(mutex__)
{
- return _interrupted;
+ return interrupted__;
}
}
- private int mainInternal(string[] args, InitializationData initializationData)
+ protected virtual int doMain(string[] args, InitializationData initializationData)
{
int status = 0;
@@ -423,17 +423,17 @@ namespace Ice
}
_application = this;
- _communicator = Util.initialize(ref args, initData);
- _destroyed = false;
+ communicator__ = Util.initialize(ref args, initData);
+ destroyed__ = false;
- Properties props = _communicator.getProperties();
- _nohup = props.getPropertyAsInt("Ice.Nohup") > 0;
- _appName = props.getPropertyWithDefault("Ice.ProgramName", _appName);
+ Properties props = communicator__.getProperties();
+ nohup__ = props.getPropertyAsInt("Ice.Nohup") > 0;
+ appName__ = props.getPropertyWithDefault("Ice.ProgramName", appName__);
//
// The default is to destroy when a signal is received.
//
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
destroyOnInterrupt();
}
@@ -456,38 +456,38 @@ namespace Ice
// (post-run), it would not make sense to release a held
// signal to run shutdown or destroy.
//
- if(_signalPolicy == SignalPolicy.HandleSignals)
+ if(signalPolicy__ == SignalPolicy.HandleSignals)
{
ignoreInterrupt();
}
- lock(_mutex)
+ lock(mutex__)
{
- while(_callbackInProgress)
+ while(callbackInProgress__)
{
- Monitor.Wait(_mutex);
+ Monitor.Wait(mutex__);
}
- if(_destroyed)
+ if(destroyed__)
{
- _communicator = null;
+ communicator__ = null;
}
else
{
- _destroyed = true;
+ destroyed__ = true;
//
- // _communicator != null means that it will be destroyed
- // next; _destroyed == true ensures that any
+ // communicator__ != null means that it will be destroyed
+ // next; destroyed__ == true ensures that any
// remaining callback won't do anything
//
}
_application = null;
}
- if(_communicator != null)
+ if(communicator__ != null)
{
try
{
- _communicator.destroy();
+ communicator__.destroy();
}
catch(Ice.Exception ex)
{
@@ -499,7 +499,7 @@ namespace Ice
Util.getProcessLogger().error("unknown exception:\n" + ex);
status = 1;
}
- _communicator = null;
+ communicator__ = null;
}
return status;
@@ -511,7 +511,7 @@ namespace Ice
private static void signalHandler(int sig)
{
Callback callback;
- lock(_mutex)
+ lock(mutex__)
{
callback = _callback;
}
@@ -534,14 +534,14 @@ namespace Ice
private static void holdInterruptCallback(int sig)
{
Callback callback = null;
- lock(_mutex)
+ lock(mutex__)
{
- while(!_released)
+ while(!released__)
{
- Monitor.Wait(_mutex);
+ Monitor.Wait(mutex__);
}
- if(_destroyed)
+ if(destroyed__)
{
//
// Being destroyed by main thread
@@ -563,86 +563,86 @@ namespace Ice
//
private static void destroyOnInterruptCallback(int sig)
{
- lock(_mutex)
+ lock(mutex__)
{
- if(_destroyed)
+ if(destroyed__)
{
//
// Being destroyed by main thread
//
return;
}
- if(_nohup && sig == SIGHUP)
+ if(nohup__ && sig == SIGHUP)
{
return;
}
- Debug.Assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
- _destroyed = true;
+ Debug.Assert(!callbackInProgress__);
+ callbackInProgress__ = true;
+ interrupted__ = true;
+ destroyed__ = true;
}
try
{
- Debug.Assert(_communicator != null);
- _communicator.destroy();
+ Debug.Assert(communicator__ != null);
+ communicator__.destroy();
}
catch(System.Exception ex)
{
Util.getProcessLogger().error("(while destroying in response to signal " + sig + "):\n" + ex);
}
- lock(_mutex)
+ lock(mutex__)
{
- _callbackInProgress = false;
- Monitor.Pulse(_mutex);
+ callbackInProgress__ = false;
+ Monitor.Pulse(mutex__);
}
}
private static void shutdownOnInterruptCallback(int sig)
{
- lock(_mutex)
+ lock(mutex__)
{
- if(_destroyed)
+ if(destroyed__)
{
//
// Being destroyed by main thread
//
return;
}
- if(_nohup && sig == SIGHUP)
+ if(nohup__ && sig == SIGHUP)
{
return;
}
- Debug.Assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
+ Debug.Assert(!callbackInProgress__);
+ callbackInProgress__ = true;
+ interrupted__ = true;
}
try
{
- Debug.Assert(_communicator != null);
- _communicator.shutdown();
+ Debug.Assert(communicator__ != null);
+ communicator__.shutdown();
}
catch(System.Exception ex)
{
Util.getProcessLogger().error("(while shutting down in response to signal " + sig + "):\n" + ex);
}
- lock(_mutex)
+ lock(mutex__)
{
- _callbackInProgress = false;
- Monitor.Pulse(_mutex);
+ callbackInProgress__ = false;
+ Monitor.Pulse(mutex__);
}
}
private static void userCallbackOnInterruptCallback(int sig)
{
- lock(_mutex)
+ lock(mutex__)
{
- if(_destroyed)
+ if(destroyed__)
{
//
// Being destroyed by main thread
@@ -651,9 +651,9 @@ namespace Ice
}
// For SIGHUP the user callback is always called. It can
// decide what to do.
- Debug.Assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
+ Debug.Assert(!callbackInProgress__);
+ callbackInProgress__ = true;
+ interrupted__ = true;
}
try
@@ -666,21 +666,21 @@ namespace Ice
Util.getProcessLogger().error("(while interrupting in response to signal " + sig + "):\n" + ex);
}
- lock(_mutex)
+ lock(mutex__)
{
- _callbackInProgress = false;
- Monitor.Pulse(_mutex);
+ callbackInProgress__ = false;
+ Monitor.Pulse(mutex__);
}
}
- private static readonly object _mutex = new object();
+ protected static readonly object mutex__ = new object();
- private static bool _callbackInProgress = false;
- private static bool _destroyed = false;
- private static bool _interrupted = false;
- private static bool _released = false;
- private static bool _nohup = false;
- private static SignalPolicy _signalPolicy = SignalPolicy.HandleSignals;
+ protected static bool callbackInProgress__ = false;
+ protected static bool destroyed__ = false;
+ protected static bool interrupted__ = false;
+ protected static bool released__ = false;
+ protected static bool nohup__ = false;
+ protected static SignalPolicy signalPolicy__ = SignalPolicy.HandleSignals;
private delegate void Callback(int sig);
private static readonly Callback _destroyCallback = new Callback(destroyOnInterruptCallback);
@@ -695,8 +695,8 @@ namespace Ice
// We use FriendlyName instead of Process.GetCurrentProcess().ProcessName because the latter
// is terribly slow. (It takes around 1 second!)
//
- private static string _appName = AppDomain.CurrentDomain.FriendlyName;
- private static Communicator _communicator;
+ protected static string appName__ = AppDomain.CurrentDomain.FriendlyName;
+ protected static Communicator communicator__;
private static Application _application;
private static int SIGHUP;