//========================================== public void send(object obj) { if (socket == null) { Debug.LogWarning("Socket is null"); return; } object ret = packMessage(obj); if (ret == null || isStopping || !connected) { return; } socket.SendAsync(ret as byte[]); }
//========================================== public bool send(object obj) { if (socket == null) { Debug.LogWarning("Socket is null"); return(false); } object ret = packMessage(obj); if (isStopping || !connected) { Debug.LogWarning("isStopping =" + isStopping + "|| !connected=" + !connected); return(false); } if (ret != null) { socket.SendAsync(ret as byte[]); } else { //这种情况可能是在组包的时候就已经发送了,还有种情况就是异常,不过其实不太可能异常,先不处理 } return(true); }