コード例 #1
0
ファイル: decoder.c プロジェクト: weimingtom/chuck
int32_t 
lua_rpacket_decoder_new(lua_State *L)
{
	if(LUA_TNUMBER != lua_type(L,1))
		return luaL_error(L,"arg1 should be number");
	lua_pushlightuserdata(L,rpacket_decoder_new(lua_tonumber(L,1)));
	return 1;
}
コード例 #2
0
ファイル: conn_broad_client.c プロジェクト: Oooocean/chuck
static void on_connected(int32_t fd,int32_t err,void *ud){
	if(fd >= 0 && err == 0){
		engine *e = (engine*)ud;
		connection *c = connection_new(fd,65535,rpacket_decoder_new(1024));
		engine_associate(e,(handle*)c,on_packet);
		timer *t = engine_regtimer(e,20,timer_callback,c);
		c->ud_ptr = t;
		//packet *p = (packet*)wpacket_new(64);
		//wpacket_write_uint64((wpacket*)p,(uint64_t)c);
		//wpacket_write_string((wpacket*)p,"hello world\n");
		//connection_send(c,p,NULL);		
	}else{
		printf("connect error\n");
	}
}