public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; // Response Fragment currentIndex = EncodeUtil.Decode(ref RequestMessageId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref FailureCode, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ParticipantId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref AvatarId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleName, packetBytes, currentIndex, 40); currentIndex = EncodeUtil.Decode(ref BubbleAssetCacheUrl, packetBytes, currentIndex, 50); currentIndex = EncodeUtil.Decode(ref BubbleRange, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubblePerceptionRange, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleRealTime, packetBytes, currentIndex); // Program Fragment currentIndex = EncodeUtil.Decode(ref ProgramName, packetBytes, currentIndex, 25); currentIndex = EncodeUtil.Decode(ref ProgramMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProgramMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolSourceRevision, packetBytes, currentIndex); //FramesDecoded++; return(currentIndex); }
public override int DecodeFragmentData(int frameIndex, byte[] packetBytes, int startIndex) { int currentIndex = startIndex; if (frameIndex == 0) { currentIndex = EncodeUtil.Decode(ref InteractionName, packetBytes, currentIndex, 20); currentIndex = EncodeUtil.Decode(ref SourceParticipantId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref SourceObjectId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref TargetParticipantId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref TargetObjectId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ExtensionDialect, packetBytes, currentIndex, 4); currentIndex = EncodeUtil.Decode(ref ExtensionDialectMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ExtensionDialectMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref extensionLength, packetBytes, currentIndex); SetExtensionData(new byte[extensionLength]); currentIndex = EncodeUtil.Decode(ref ExtensionData, 0, packetBytes, currentIndex, FragmentDataSize(frameIndex) - InternalDataPrefixSize); } else { currentIndex = EncodeUtil.Decode(ref ExtensionData, frameIndex * MxpConstants.MaxFrameDataSize - TotalDataPrefixSize, packetBytes, currentIndex, FragmentDataSize(frameIndex)); } return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; currentIndex = EncodeUtil.Decode(ref ListType, packetBytes, currentIndex); //FramesDecoded++; return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; currentIndex = EncodeUtil.Decode(ref ParticipantId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ParticipantIdentityType, packetBytes, currentIndex, 20); currentIndex = EncodeUtil.Decode(ref ParticipantIdentity, packetBytes, currentIndex, 219); return(currentIndex); }
public static void DecodePacketHeader(Packet packet) { int currentIndex = 0; currentIndex = EncodeUtil.Decode(ref packet.SessionId, packet.PacketBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref packet.PacketId, packet.PacketBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref packet.FirstSendTime, packet.PacketBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref packet.Quaranteed, packet.PacketBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref packet.ResendCount, packet.PacketBytes, currentIndex); packet.DataStartIndex = currentIndex; }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; // Response Fragment currentIndex = EncodeUtil.Decode(ref RequestMessageId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref FailureCode, packetBytes, currentIndex); //FramesDecoded++; return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { packetIdCount = length / 4; int currentIndex = startIndex; for (int i = 0; i < packetIdCount; i++) { currentIndex = EncodeUtil.Decode(ref packetIds[i], packetBytes, currentIndex); } //FramesDecoded++; return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; if (frameIndex == 0) { // Response Fragment currentIndex = EncodeUtil.Decode(ref SourceBubbleId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref TargetBubbleId, packetBytes, currentIndex); } currentIndex = ObjectFragment.DecodeFragmentData(frameIndex, packetBytes, currentIndex); FrameCount = ObjectFragment.FrameCount; // refreshing message frame count from object fragment //FramesDecoded++; return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; if (frameIndex == 0) { // Response Fragment currentIndex = EncodeUtil.Decode(ref RequestMessageId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref FailureCode, packetBytes, currentIndex); } currentIndex = InteractionFragment.DecodeFragmentData(frameIndex, packetBytes, currentIndex); FrameCount = InteractionFragment.FrameCount; // refreshing message frame count from object fragment //FramesDecoded++; return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; currentIndex = EncodeUtil.Decode(ref TargetBubbleId, packetBytes, currentIndex); currentIndex = SourceBubbleFragment.DecodeFragmentData(packetBytes, currentIndex); // Program Fragment currentIndex = EncodeUtil.Decode(ref ProgramName, packetBytes, currentIndex, 25); currentIndex = EncodeUtil.Decode(ref ProgramMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProgramMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolSourceRevision, packetBytes, currentIndex); //FramesDecoded++; return(currentIndex); }
/// <summary> /// Decodes one frame from packet bytes. /// </summary> /// <param name="session"> /// A session the message belongs to. <see cref="Session"/> /// </param> /// <param name="packetBytes"> /// A byte array containing packet bytes. <see cref="System.Byte"/> /// </param> /// <param name="startIndex"> /// The start index in packet byte array. <see cref="System.Int32"/> /// </param> /// <param name="frameQuaranteed"> /// Output parameter which is true if frame is quaranteed. <see cref="System.Boolean"/> /// </param> /// <returns> /// Start index of next frame in packet byte array. <see cref="System.Int32"/> /// </returns> public static int DecodeFrame(Session session, byte[] packetBytes, int startIndex, ref bool frameQuaranteed) { byte messageType = 0; uint messageId = 0; int currentIndex = startIndex; UInt16 frameCount = 0; byte frameSize = 0; ushort frameIndex = 0; currentIndex = EncodeUtil.Decode(ref messageType, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref messageId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref frameCount, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref frameIndex, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref frameSize, packetBytes, currentIndex); MessageEntry messageEntry = session.GetPartialInboundMessage(messageId, messageType, frameCount, frameIndex); if (messageEntry != null) { Message message = messageEntry.Message; frameQuaranteed = message.Quaranteed; currentIndex = message.DecodeFrameData(frameIndex, packetBytes, currentIndex, frameSize); messageEntry.FramesCompleted++; if (messageEntry.FramesCompleted == message.FrameCount) { session.CompleteInboundMessage(message); } } else { // TODO Should these frames be stored for applying after the initial packet has arrived. // Should fix problems in situation where packet containing the initial packet is dropped or // if the packet with later frame just happens to arrive first. LogUtil.Warn("Ignored frame which arrived before message initialization frame. Possible reconnect."); } return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; float tempFloat = 0; currentIndex = EncodeUtil.Decode(ref ObjectIndex, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Location.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Location.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Location.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.W = tempFloat; //FramesDecoded++; return(currentIndex); }
public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length) { int currentIndex = startIndex; currentIndex = EncodeUtil.Decode(ref BubbleId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref AvatarId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleName, packetBytes, currentIndex, 40); currentIndex = EncodeUtil.Decode(ref LocationName, packetBytes, currentIndex, 28); currentIndex = EncodeUtil.Decode(ref ParticipantIdentifier, packetBytes, currentIndex, 32); currentIndex = EncodeUtil.Decode(ref ParticipantSecret, packetBytes, currentIndex, 32); currentIndex = EncodeUtil.Decode(ref ParticipantRealTime, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref IdentityProviderUrl, packetBytes, currentIndex, 50); // Program Fragment currentIndex = EncodeUtil.Decode(ref ProgramName, packetBytes, currentIndex, 25); currentIndex = EncodeUtil.Decode(ref ProgramMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProgramMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ProtocolSourceRevision, packetBytes, currentIndex); //FramesDecoded++; return(currentIndex); }
public override int DecodeFragmentData(byte[] packetBytes, int startIndex) { int currentIndex = startIndex; float tempFloat = 0; currentIndex = EncodeUtil.Decode(ref BubbleId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleName, packetBytes, currentIndex, 40); currentIndex = EncodeUtil.Decode(ref BubbleAssetCacheUrl, packetBytes, currentIndex, 51); currentIndex = EncodeUtil.Decode(ref OwnerId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleAddress, packetBytes, currentIndex, 40); currentIndex = EncodeUtil.Decode(ref BubblePort, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); BubbleCenter.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); BubbleCenter.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); BubbleCenter.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref BubbleRange, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubblePerceptionRange, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref BubbleRealTime, packetBytes, currentIndex); return(currentIndex); }
public override int DecodeFragmentData(int frameIndex, byte[] packetBytes, int startIndex) { int currentIndex = startIndex; float tempFloat = 0; if (frameIndex == 0) { currentIndex = EncodeUtil.Decode(ref ObjectId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ObjectIndex, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref TypeId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ParentObjectId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ObjectName, packetBytes, currentIndex, 20); currentIndex = EncodeUtil.Decode(ref TypeName, packetBytes, currentIndex, 20); currentIndex = EncodeUtil.Decode(ref OwnerId, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Location.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Location.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Location.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Velocity.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Velocity.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Velocity.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Acceleration.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Acceleration.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Acceleration.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); Orientation.W = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularVelocity.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularVelocity.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularVelocity.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularVelocity.W = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularAcceleration.X = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularAcceleration.Y = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularAcceleration.Z = tempFloat; currentIndex = EncodeUtil.Decode(ref tempFloat, packetBytes, currentIndex); AngularAcceleration.W = tempFloat; currentIndex = EncodeUtil.Decode(ref BoundingSphereRadius, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref Mass, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ExtensionDialect, packetBytes, currentIndex, 4); currentIndex = EncodeUtil.Decode(ref ExtensionDialectMajorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref ExtensionDialectMinorVersion, packetBytes, currentIndex); currentIndex = EncodeUtil.Decode(ref extensionLength, packetBytes, currentIndex); SetExtensionData(new byte[extensionLength]); currentIndex = EncodeUtil.Decode(ref ExtensionData, 0, packetBytes, currentIndex, FragmentDataSize(frameIndex) - InternalDataPrefixSize); } else { currentIndex = EncodeUtil.Decode(ref ExtensionData, frameIndex * MxpConstants.MaxFrameDataSize - TotalDataPrefixSize, packetBytes, currentIndex, FragmentDataSize(frameIndex)); } return(currentIndex); }