Class: StropheRuby::Context
- Inherits:
-
Object
- Object
- StropheRuby::Context
- Defined in:
- ext/strophe_ruby/strophe_ruby.c
Class Method Summary collapse
-
.new(log_level) ⇒ Object
Initialize a run time context.
Instance Method Summary collapse
-
#initialize(log_level) ⇒ Object
constructor
Ruby initialize for the context.
-
#loop_status ⇒ Object
Get the status of the control loop TODO: Define ruby constants for the loop statuses.
-
#loop_status=(rb_loop_status) ⇒ Object
Set the loop status.
Constructor Details
#initialize(log_level) ⇒ Object
Ruby initialize for the context. Hmm... do we really need this?
101 102 103 104 |
# File 'ext/strophe_ruby/strophe_ruby.c', line 101
static VALUE t_xmpp_ctx_init(VALUE self, VALUE log_level) {
rb_iv_set(self, "@log_level", log_level);
return self;
}
|
Class Method Details
.new(log_level) ⇒ Object
Initialize a run time context
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'ext/strophe_ruby/strophe_ruby.c', line 87
VALUE t_xmpp_ctx_new(VALUE class, VALUE log_level) {
xmpp_log_t *log;
xmpp_log_level_t level;
level=FIX2INT(log_level);
log = xmpp_get_default_logger((xmpp_log_level_t)level);
xmpp_ctx_t *ctx = xmpp_ctx_new(NULL, log);
VALUE tdata = Data_Wrap_Struct(class, 0, t_xmpp_ctx_free, ctx);
VALUE argv[1];
argv[0] = log_level;
rb_obj_call_init(tdata,1,argv);
return tdata;
}
|
Instance Method Details
#loop_status ⇒ Object
Get the status of the control loop TODO: Define ruby constants for the loop statuses. Currently we have to know them by heart (0 = NOTSTARTED, 1 = RUNNING, 2 = QUIT)
71 72 73 74 75 |
# File 'ext/strophe_ruby/strophe_ruby.c', line 71
static VALUE t_xmpp_get_loop_status(VALUE self) {
xmpp_ctx_t *ctx;
Data_Get_Struct(self, xmpp_ctx_t, ctx);
return INT2FIX(ctx->loop_status);
}
|
#loop_status=(rb_loop_status) ⇒ Object
Set the loop status. Don't call this method if you want to exit the control loop. Call xmpp_stop instead. This method will set the loop status at QUIT
79 80 81 82 83 84 |
# File 'ext/strophe_ruby/strophe_ruby.c', line 79
static VALUE t_xmpp_set_loop_status(VALUE self, VALUE rb_loop_status) {
xmpp_ctx_t *ctx;
Data_Get_Struct(self, xmpp_ctx_t, ctx);
ctx->loop_status=FIX2INT(rb_loop_status);
return rb_loop_status;
}
|