我正在为全息透镜开发一个共享应用程序,并尝试使用
Custom Messages.cs
包含在
MixedRealityToolkit-Unity
.
byte
double
,
float
int
,
long
,
short
和
Xstring
NetworkConnection.[Write/Read]()
重载函数,但我无法获取
NetworkMessage.ReadArray()
我在网络上成功地发送了许多其他自定义消息,因此我知道网络连接不应该成为问题。
正在编写消息
public void SendByteArray(byte[] array)
{
// If connected to session, broadcast command
if (serverConnection != null && serverConnection.IsConnected())
{
// Create an outgoing network message to contain all the info we want to send
NetworkOutMessage msg = CreateMessage((byte)TestMessageID.SendArray);
// Append Command
msg.WriteArray(array, Convert.ToUInt32(array.Length));
// Send the message as a broadcast, which will cause the server to forward it to all other users in the session.
serverConnection.Broadcast(
msg,
MessagePriority.Immediate,
MessageReliability.UnreliableSequenced,
MessageChannel.Avatar);
}
}
private byte[] OnArrayReceived(NetworkInMessage msg)
{
msg.ReadInt64(); // need to read UserID first, but isn't used for this function
return msg.ReadArray();
}
根据签名,它看起来像是一个复制得不好的、重命名过的书写函数,但我不知道如何修改它。
public virtual void ReadArray(byte[] data, uint arrayLength) {
global::System.Runtime.InteropServices.GCHandle pinHandle_data = global::System.Runtime.InteropServices.GCHandle.Alloc(data, global::System.Runtime.InteropServices.GCHandleType.Pinned); try {
{
SharingClientPINVOKE.NetworkInMessage_ReadArray(swigCPtr, (global::System.IntPtr)pinHandle_data.AddrOfPinnedObject(), arrayLength);
}
} finally { pinHandle_data.Free(); }
}
以下是
NetworkInMessage_ReadArray()
但随之而来的是这个警告。
//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 3.0.10
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------