static int serialization(IntPtr L) { L.ChkArgsCount(1); clientlib.net.NetMsg obj = (clientlib.net.NetMsg)L.ChkUserDataSelf(1, "clientlib.net.NetMsg"); obj.serialization(); return(0); }
/// <summary> /// 发送数据 /// </summary> /// <param name="buffer"></param> /// <returns></returns> public bool send(INetMsg message) { if (!isConnected) { return(false); } NetMsg msg = (NetMsg)message; if (msg == null) { return(false); } //序列化 msg.serialization(); NetworkStream stream = _tcp.GetStream(); if (stream.CanWrite) { try { msg.buffer.position = 0; stream.BeginWrite(msg.buffer.array, msg.buffer.position, msg.buffer.limit - msg.buffer.position, new AsyncCallback(AsyncWrite), null); } catch (Exception ex) { OnException(ex); return(false); } } return(true); }