Skip to content

Commit 228532c

Browse files
committed
refactor!: update namespace to drop Runtime
1 parent 6dc148f commit 228532c

File tree

64 files changed

+172
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+172
-158
lines changed

UnityRSocket/Assets/Viglucci/UnityRSocket/Example/ClientManager.cs

Lines changed: 91 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2,123 +2,126 @@
22
using System.Collections.Generic;
33
using System.Text;
44
using UnityEngine;
5-
using Viglucci.UnityRSocket.Runtime;
6-
using Viglucci.UnityRSocket.Runtime.Metadata;
7-
using Viglucci.UnityRSocket.Runtime.Scheduling;
5+
using Viglucci.UnityRSocket.Metadata;
6+
using Viglucci.UnityRSocket.Scheduling;
7+
using Viglucci.UnityRSocket.Transport;
88

9-
public class ClientManager : MonoBehaviour
9+
namespace Viglucci.UnityRSocket.Example
1010
{
11-
private static ClientManager _instance;
11+
public class ClientManager : MonoBehaviour
12+
{
13+
private static ClientManager _instance;
1214

13-
/**
15+
/**
1416
* How often to send KeepAlive frames.
1517
*/
16-
public int keepAliveInterval = 10_000;
18+
public int keepAliveInterval = 10_000;
1719

18-
/**
20+
/**
1921
* The max delay between a keep alive frame and a server ACK. Client will disconnect if server does not
2022
* respond to a KeepAlive frame within this time period.
2123
*/
22-
public int keepAliveTimeout = 60_000;
23-
24-
private IRSocket _rSocket;
25-
private IClientTransport _transport;
24+
public int keepAliveTimeout = 60_000;
2625

27-
private void Awake()
28-
{
29-
Debug.Log("Awake");
26+
private IRSocket _rSocket;
27+
private IClientTransport _transport;
3028

31-
if (_instance == null)
32-
{
33-
_instance = this;
34-
}
35-
else if (_instance != this)
29+
private void Awake()
3630
{
37-
Debug.LogWarning(
38-
$"Instance of {GetType().Name} already exists. Newly created instance will be destroyed.");
39-
Destroy(this);
31+
Debug.Log("Awake");
32+
33+
if (_instance == null)
34+
{
35+
_instance = this;
36+
}
37+
else if (_instance != this)
38+
{
39+
Debug.LogWarning(
40+
$"Instance of {GetType().Name} already exists. Newly created instance will be destroyed.");
41+
Destroy(this);
42+
}
4043
}
41-
}
4244

43-
private void Start()
44-
{
45-
Debug.Log("Start");
45+
private void Start()
46+
{
47+
Debug.Log("Start");
4648

47-
_transport = new TcpClientTransport("localhost", 9090);
49+
_transport = new TcpClientTransport("localhost", 9090);
4850

49-
SetupOptions setupOptions = new SetupOptions(
50-
keepAliveInterval,
51-
keepAliveTimeout,
52-
data: new List<byte>(),
53-
metadata: new List<byte>(),
54-
dataMimeType:
55-
Metadata.WellKnownMimeTypeToString(
51+
SetupOptions setupOptions = new SetupOptions(
52+
keepAliveInterval,
53+
keepAliveTimeout,
54+
data: new List<byte>(),
55+
metadata: new List<byte>(),
56+
dataMimeType:
57+
Metadata.Metadata.WellKnownMimeTypeToString(
5658
WellKnownMimeType.APPLICATION_JSON),
57-
metadataMimeType:
58-
Metadata.WellKnownMimeTypeToString(
59+
metadataMimeType:
60+
Metadata.Metadata.WellKnownMimeTypeToString(
5961
WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA)
60-
);
62+
);
6163

62-
RSocketConnector connector = new RSocketConnector(
63-
_transport,
64-
setupOptions,
65-
new MonoBehaviorScheduler());
64+
RSocketConnector connector = new RSocketConnector(
65+
_transport,
66+
setupOptions,
67+
new MonoBehaviorScheduler());
6668

67-
IRSocket rSocket = connector.Bind();
69+
IRSocket rSocket = connector.Bind();
6870

69-
try
70-
{
71-
Debug.Log("Binding connector");
72-
_rSocket = connector.Bind();
71+
try
72+
{
73+
Debug.Log("Binding connector");
74+
_rSocket = connector.Bind();
75+
}
76+
catch (Exception e)
77+
{
78+
Debug.LogError(e);
79+
return;
80+
}
81+
82+
OnRSocketConnected();
7383
}
74-
catch (Exception e)
84+
85+
private void Update()
7586
{
76-
Debug.LogError(e);
77-
return;
87+
_transport.ProcessMessages();
7888
}
7989

80-
OnRSocketConnected();
81-
}
82-
83-
private void Update()
84-
{
85-
_transport.ProcessMessages();
86-
}
87-
88-
private void OnRSocketConnected()
89-
{
90-
_rSocket.OnClose((ex) =>
90+
private void OnRSocketConnected()
9191
{
92-
Debug.Log("RSocket connection closed.");
93-
if (ex != null)
94-
Debug.LogError(ex);
95-
});
92+
_rSocket.OnClose((ex) =>
93+
{
94+
Debug.Log("RSocket connection closed.");
95+
if (ex != null)
96+
Debug.LogError(ex);
97+
});
9698

97-
List<byte> data = new List<byte>(Encoding.UTF8.GetBytes("{ \"key\": \"value\"}"));
98-
List<byte> metadata = new List<byte>();
99+
List<byte> data = new List<byte>(Encoding.UTF8.GetBytes("{ \"key\": \"value\"}"));
100+
List<byte> metadata = new List<byte>();
99101

100-
ICancellable cancellable = _rSocket.RequestResponse(new RSocketPayload
101-
{
102-
Data = data,
103-
Metadata = metadata
104-
},
105-
new Subscriber(
106-
(payload, isComplete) =>
102+
ICancellable cancellable = _rSocket.RequestResponse(new RSocketPayload
107103
{
108-
string decodedData = Encoding.UTF8.GetString(payload.Data.ToArray());
109-
string decodedMetadata = Encoding.UTF8.GetString(payload.Metadata.ToArray());
110-
111-
Debug.Log($"data: {decodedData}");
112-
Debug.Log($"metadata: {decodedMetadata}");
113-
Debug.Log($"isComplete: {isComplete}");
114-
115-
if (isComplete)
116-
{
117-
Debug.Log("RequestResponse done");
118-
}
104+
Data = data,
105+
Metadata = metadata
119106
},
120-
() => Debug.Log("RequestResponse done"),
121-
Debug.LogError
122-
));
107+
new Subscriber(
108+
(payload, isComplete) =>
109+
{
110+
string decodedData = Encoding.UTF8.GetString(payload.Data.ToArray());
111+
string decodedMetadata = Encoding.UTF8.GetString(payload.Metadata.ToArray());
112+
113+
Debug.Log($"data: {decodedData}");
114+
Debug.Log($"metadata: {decodedMetadata}");
115+
Debug.Log($"isComplete: {isComplete}");
116+
117+
if (isComplete)
118+
{
119+
Debug.Log("RequestResponse done");
120+
}
121+
},
122+
() => Debug.Log("RequestResponse done"),
123+
Debug.LogError
124+
));
125+
}
123126
}
124127
}

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/BufferUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace Viglucci.UnityRSocket.Runtime
4+
namespace Viglucci.UnityRSocket
55
{
66
public static class BufferUtils
77
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/CancellableRequestableWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Viglucci.UnityRSocket.Runtime
1+
namespace Viglucci.UnityRSocket
22
{
33
public class CancellableRequestableWrapper : ICancellableRequestable
44
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/CancellableWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Viglucci.UnityRSocket.Runtime
1+
namespace Viglucci.UnityRSocket
22
{
33
public class CancellableWrapper : ICancellable
44
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using UnityEngine;
5-
using Viglucci.UnityRSocket.Runtime.Frame;
5+
using Viglucci.UnityRSocket.Frame;
66

7-
namespace Viglucci.UnityRSocket.Runtime
7+
namespace Viglucci.UnityRSocket
88
{
99
public abstract class ClientServerInputMultiplexerDemultiplexer : Deferred, IMultiplexer, IStream
1010
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/DefaultConnectionFrameHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2-
using Viglucci.UnityRSocket.Runtime.Frame;
3-
using Viglucci.UnityRSocket.Runtime.KeepAlive;
2+
using Viglucci.UnityRSocket.Frame;
3+
using Viglucci.UnityRSocket.KeepAlive;
44

5-
namespace Viglucci.UnityRSocket.Runtime
5+
namespace Viglucci.UnityRSocket
66
{
77
public class DefaultConnectionFrameHandler : IConnectionFrameHandler
88
{

UnityRSocket/Assets/Viglucci/UnityRSocket/Runtime/Deferred.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44

5-
namespace Viglucci.UnityRSocket.Runtime
5+
namespace Viglucci.UnityRSocket
66
{
77
public class Deferred : ICloseable
88
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Viglucci.UnityRSocket.Runtime
1+
namespace Viglucci.UnityRSocket
22
{
33
public class EpochUtils
44
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Viglucci.UnityRSocket.Runtime.Frame
1+
namespace Viglucci.UnityRSocket.Frame
22
{
33
public static partial class RSocketFrame
44
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text;
44

5-
namespace Viglucci.UnityRSocket.Runtime.Frame
5+
namespace Viglucci.UnityRSocket.Frame
66
{
77
public static class FrameDeserializer
88
{

0 commit comments

Comments
 (0)