ext/iodine/iodine_pubsub.c
/** Initializes the Connection Ruby class. */
Initializes the Connection Ruby class.
Initializes the Connection Ruby class .
void iodine_pubsub_init(void) {
  subscribe_id = rb_intern2("subscribe", 9);
  unsubscribe_id = rb_intern2("unsubscribe", 11);
  publish_id = rb_intern2("publish", 7);
  default_id = rb_intern2("default_engine", 14);
  redis_id = rb_intern2("redis", 5);
  call_id = rb_intern2("call", 4);
  VALUE PubSubModule = rb_define_module_under(IodineModule, "PubSub");
  rb_define_module_function(PubSubModule, "default=", iodine_pubsub_default_set,
                            1);
  rb_define_module_function(PubSubModule, "default", iodine_pubsub_default_get,
                            0);
  rb_define_module_function(PubSubModule, "attach", iodine_pubsub_attach, 1);
  rb_define_module_function(PubSubModule, "detach", iodine_pubsub_detach, 1);
  rb_define_module_function(PubSubModule, "reset", iodine_pubsub_reset, 1);
  EngineClass = rb_define_class_under(PubSubModule, "Engine", rb_cObject);
  rb_define_alloc_func(EngineClass, iodine_pubsub_data_alloc_c);
  rb_define_method(EngineClass, "subscribe", iodine_pubsub_subscribe, 2);
  rb_define_method(EngineClass, "unsubscribe", iodine_pubsub_unsubscribe, 2);
  rb_define_method(EngineClass, "publish", iodine_pubsub_publish, 2);
  rb_define_const(PubSubModule, "CLUSTER",
                  iodine_pubsub_make_C_engine(FIO_PUBSUB_CLUSTER));
  rb_define_const(PubSubModule, "PROCESS",
                  iodine_pubsub_make_C_engine(FIO_PUBSUB_PROCESS));
  rb_define_const(PubSubModule, "SIBLINGS",
                  iodine_pubsub_make_C_engine(FIO_PUBSUB_SIBLINGS));
  rb_define_const(PubSubModule, "PUBLISH2ROOT",
                  iodine_pubsub_make_C_engine(FIO_PUBSUB_ROOT));
  VALUE RedisClass = rb_define_class_under(PubSubModule, "Redis", EngineClass);
  rb_define_method(RedisClass, "initialize", iodine_pubsub_redis_new, -1);
  rb_define_method(RedisClass, "cmd", iodine_pubsub_redis_cmd, -1);
}
void iodine_pubsub_init ( void ) { subscribe_id = rb_intern2 ( " " , 9 ) ; unsubscribe_id = rb_intern2 ( " " , 11 ) ; publish_id = rb_intern2 ( " " , 7 ) ; default_id = rb_intern2 ( " " , 14 ) ; redis_id = rb_intern2 ( " " , 5 ) ; call_id = rb_intern2 ( " " , 4 ) ; VALUE PubSubModule = rb_define_module_under ( IodineModule , " " ) ; rb_define_module_function ( PubSubModule , " " , iodine_pubsub_default_set , 1 ) ; rb_define_module_function ( PubSubModule , " " , iodine_pubsub_default_get , 0 ) ; rb_define_module_function ( PubSubModule , " " , iodine_pubsub_attach , 1 ) ; rb_define_module_function ( PubSubModule , " " , iodine_pubsub_detach , 1 ) ; rb_define_module_function ( PubSubModule , " " , iodine_pubsub_reset , 1 ) ; EngineClass = rb_define_class_under ( PubSubModule , " " , rb_cObject ) ; rb_define_alloc_func ( EngineClass , iodine_pubsub_data_alloc_c ) ; rb_define_method ( EngineClass , " " , iodine_pubsub_subscribe , 2 ) ; rb_define_method ( EngineClass , " " , iodine_pubsub_unsubscribe , 2 ) ; rb_define_method ( EngineClass , " " , iodine_pubsub_publish , 2 ) ; rb_define_const ( PubSubModule , " " , iodine_pubsub_make_C_engine ( FIO_PUBSUB_CLUSTER ) ) ; rb_define_const ( PubSubModule , " " , iodine_pubsub_make_C_engine ( FIO_PUBSUB_PROCESS ) ) ; rb_define_const ( PubSubModule , " " , iodine_pubsub_make_C_engine ( FIO_PUBSUB_SIBLINGS ) ) ; rb_define_const ( PubSubModule , " " , iodine_pubsub_make_C_engine ( FIO_PUBSUB_ROOT ) ) ; VALUE RedisClass = rb_define_class_under ( PubSubModule , " " , EngineClass ) ; rb_define_method ( RedisClass , " " , iodine_pubsub_redis_new , -1 ) ; rb_define_method ( RedisClass , " " , iodine_pubsub_redis_cmd , -1 ) ; }
Initializes the Connection Ruby class.
Initializes the Connection Ruby class .
/* Define the PubSub module and it's methods */ /* Define the Engine class and it's methods */ /**
  The {Iodine::PubSub::Engine} class is the parent for all engines to inherit
  from.

  Engines should inherit this class and override the `subscribe`, `unsubscribe`
  and `publish` callbacks (which shall be called by {Iodine}).

  After creation, Engines should attach themselves to Iodine using
  {Iodine::PubSub.attach} or their callbacks will never get called.

  Engines can also set themselves to be the default engine using
  {Iodine::PubSub.default=}.
  */ /* Define the CLUSTER and PROCESS engines */ /* CLUSTER publishes data to all the subscribers in the process cluster. */ /* PROCESS publishes data to all the subscribers in a single process. */ /* SIBLINGS publishes data to all the subscribers in the *other* processes
   * process. */ /* PUBLISH2ROOT publishes data only to the root / master process. */