public void onData(byte[] data) { lock (producerQueue) { if (usedIndex >= length) { object[] temp = new object[length + 10]; Array.Copy(producerQueue, 0, temp, 0, length); producerQueue = temp; length += 10; } UtilLog.Log("有消息"); producerQueue[usedIndex++] = data; } }
public void updata() { tcpHandler.consume(); object[] data = tcpConsumer.data; for (int i = 0; i < tcpConsumer.size; i++) { buffer.reset((byte[])data[i]); try { tcpHandler.handle(buffer); } catch (Exception ex) { UtilLog.Log("消息未注册"); Debug.LogError(ex); } } tcpConsumer.size = 0; }
public void handle(ByteBuffer buffer) { CMessageID code = (CMessageID)buffer.readShort(); buffer.code = code; UtilLog.Log("收到消息" + code); switch (code) { case CMessageID.MS_Error: break; default: handles[code](buffer); // BaseHandle baseHandle = handles[code]; // if (baseHandle != null) // { // baseHandle.onResult(code, buffer); // } break; } }
void Awake() { UtilLog.Log("Awake"); DontDestroyOnLoad(this.gameObject); }
public void send(ByteBuffer data) { UtilLog.Log(">>>>消息发送:" + data.ToString()); socket.send(data); //Singleton<NetIoClientSingle>.Instance.Send(data); }