0
static VALUE global_server_port;
0
static VALUE global_path_info;
0
static VALUE global_content_length;
0
-static VALUE global_gateway_interface;
0
-static VALUE global_gateway_interface_value;
0
-static VALUE global_server_protocol;
0
-static VALUE global_server_protocol_value;
0
-static VALUE global_server_software;
0
-static VALUE global_ebb_version;
0
static VALUE global_http_host;
0
-VALUE client_env(
VALUE client)
0
+VALUE client_env(
ebb_client *_client)
0
VALUE hash = rb_hash_new();
0
- Data_Get_Struct(client, ebb_client, _client);
0
+ /* This client->env_fields, client->env_value structure is pretty hacky
0
+ * and a bit hard to follow. Look at the #defines at the top of ebb.c to
0
+ * see what they are doing. Basically it's a list of (ptr,length) pairs
0
+ * for both a field and value
0
for(i=0; i < _client->env_size; i++) {
0
rb_hash_aset(hash, env_field(_client->env_fields[i], _client->env_field_lengths[i])
0
, rb_str_new(_client->env_values[i], _client->env_value_lengths[i])
0
- rb_hash_aset(hash, global_gateway_interface, global_gateway_interface_value);
0
- rb_hash_aset(hash, global_server_protocol, global_server_protocol_value);
0
- rb_hash_aset(hash, global_server_software, global_ebb_version);
0
rb_hash_aset(hash, global_path_info, rb_hash_aref(hash, global_request_path));
0
VALUE client_new(ebb_client *_client)
0
VALUE client = Data_Wrap_Struct(cClient, 0, 0, _client);
0
_client->data = (void*)client;
0
- rb_iv_set(client, "@env", client_env(client));
0
- rb_iv_set(client, "@upload_filename", rb_str_new2(_client->upload_file_filename));
0
- rb_iv_set(client, "@write_buffer", rb_ary_new());
0
+ // if(_client->upload_file_filename)
0
+ // rb_iv_set(client, "@upload_filename", rb_str_new2(_client->upload_file_filename));
0
+ rb_iv_set(client, "@ebb_env", client_env(_client));
0
VALUE server_init(VALUE server, VALUE host, VALUE port)
0
struct ev_loop *loop = ev_default_loop (0);
0
Data_Get_Struct(server, ebb_server, _server);
0
ebb_server_init(_server, loop, StringValuePtr(host), FIX2INT(port), request_cb, (void*)server);
0
-VALUE server_
start(VALUE server)
0
+VALUE server_
listen(VALUE server)
0
Data_Get_Struct(server, ebb_server, _server);
0
rb_iv_set(server, "@waiting_clients", rb_ary_new());
0
- ebb_server_
start(_server);
0
+ ebb_server_
listen(_server);
0
+oneshot_timeout (struct ev_loop *loop, struct ev_timer *w, int revents) {;}
0
VALUE server_process_connections(VALUE server)
0
Data_Get_Struct(server, ebb_server, _server);
0
- //ev_loop(_server->loop, EVLOOP_NONBLOCK);
0
+ ev_timer_init (&timeout, oneshot_timeout, 0.5, 0.);
0
+ ev_timer_start (_server->loop, &timeout);
0
ev_loop(_server->loop, EVLOOP_ONESHOT);
0
/* XXX: Need way to know when the loop is finished...
0
* should return true or false */
0
+ ev_timer_stop(_server->loop, &timeout);
0
-VALUE server_
stop(VALUE server)
0
+VALUE server_
deafen(VALUE server)
0
Data_Get_Struct(server, ebb_server, _server);
0
- ebb_server_
stop(_server);
0
+ ebb_server_
deafen(_server);
0
-VALUE client_
start_writing(VALUE client)
0
+VALUE client_
finished(VALUE client)
0
Data_Get_Struct(client, ebb_client, _client);
0
- ebb_client_
start_writing(_client, NULL);
0
+ ebb_client_
finished(_client);
0
+VALUE client_init(VALUE self, VALUE something) {return self;}
0
cServer = rb_define_class_under(mEbb, "Server", rb_cObject);
0
cClient = rb_define_class_under(mEbb, "Client", rb_cObject);
0
-/** Defines global strings in the init method. */
0
-#define DEF_GLOBAL(N, val) global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N)
0
+ /** Defines global strings in the init method. */
0
+#define DEF_GLOBAL(N, val) global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N)
0
DEF_GLOBAL(http_prefix, "HTTP_");
0
DEF_GLOBAL(request_method, "REQUEST_METHOD");
0
DEF_GLOBAL(request_uri, "REQUEST_URI");
0
DEF_GLOBAL(server_port, "SERVER_PORT");
0
DEF_GLOBAL(path_info, "PATH_INFO");
0
DEF_GLOBAL(content_length, "HTTP_CONTENT_LENGTH");
0
- DEF_GLOBAL(gateway_interface, "GATEWAY_INTERFACE");
0
- DEF_GLOBAL(gateway_interface_value, "CGI/1.2");
0
- DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
0
- DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
0
DEF_GLOBAL(http_host, "HTTP_HOST");
0
- DEF_GLOBAL(ebb_version, "Ebb 0.0.1"); /* XXX Why is this defined here? */
0
- DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
0
rb_define_alloc_func(cServer, server_alloc);
0
rb_define_method(cServer, "init", server_init, 2);
0
rb_define_method(cServer, "process_connections", server_process_connections, 0);
0
- rb_define_method(cServer, "really_start", server_start, 0);
0
- rb_define_method(cServer, "stop", server_stop, 0);
0
+ rb_define_method(cServer, "listen", server_listen, 0);
0
+ rb_define_method(cServer, "deafen", server_deafen, 0);
0
+ rb_define_method(cClient, "initialize", client_init, 1);
0
rb_define_method(cClient, "write", client_write, 1);
0
- rb_define_method(cClient, "finished", client_start_writing, 0);
0
rb_define_method(cClient, "read_input", client_read_input, 1);
0
+ rb_define_method(cClient, "finished", client_finished, 0);
0
+ rb_define_method(cClient, "read_input", client_read_input, 1);
Comments
No one has commented yet.