Class: StropheRuby::EventLoop

Inherits:
Object
  • Object
show all
Defined in:
ext/strophe_ruby.c

Constant Summary collapse

LOOP_RUNNING =
INT2FIX(XMPP_LOOP_RUNNING)
LOOP_NOTSTARTED =
INT2FIX(XMPP_LOOP_NOTSTARTED)
LOOP_QUIT =
INT2FIX(XMPP_LOOP_QUIT)

Class Method Summary collapse

Class Method Details

.prepareObject

Initialize the strophe library



24
25
26
27
# File 'ext/strophe_ruby.c', line 24

VALUE t_xmpp_initialize(VALUE self) {
    xmpp_initialize();
    return Qtrue;
}

.run(rb_ctx) ⇒ Object

parse the stream continuously (by calling xmpp_run_once in a while loop)



50
51
52
53
54
55
# File 'ext/strophe_ruby.c', line 50

VALUE t_xmpp_run(VALUE self, VALUE rb_ctx) {
    xmpp_ctx_t *ctx;
    Data_Get_Struct(rb_ctx,xmpp_ctx_t,ctx);	
    xmpp_run(ctx);
    return Qtrue;
}

.run_once(rb_ctx, timeout) ⇒ Object

parse the stream one time



42
43
44
45
46
47
# File 'ext/strophe_ruby.c', line 42

VALUE t_xmpp_run_once(VALUE self, VALUE rb_ctx, VALUE timeout) {
    xmpp_ctx_t *ctx;        
    Data_Get_Struct(rb_ctx,xmpp_ctx_t,ctx);
    int i = xmpp_run_once(ctx, NUM2INT(timeout));
    return INT2FIX(i);        
}

.shutdownObject

shutdown the library



30
31
32
33
# File 'ext/strophe_ruby.c', line 30

VALUE t_xmpp_shutdown(VALUE self) {
    xmpp_shutdown();
    return Qnil;
}

.stop(rb_ctx) ⇒ Object

Set a flag to indicate to our event loop that it must exit



58
59
60
61
62
63
# File 'ext/strophe_ruby.c', line 58

VALUE t_xmpp_stop(VALUE self, VALUE rb_ctx) {
    xmpp_ctx_t *ctx;
    Data_Get_Struct(rb_ctx, xmpp_ctx_t, ctx);
    xmpp_stop(ctx);
    return Qtrue;
}

.version(major, minor) ⇒ Object

check Strophe version



36
37
38
39
# File 'ext/strophe_ruby.c', line 36

VALUE t_xmpp_version_check(VALUE self, VALUE major, VALUE minor) {
    int res = xmpp_version_check(FIX2INT(major), FIX2INT(minor));
    return INT2FIX(res);
}