aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/load_net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/lua_api/load_net.cpp')
-rw-r--r--src/shared/lua_api/load_net.cpp50
1 files changed, 2 insertions, 48 deletions
diff --git a/src/shared/lua_api/load_net.cpp b/src/shared/lua_api/load_net.cpp
index b6e95bc..04a9239 100644
--- a/src/shared/lua_api/load_net.cpp
+++ b/src/shared/lua_api/load_net.cpp
@@ -422,53 +422,6 @@ void gameloop_net(lua_State* L){
}
//printf("There are %d items left on the lua stack\n",lua_gettop(L));
lua_pop(L,2);
- //for(std::map<nng_socket*,int>::iterator it = netfuncs.begin(); it != netfuncs.end(); ++it){
- ////printf("In for socket %p\n",(void*)(it->first));
- ////char* buf = NULL;
- ////size_t size;
- ////int err = nng_recv(*(it->first), &buf, &size, NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC);
- //nng_msg *msgp;
- ////printf("About to recvmsg()\n");
- //int err = nng_recvmsg(*(it->first), &msgp, NNG_FLAG_NONBLOCK);
- ////printf("Done recvmsg()\n");
- ////printf("Got bytes: %d EAGAIN:%d\n",bytes,EAGAIN);
- //if(err != 0 && err != NNG_EAGAIN){
- //printf("Net error: %s\n\t err: %d\n\teagain:%d\n",nng_strerror(err),err,NNG_EAGAIN);
- ////lua_pushstring(L,"Failed to receive");
- ////lua_error(L);
- //}else if(err == NNG_EAGAIN){
- ////printf("EAGAIN\n");
- ////do nothing
- //}else{
- //printf("Calling function with stream\n");
- //char* buf = (char*)nng_msg_body(msgp);
- //printf("Got msg body\n");
- //size_t size = nng_msg_len(msgp);
- //printf("Got msg size\n");
- ////find how long until the first null character
- //struct stream* stream = stream_create();
- //stream->length = size;
- //stream->data = buf;
- //stream_print(stream);
- //int f = it->second;
- //if(f == -1){//not set yet
- //lua_pushstring(L,"Got message for a socket without a receiving function");
- //lua_error(L);
- //}
- //lua_rawgeti(L,LUA_REGISTRYINDEX,f);//function(stream)
- //lua_newtable(L);//function(stream),{}
- //lua_pushlightuserdata(L,stream);//func,{},ud_stream
- //lua_setfield(L,-2,"data");//func,{data=stream}
- //luaL_getmetatable(L,"net.stream");//func,{data=stream}
- //lua_setmetatable(L,-2);//func,{stream}
- //lua_call(L,1,0);//
- ////printf("Finished calling gameloop, buf is %p, size is %zu\n",buf,size);
- //nng_msg_free(msgp);
- //printf("called nn_freemsg\n");
- //free(stream);//We manually set stream->data so free_stream would crash here
- //printf("Called free on stream\n");
- //}
- //}
//printf("Done with net game loop\n");
}
@@ -542,7 +495,8 @@ int send(lua_State* L){
lua_call(L,1,0);//socket,
printf("Finished the stream call\n");
lua_pop(L,1);//
- printf("About to nn_send\n\tfd:%p\n\t%s\n\t%ld\n",fd,s->data,s->length);
+ printf("About to nng_send\n\tfd:%p\n\t%s\n\t%ld\n",fd,s->data,s->length);
+ //int err = nng_send(*fd, s->data, s->length,0);
int err = nng_send(*fd, s->data, s->length,0);
printf("Finished nn_send\n");
stream_free(s);