Skip to content

Commit e05af37

Browse files
committed
refactor: cleanup locations of util classes and move HasMetaData to FlagUtils
1 parent 5f86f49 commit e05af37

24 files changed

+85
-89
lines changed

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/ClientServerInputMultiplexerDemultiplexer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using UnityEngine;
55
using Viglucci.UnityRSocket.Frame;
6+
using Viglucci.UnityRSocket.Util;
67

78
namespace Viglucci.UnityRSocket
89
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/EpochUtils.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/EpochUtils.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/FrameDeserializer.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using Viglucci.UnityRSocket.Util;
45

56
namespace Viglucci.UnityRSocket.Frame
67
{
@@ -32,20 +33,20 @@ public static class FrameDeserializer
3233
public static RSocketFrame.AbstractFrame DeserializeFrame(List<byte> frameBuffer)
3334
{
3435
int offset = 0;
35-
36+
3637
(int value, int nextOffset) streamId = BufferUtils.ReadUInt32BigEndian(frameBuffer, offset);
3738
offset = streamId.nextOffset;
38-
39+
3940
(int value, int nextOffset) typeAndFlags = BufferUtils.ReadUint16BigEndian(frameBuffer, offset);
40-
41+
4142
// keep highest 6 bits
42-
int type = (int)((uint)typeAndFlags.value >> RSocketFlagUtils.FrameTypeOffset);
43-
43+
int type = (int)((uint)typeAndFlags.value >> FlagUtils.FrameTypeOffset);
44+
4445
// keep lowest 10 bits
45-
int flags = typeAndFlags.value & RSocketFlagUtils.FlagsMask;
46-
46+
int flags = typeAndFlags.value & FlagUtils.FlagsMask;
47+
4748
offset = typeAndFlags.nextOffset;
48-
49+
4950
return (FrameType)type switch
5051
{
5152
FrameType.PAYLOAD => DeserializePayloadFrame(frameBuffer, streamId.value, flags, offset),
@@ -68,7 +69,7 @@ private static RSocketFrame.AbstractFrame DeserializeKeepAliveFrame(
6869
return new RSocketFrame.KeepAliveFrame(streamId)
6970
{
7071
LastReceivedPosition = lastReceivedPosition.value,
71-
Flags = (ushort) flags
72+
Flags = (ushort)flags
7273
};
7374
}
7475

@@ -98,18 +99,18 @@ private static RSocketFrame.AbstractFrame DeserializePayloadFrame(
9899
{
99100
Flags = (ushort)flags
100101
};
101-
102+
102103
ReadPayload(frameBuffer, frame, offset);
103-
104+
104105
return frame;
105106
}
106107

107108
private static void ReadPayload(List<byte> frameBuffer, RSocketFrame.AbstractRequestFrame frame, int offset)
108109
{
109110
frame.Metadata = new List<byte>();
110111
frame.Data = new List<byte>();
111-
112-
if (RSocketFlagUtils.HasMetadata(frame.Flags))
112+
113+
if (FlagUtils.HasMetadata(frame.Flags))
113114
{
114115
(int value, int nextOffset) metadataLength
115116
= BufferUtils.ReadUInt24BigEndian(frameBuffer, offset);

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/RSocketFrame.AbstractFrame.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using Viglucci.UnityRSocket.Util;
23

34
namespace Viglucci.UnityRSocket.Frame
45
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/RSocketFrame.AbstractRequestFrame.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using Viglucci.UnityRSocket.Util;
23

34
namespace Viglucci.UnityRSocket.Frame
45
{
@@ -16,7 +17,7 @@ protected AbstractRequestFrame(int streamId) : base(streamId)
1617
protected void WritePayload(List<byte> bytes)
1718
{
1819
// Check if Metadata flag is set
19-
if (FrameUtils.HasMetadataFlag(Flags))
20+
if (FlagUtils.HasMetadata(Flags))
2021
{
2122
// Write metadata with length prefix if we have metadata
2223
if (Metadata != null)

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/RSocketFrame.CancelFrame.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Viglucci.UnityRSocket.Util;
34

45
namespace Viglucci.UnityRSocket.Frame
56
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/RSocketFrame.KeepAliveFrame.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Viglucci.UnityRSocket.Util;
34

45
namespace Viglucci.UnityRSocket.Frame
56
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/RSocketFrame.RequestFnfFrame.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Viglucci.UnityRSocket.Util;
34

45
namespace Viglucci.UnityRSocket.Frame
56
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Frame/RSocketFrame.RequestResponseFrame.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Viglucci.UnityRSocket.Util;
34

45
namespace Viglucci.UnityRSocket.Frame
56
{

0 commit comments

Comments
 (0)