summaryrefslogtreecommitdiff
path: root/ruby/src/IceRuby/Connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ruby/src/IceRuby/Connection.cpp')
-rw-r--r--ruby/src/IceRuby/Connection.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp
index 6b4b57efdc7..2c5f65a8434 100644
--- a/ruby/src/IceRuby/Connection.cpp
+++ b/ruby/src/IceRuby/Connection.cpp
@@ -46,14 +46,23 @@ IceRuby::createConnection(const Ice::ConnectionPtr& p)
extern "C"
VALUE
-IceRuby_Connection_close(VALUE self, VALUE b)
+IceRuby_Connection_close(VALUE self, VALUE mode)
{
ICE_RUBY_TRY
{
Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self));
assert(p);
- (*p)->close(RTEST(b));
+ volatile VALUE type = callRuby(rb_path2class, "Ice::ConnectionClose");
+ if(callRuby(rb_obj_is_instance_of, mode, type) != Qtrue)
+ {
+ throw RubyException(rb_eTypeError,
+ "value for 'mode' argument must be an enumerator of Ice.ConnectionClose");
+ }
+ volatile VALUE modeValue = callRuby(rb_funcall, mode, rb_intern("to_i"), 0);
+ assert(TYPE(modeValue) == T_FIXNUM);
+ Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(FIX2LONG(modeValue));
+ (*p)->close(cc);
}
ICE_RUBY_CATCH
return Qnil;
@@ -76,6 +85,21 @@ IceRuby_Connection_flushBatchRequests(VALUE self)
extern "C"
VALUE
+IceRuby_Connection_heartbeat(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self));
+ assert(p);
+
+ (*p)->heartbeat();
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_Connection_setACM(VALUE self, VALUE t, VALUE c, VALUE h)
{
ICE_RUBY_TRY
@@ -221,6 +245,7 @@ IceRuby_Connection_getEndpoint(VALUE self)
ICE_RUBY_CATCH
return Qnil;
}
+
extern "C"
VALUE
IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s)
@@ -241,6 +266,21 @@ IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s)
extern "C"
VALUE
+IceRuby_Connection_throwException(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self));
+ assert(p);
+
+ (*p)->throwException();
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_Connection_toString(VALUE self)
{
ICE_RUBY_TRY
@@ -377,6 +417,7 @@ IceRuby::initConnection(VALUE iceModule)
//
rb_define_method(_connectionClass, "close", CAST_METHOD(IceRuby_Connection_close), 1);
rb_define_method(_connectionClass, "flushBatchRequests", CAST_METHOD(IceRuby_Connection_flushBatchRequests), 0);
+ rb_define_method(_connectionClass, "heartbeat", CAST_METHOD(IceRuby_Connection_heartbeat), 0);
rb_define_method(_connectionClass, "setACM", CAST_METHOD(IceRuby_Connection_setACM), 3);
rb_define_method(_connectionClass, "getACM", CAST_METHOD(IceRuby_Connection_getACM), 0);
rb_define_method(_connectionClass, "type", CAST_METHOD(IceRuby_Connection_type), 0);
@@ -384,6 +425,7 @@ IceRuby::initConnection(VALUE iceModule)
rb_define_method(_connectionClass, "getInfo", CAST_METHOD(IceRuby_Connection_getInfo), 0);
rb_define_method(_connectionClass, "getEndpoint", CAST_METHOD(IceRuby_Connection_getEndpoint), 0);
rb_define_method(_connectionClass, "setBufferSize", CAST_METHOD(IceRuby_Connection_setBufferSize), 2);
+ rb_define_method(_connectionClass, "throwException", CAST_METHOD(IceRuby_Connection_throwException), 0);
rb_define_method(_connectionClass, "toString", CAST_METHOD(IceRuby_Connection_toString), 0);
rb_define_method(_connectionClass, "to_s", CAST_METHOD(IceRuby_Connection_toString), 0);
rb_define_method(_connectionClass, "inspect", CAST_METHOD(IceRuby_Connection_toString), 0);