private static void send_cb(IAsyncResult ar) { netsocket obj = (netsocket)ar.AsyncState; if (obj.sendq.Count == 0) { return; } byte[] a = (byte[])obj.sendq.Dequeue(); obj.dosend(a); return; }
private static void connect_cb(IAsyncResult ar) { netsocket obj = (netsocket)ar.AsyncState; obj._status = CONNECTED; Debug.Log("Connect:" + obj.s.Connected); obj.dorecv(); if (obj.sendq.Count > 0) { byte[] a = (byte[])obj.sendq.Dequeue(); obj.dosend(a); } return; }
public static int lcreate(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { netsocket obj = new netsocket(); ToLua.Push(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: netsocket.create")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private static void recv_cb(IAsyncResult ar) { netsocket obj = (netsocket)ar.AsyncState; int read = obj.s.EndReceive(ar); if (read > 0) { lock (obj.readstream) { obj.readstream.write(obj.buffer, 0, read); } obj.dorecv(); } else { Debug.Log("RecvCB: Disconnect"); obj._status = DISCONNECT; obj.s.Close(); lock (obj.readstream) { obj.readstream.clear(); } } }