void * test_init(rain_ctx_t *ctx,char *args) { test_t * tt = malloc(sizeof(test_t)); tt->ctx = ctx; tt->recvsize = 0; tt->cli = 0; char arg[1024]; rain_debug(tt->ctx,"TestRunning,arguments:%s",args); fflush(stdout); int ret = 0; sprintf(arg,"ip=%s&port=%d&watchdog=%d&mode=%s","127.0.0.1",8100,rain_routineid(ctx),"epoll"); ret = rain_spawn(ctx,"tcpsvr",arg,&(tt->tcpsvr_id)); if(ret == RAIN_ERROR){ free(tt); return NULL; } rain_link(ctx,tt->tcpsvr_id); ret = rain_spawn(ctx,"jsv8","test.js",&(tt->jsv8_test_id)); if(ret == RAIN_ERROR){ free(tt); return NULL; } rain_link(ctx,tt->jsv8_test_id); RAIN_CALLBACK(ctx,_recv,_recv_rsp,_link_exit,_time_out,NULL); rain_timeout(ctx,60.0,NULL); return tt; }
void * test_new(struct rain_ctx *ctx,char *args) { test_t * tt = malloc(sizeof(test_t)); tt->ctx = ctx; tt->recvsize = 0; tt->cli = 0; rain_debug(tt->ctx,"TestRunning,arguments:%s",args); fflush(stdout); RAIN_CALLBACK(ctx,_recv,_recv_rsp,_link_exit,_time_out,NULL,_tcp_event); rain_timeout(ctx,60*1000,NULL); tt->tcp = rain_tcp_listen(ctx,"0.0.0.0",8194); tt->x = 0; return tt; }