summaryrefslogtreecommitdiff
path: root/php/src/IcePHP/Connection.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2014-07-21 17:14:45 -0700
committerMark Spruiell <mes@zeroc.com>2014-07-21 17:14:45 -0700
commitf6871bc421840e0cabff34f2f477a9e53d14f812 (patch)
treec53a747b0c2a330802ceca7d80da7f5af3b05d4a /php/src/IcePHP/Connection.cpp
parentFixed windows compiler error (diff)
downloadice-f6871bc421840e0cabff34f2f477a9e53d14f812.tar.bz2
ice-f6871bc421840e0cabff34f2f477a9e53d14f812.tar.xz
ice-f6871bc421840e0cabff34f2f477a9e53d14f812.zip
ICE-5580 - port connection ACM functionality to scripting languages
Diffstat (limited to 'php/src/IcePHP/Connection.cpp')
-rw-r--r--php/src/IcePHP/Connection.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/php/src/IcePHP/Connection.cpp b/php/src/IcePHP/Connection.cpp
index db55120acae..a9b780bab82 100644
--- a/php/src/IcePHP/Connection.cpp
+++ b/php/src/IcePHP/Connection.cpp
@@ -9,6 +9,7 @@
#include <Connection.h>
#include <Endpoint.h>
+#include <Types.h>
#include <Util.h>
using namespace std;
@@ -136,6 +137,97 @@ ZEND_METHOD(Ice_Connection, flushBatchRequests)
}
}
+ZEND_METHOD(Ice_Connection, setACM)
+{
+ Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ zval* t;
+ zval* c;
+ zval* h;
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("zzz"), &t, &c, &h TSRMLS_CC) != SUCCESS)
+ {
+ RETURN_NULL();
+ }
+
+ IceUtil::Optional<Ice::Int> timeout;
+ IceUtil::Optional<Ice::ACMClose> close;
+ IceUtil::Optional<Ice::ACMHeartbeat> heartbeat;
+
+ if(!isUnset(t TSRMLS_CC))
+ {
+ if(Z_TYPE_P(t) != IS_LONG)
+ {
+ invalidArgument("value for 'timeout' argument must be Unset or an integer");
+ RETURN_NULL();
+ }
+ timeout = static_cast<Ice::Int>(Z_LVAL_P(t));
+ }
+
+ if(!isUnset(c TSRMLS_CC))
+ {
+ if(Z_TYPE_P(c) != IS_LONG)
+ {
+ invalidArgument("value for 'close' argument must be Unset or an enumerator of ACMClose");
+ RETURN_NULL();
+ }
+ close = static_cast<Ice::ACMClose>(Z_LVAL_P(c));
+ }
+
+ if(!isUnset(h TSRMLS_CC))
+ {
+ if(Z_TYPE_P(h) != IS_LONG)
+ {
+ invalidArgument("value for 'heartbeat' argument must be Unset or an enumerator of ACMHeartbeat");
+ RETURN_NULL();
+ }
+ heartbeat = static_cast<Ice::ACMHeartbeat>(Z_LVAL_P(h));
+ }
+
+ try
+ {
+ _this->setACM(timeout, close, heartbeat);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
+ZEND_METHOD(Ice_Connection, getACM)
+{
+ if(ZEND_NUM_ARGS() > 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ Ice::ACM acm = _this->getACM();
+
+ zend_class_entry* acmClass = idToClass("::Ice::ACM" TSRMLS_CC);
+
+ if(object_init_ex(return_value, const_cast<zend_class_entry*>(acmClass)) != SUCCESS)
+ {
+ runtimeError("unable to initialize object of type %s" TSRMLS_CC, acmClass->name);
+ RETURN_NULL();
+ }
+
+ add_property_long(return_value, STRCAST("timeout"), static_cast<long>(acm.timeout));
+ add_property_long(return_value, STRCAST("close"), static_cast<long>(acm.close));
+ add_property_long(return_value, STRCAST("heartbeat"), static_cast<long>(acm.heartbeat));
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_Connection, type)
{
if(ZEND_NUM_ARGS() > 0)
@@ -290,6 +382,8 @@ static zend_function_entry _connectionClassMethods[] =
ZEND_ME(Ice_Connection, close, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getEndpoint, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, flushBatchRequests, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, setACM, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, getACM, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, type, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, timeout, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, toString, NULL, ZEND_ACC_PUBLIC)