public override void OnMsg(IntPtr data) { //测试接收数据 CppRecvStream r = new CppRecvStream(data); MGS_TYPE type = r.ReadType(); switch (type) { case MGS_TYPE.MSG_BYTESTREAM: { sbyte n1 = r.ReadInt8(); Int16 n2 = r.ReadInt16(); Int32 n3 = r.ReadInt32(); Int64 n4 = r.ReadInt64(); float n5 = r.ReadFloat(); double n6 = r.ReadDouble(); byte[] n7 = r.ReadBytes(); string n8 = r.ReadString(); Debug.Log(n1); Debug.Log(n2); Debug.Log(n3); Debug.Log(n4); Debug.Log(n5); Debug.Log(n6); Debug.Log(Encoding.UTF8.GetString(n7)); Debug.Log(n8); } break; } }
public void Finish(MGS_TYPE type) { if (pCppStream == IntPtr.Zero) { return; } CppFinish(pCppStream, type); }
public MGS_TYPE ReadType(MGS_TYPE t = MGS_TYPE.MSG_ERROR) { if (pCppStream == IntPtr.Zero) { return(t); } return((MGS_TYPE)CppReadInt32(pCppStream, (int)t)); }
private static extern void CppFinish(IntPtr pStream, MGS_TYPE type);