diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/all.dsw | 42 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/.depend | 0 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/Callback.ice | 30 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/CallbackI.cpp | 82 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/CallbackI.h | 39 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/Client.cpp | 73 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/Makefile | 42 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/Server.cpp | 52 | ||||
-rwxr-xr-x | cpp/demo/Ice/bidir/bidirC.dsp | 153 | ||||
-rwxr-xr-x | cpp/demo/Ice/bidir/bidirS.dsp | 161 | ||||
-rw-r--r-- | cpp/demo/Ice/bidir/config | 7 | ||||
-rw-r--r-- | cpp/demo/Ice/callback/CallbackI.cpp | 6 | ||||
-rw-r--r-- | cpp/demo/Ice/callback/CallbackI.h | 8 | ||||
-rw-r--r-- | cpp/demo/Ice/callback/Client.cpp | 14 | ||||
-rw-r--r-- | cpp/demo/Ice/callback/callbackC.dsp | 8 | ||||
-rw-r--r-- | cpp/demo/Ice/callback/config | 2 | ||||
-rw-r--r-- | cpp/slice/Ice/Connection.ice | 62 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.h | 4 |
19 files changed, 751 insertions, 41 deletions
diff --git a/cpp/all.dsw b/cpp/all.dsw index d3f4bfd8b3e..5916cab80d2 100644 --- a/cpp/all.dsw +++ b/cpp/all.dsw @@ -518,6 +518,12 @@ Package=<4> Begin Project Dependency
Project_Dep_Name icepatch2S
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name bidirC
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name bidirS
+ End Project Dependency
}}}
###############################################################################
@@ -543,6 +549,42 @@ Package=<4> ###############################################################################
+Project: "bidirC"=.\demo\Ice\bidir\bidirC.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name ice
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name iceutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "bidirS"=.\demo\Ice\bidir\bidirS.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name ice
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name iceutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "callbackC"=.\demo\ice\callback\callbackC.dsp - Package Owner=<4>
Package=<5>
diff --git a/cpp/demo/Ice/bidir/.depend b/cpp/demo/Ice/bidir/.depend new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/cpp/demo/Ice/bidir/.depend diff --git a/cpp/demo/Ice/bidir/Callback.ice b/cpp/demo/Ice/bidir/Callback.ice new file mode 100644 index 00000000000..92a252be2ca --- /dev/null +++ b/cpp/demo/Ice/bidir/Callback.ice @@ -0,0 +1,30 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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 CALLBACK_ICE +#define CALLBACK_ICE + +#include <Ice/Identity.ice> + +module Demo +{ + +interface CallbackReceiver +{ + void callback(int num); +}; + +interface CallbackSender +{ + void addClient(Ice::Identity ident); +}; + +}; + +#endif diff --git a/cpp/demo/Ice/bidir/CallbackI.cpp b/cpp/demo/Ice/bidir/CallbackI.cpp new file mode 100644 index 00000000000..b2c8da3f78f --- /dev/null +++ b/cpp/demo/Ice/bidir/CallbackI.cpp @@ -0,0 +1,82 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <CallbackI.h> + +using namespace std; +using namespace Ice; +using namespace Demo; + +CallbackSenderI::CallbackSenderI() : + _destroy(false), + _num(0) +{ +} + +void +CallbackSenderI::destroy() +{ + { + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + cout << "destroying callback sender" << endl; + _destroy = true; + + notify(); + } + + getThreadControl().join(); +} + +void +CallbackSenderI::addClient(const Identity& ident, const Current& current) +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + cout << "adding client `" << identityToString(ident) << "'"<< endl; + + CallbackReceiverPrx client = CallbackReceiverPrx::uncheckedCast(current.con->createProxy(ident)); + _clients.insert(client); +} + +void +CallbackSenderI::run() +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + while(true) + { + timedWait(IceUtil::Time::seconds(2)); + + if(_destroy) + { + return; + } + + ++_num; + + set<CallbackReceiverPrx>::iterator p = _clients.begin(); + while(p != _clients.end()) + { + try + { + (*p)->callback(_num); + ++p; + } + catch(const Exception& ex) + { + cerr << "removing client `" << identityToString((*p)->ice_getIdentity()) << "':\n" + << ex << endl; + _clients.erase(p++); + } + } + } +} + diff --git a/cpp/demo/Ice/bidir/CallbackI.h b/cpp/demo/Ice/bidir/CallbackI.h new file mode 100644 index 00000000000..b1c2edf0ff6 --- /dev/null +++ b/cpp/demo/Ice/bidir/CallbackI.h @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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 CALLBACK_I_H +#define CALLBACK_I_H + +#include <IceUtil/Thread.h> +#include <IceUtil/Monitor.h> +#include <Callback.h> +#include <set> + +class CallbackSenderI : public Demo::CallbackSender, public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + CallbackSenderI(); + + void destroy(); + + virtual void addClient(const Ice::Identity&, const Ice::Current&); + + virtual void run(); + +private: + + bool _destroy; + Ice::Int _num; + std::set<Demo::CallbackReceiverPrx> _clients; +}; + +typedef IceUtil::Handle<CallbackSenderI> CallbackSenderIPtr; + +#endif diff --git a/cpp/demo/Ice/bidir/Client.cpp b/cpp/demo/Ice/bidir/Client.cpp new file mode 100644 index 00000000000..6790702e6e6 --- /dev/null +++ b/cpp/demo/Ice/bidir/Client.cpp @@ -0,0 +1,73 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +#include <IceUtil/UUID.h> +#include <Ice/Application.h> +#include <Callback.h> + +using namespace std; +using namespace Ice; +using namespace Demo; + +class CallbackReceiverI : public CallbackReceiver +{ +public: + + virtual void + callback(Int num, const Current&) + { + cout << "received callback #" << num << endl; + } +}; + +class CallbackClient : public Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + CallbackClient app; + return app.main(argc, argv, "config"); +} + +int +CallbackClient::run(int argc, char* argv[]) +{ + PropertiesPtr properties = communicator()->getProperties(); + const char* proxyProperty = "Callback.Client.CallbackServer"; + std::string proxy = properties->getProperty(proxyProperty); + if(proxy.empty()) + { + cerr << appName() << ": property `" << proxyProperty << "' not set" << endl; + return EXIT_FAILURE; + } + + CallbackSenderPrx server = CallbackSenderPrx::checkedCast(communicator()->stringToProxy(proxy)); + if(!server) + { + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; + } + + ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client"); + Identity ident; + ident.name = IceUtil::generateUUID(); + ident.category = ""; + adapter->add(new CallbackReceiverI, ident); + adapter->activate(); + server->ice_connection()->setAdapter(adapter); + server->addClient(ident); + communicator()->waitForShutdown(); + + return EXIT_SUCCESS; +} diff --git a/cpp/demo/Ice/bidir/Makefile b/cpp/demo/Ice/bidir/Makefile new file mode 100644 index 00000000000..741861fe894 --- /dev/null +++ b/cpp/demo/Ice/bidir/Makefile @@ -0,0 +1,42 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2004 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. +# +# ********************************************************************** + +top_srcdir = ../../.. + +CLIENT = client +SERVER = server + +TARGETS = $(CLIENT) $(SERVER) + +OBJS = Callback.o \ + CallbackI.o + +COBJS = Client.o + +SOBJS = Server.o + +SRCS = $(OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) + +SLICE_SRCS = Callback.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. $(CPPFLAGS) + +$(CLIENT): $(OBJS) $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) + +$(SERVER): $(OBJS) $(SOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SOBJS) $(LIBS) + +include .depend diff --git a/cpp/demo/Ice/bidir/Server.cpp b/cpp/demo/Ice/bidir/Server.cpp new file mode 100644 index 00000000000..56cfe1529ec --- /dev/null +++ b/cpp/demo/Ice/bidir/Server.cpp @@ -0,0 +1,52 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +#include <Ice/Application.h> +#include <CallbackI.h> + +using namespace std; +using namespace Ice; +using namespace Demo; + +class CallbackServer : public Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + CallbackServer app; + return app.main(argc, argv, "config"); +} + +int +CallbackServer::run(int argc, char* argv[]) +{ + ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server"); + CallbackSenderIPtr sender = new CallbackSenderI; + adapter->add(sender, Ice::stringToIdentity("sender")); + adapter->activate(); + + sender->start(); + try + { + communicator()->waitForShutdown(); + } + catch(...) + { + sender->destroy(); + throw; + } + sender->destroy(); + + return EXIT_SUCCESS; +} diff --git a/cpp/demo/Ice/bidir/bidirC.dsp b/cpp/demo/Ice/bidir/bidirC.dsp new file mode 100755 index 00000000000..ff0c0092c88 --- /dev/null +++ b/cpp/demo/Ice/bidir/bidirC.dsp @@ -0,0 +1,153 @@ +# Microsoft Developer Studio Project File - Name="bidirC" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=bidirC - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bidirC.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bidirC.mak" CFG="bidirC - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bidirC - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "bidirC - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bidirC - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /D "NDEBUG" /D "_CONSOLE" /FD /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Ice.lib IceUtil.lib /nologo /subsystem:console /machine:I386 /out:"client.exe" /libpath:"../../../lib"
+# SUBTRACT LINK32 /debug /nodefaultlib
+
+!ELSEIF "$(CFG)" == "bidirC - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Iced.lib IceUtild.lib /nologo /subsystem:console /debug /machine:I386 /out:"client.exe" /pdbtype:sept /libpath:"../../../lib"
+# SUBTRACT LINK32 /nodefaultlib
+
+!ENDIF
+
+# Begin Target
+
+# Name "bidirC - Win32 Release"
+# Name "bidirC - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Callback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Client.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Callback.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\Callback.ice
+
+!IF "$(CFG)" == "bidirC - Win32 Release"
+
+USERDEP__CALLB="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\slice.lib"
+# Begin Custom Build
+InputPath=.\Callback.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe -I../../../slice Callback.ice
+
+"Callback.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Callback.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bidirC - Win32 Debug"
+
+USERDEP__CALLB="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\sliced.lib"
+# Begin Custom Build
+InputPath=.\Callback.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe -I../../../slice Callback.ice
+
+"Callback.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Callback.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/cpp/demo/Ice/bidir/bidirS.dsp b/cpp/demo/Ice/bidir/bidirS.dsp new file mode 100755 index 00000000000..4502c35526f --- /dev/null +++ b/cpp/demo/Ice/bidir/bidirS.dsp @@ -0,0 +1,161 @@ +# Microsoft Developer Studio Project File - Name="bidirS" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=bidirS - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bidirS.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bidirS.mak" CFG="bidirS - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bidirS - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "bidirS - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bidirS - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /D "NDEBUG" /D "_CONSOLE" /FD /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Ice.lib IceUtil.lib /nologo /subsystem:console /machine:I386 /out:"server.exe" /libpath:"../../../lib"
+# SUBTRACT LINK32 /debug /nodefaultlib
+
+!ELSEIF "$(CFG)" == "bidirS - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Iced.lib IceUtild.lib /nologo /subsystem:console /debug /machine:I386 /out:"server.exe" /pdbtype:sept /libpath:"../../../lib"
+# SUBTRACT LINK32 /nodefaultlib
+
+!ENDIF
+
+# Begin Target
+
+# Name "bidirS - Win32 Release"
+# Name "bidirS - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Callback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CallbackI.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Callback.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\CallbackI.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\Callback.ice
+
+!IF "$(CFG)" == "bidirS - Win32 Release"
+
+USERDEP__CALLB="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\slice.lib"
+# Begin Custom Build
+InputPath=.\Callback.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe -I../../../slice Callback.ice
+
+"Callback.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Callback.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bidirS - Win32 Debug"
+
+USERDEP__CALLB="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\sliced.lib"
+# Begin Custom Build
+InputPath=.\Callback.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe -I../../../slice Callback.ice
+
+"Callback.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Callback.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/cpp/demo/Ice/bidir/config b/cpp/demo/Ice/bidir/config new file mode 100644 index 00000000000..d194f5d3765 --- /dev/null +++ b/cpp/demo/Ice/bidir/config @@ -0,0 +1,7 @@ +Callback.Client.CallbackServer=sender:tcp -p 10000 +Callback.Client.Endpoints= +Callback.Server.Endpoints=tcp -p 10000 + +#Ice.Trace.Network=1 +#Ice.Trace.Protocol=1 +Ice.Warn.Connections=1 diff --git a/cpp/demo/Ice/callback/CallbackI.cpp b/cpp/demo/Ice/callback/CallbackI.cpp index 15d2967cd9a..c24eff4d2b1 100644 --- a/cpp/demo/Ice/callback/CallbackI.cpp +++ b/cpp/demo/Ice/callback/CallbackI.cpp @@ -15,12 +15,6 @@ using namespace Ice; using namespace Demo; void -CallbackReceiverI::callback(const Current&) -{ - cout << "received callback" << endl; -} - -void CallbackI::initiateCallback(const CallbackReceiverPrx& proxy, const Current& current) { cout << "initiating callback" << endl; diff --git a/cpp/demo/Ice/callback/CallbackI.h b/cpp/demo/Ice/callback/CallbackI.h index 7a8d71187eb..99efcc672f3 100644 --- a/cpp/demo/Ice/callback/CallbackI.h +++ b/cpp/demo/Ice/callback/CallbackI.h @@ -12,20 +12,12 @@ #include <Callback.h> -class CallbackReceiverI : public Demo::CallbackReceiver -{ -public: - - virtual void callback(const Ice::Current&); -}; - class CallbackI : public Demo::Callback { public: virtual void initiateCallback(const Demo::CallbackReceiverPrx&, const Ice::Current&); virtual void shutdown(const Ice::Current&); - }; #endif diff --git a/cpp/demo/Ice/callback/Client.cpp b/cpp/demo/Ice/callback/Client.cpp index ab0bedd7ab9..337748ec1d4 100644 --- a/cpp/demo/Ice/callback/Client.cpp +++ b/cpp/demo/Ice/callback/Client.cpp @@ -8,12 +8,22 @@ // ********************************************************************** #include <Ice/Application.h> -#include <CallbackI.h> +#include <Callback.h> using namespace std; using namespace Ice; using namespace Demo; +class CallbackReceiverI : public CallbackReceiver +{ +public: + + virtual void callback(const Current&) + { + cout << "received callback" << endl; + } +}; + class CallbackClient : public Application { public: @@ -49,7 +59,7 @@ int CallbackClient::run(int argc, char* argv[]) { PropertiesPtr properties = communicator()->getProperties(); - const char* proxyProperty = "Callback.Client.Callback"; + const char* proxyProperty = "Callback.Client.CallbackServer"; std::string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) { diff --git a/cpp/demo/Ice/callback/callbackC.dsp b/cpp/demo/Ice/callback/callbackC.dsp index ba0765f4c46..9619cd6a6ef 100644 --- a/cpp/demo/Ice/callback/callbackC.dsp +++ b/cpp/demo/Ice/callback/callbackC.dsp @@ -95,10 +95,6 @@ SOURCE=.\Callback.cpp # End Source File
# Begin Source File
-SOURCE=.\CallbackI.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\Client.cpp
# End Source File
# End Group
@@ -109,10 +105,6 @@ SOURCE=.\Client.cpp SOURCE=.\Callback.h
# End Source File
-# Begin Source File
-
-SOURCE=.\CallbackI.h
-# End Source File
# End Group
# Begin Group "Resource Files"
diff --git a/cpp/demo/Ice/callback/config b/cpp/demo/Ice/callback/config index 7424b8276eb..9b1f3e0e779 100644 --- a/cpp/demo/Ice/callback/config +++ b/cpp/demo/Ice/callback/config @@ -1,4 +1,4 @@ -Callback.Client.Callback=callback:tcp -p 10000:udp -p 10000:ssl -p 10001 +Callback.Client.CallbackServer=callback:tcp -p 10000:udp -p 10000:ssl -p 10001 Callback.Client.Endpoints=tcp:udp:ssl Callback.Server.Endpoints=tcp -p 10000:udp -p 10000:ssl -p 10001 diff --git a/cpp/slice/Ice/Connection.ice b/cpp/slice/Ice/Connection.ice index f51ba5a95d4..7a3be482908 100644 --- a/cpp/slice/Ice/Connection.ice +++ b/cpp/slice/Ice/Connection.ice @@ -10,6 +10,7 @@ #ifndef ICE_CONNECTION_ICE #define ICE_CONNECTION_ICE +#include <Ice/ObjectAdapterF.ice> #include <Ice/Identity.ice> module Ice @@ -38,32 +39,65 @@ local interface Connection /** * - * Flush any pending batch requests for this connection. This - * causes all batch requests that were sent via proxies that use - * this connection to be sent to the server. + * Create a special proxy that always uses this connection. This + * can be used for callbacks from a server to a client if the + * server cannot directly establish a connection to the client, + * for example because of firewalls. In this case, the server + * would create a proxy using an already established connection + * from the client. + * + * @param id The identity for which a proxy is to be created. + * + * @return A proxy that matches the given identity and uses this + * connection. + * + * @see setAdapter * **/ - void flushBatchRequests(); + nonmutating Object* createProxy(Identity id); /** * - * Create a proxy that always uses this connection. This is - * typically used for reverse communications using connections - * that have been established from a client to an object adapter. + * Explicitly set an object adapter that dispatches requests that + * are received over this connection. A client can invoke an + * operation on a server using a proxy, and then set an object + * adapter for the outgoing connection that is used by the proxy + * in order to receive callbacks. This is useful if the server + * cannot establish a connection back to the client, for example + * because of firewalls. * - * <note><para> This operation is intended to be used by special - * services, such as [Router] implementations. Regular user code - * should not attempt to use this operation. </para></note> + * @param adapter The object adapter that should be used by this + * connection to dispatch requests. The object adapter must be + * activated. When the object adapter is deactivated, it is + * automatically removed from the connection. * - * @param id The identity for which a proxy is to be created. + * @see createProxy + * @see setAdapter * - * @return A proxy that matches the given identity and uses this + **/ + void setAdapter(ObjectAdapter adapter); + + /** + * + * Get the object adapter that dispatches requests for this * connection. * - * @see Identity + * @return The object adapter that dispatches requests for the + * connection, or null if no adapter is set. + * + * @see setAdapter * **/ - nonmutating Object* createProxy(Identity id); + nonmutating ObjectAdapter getAdapter(); + + /** + * + * Flush any pending batch requests for this connection. This + * causes all batch requests that were sent via proxies that use + * this connection to be sent to the server. + * + **/ + void flushBatchRequests(); /** * diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index d81fe1a81a0..dcbd280e61f 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -1113,6 +1113,13 @@ Ice::ConnectionI::setAdapter(const ObjectAdapterPtr& adapter) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + if(_exception.get()) + { + _exception->ice_throw(); + } + + assert(_state < StateClosing); + // // Before we set an adapter (or reset it) we wait until the // dispatch count with any old adapter is zero. diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index f2338f033ac..a61a3e3c522 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -76,8 +76,8 @@ public: IceInternal::EndpointPtr endpoint() const; - void setAdapter(const ObjectAdapterPtr&); - ObjectAdapterPtr getAdapter() const; + virtual void setAdapter(const ObjectAdapterPtr&); // From Connection. + virtual ObjectAdapterPtr getAdapter() const; // From Connection. virtual ObjectPrx createProxy(const Identity& ident) const; // From Connection. // |