Class: StropheRuby::EventLoop

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

Class Method Summary collapse

Class Method Details

.prepareObject

Initialize the strophe library



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

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

.run(rb_ctx) ⇒ Object

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



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

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



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

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);
    xmpp_run_once(ctx, NUM2INT(timeout));
    return Qtrue;        
}

.shutdownObject

shutdown the library



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

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



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

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



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

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