Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ namespace ChainSafe.Gaming.UnityPackage.Connection
{
public class EventsServiceAdapter : MonoBehaviour, ILightWeightServiceAdapter
{
[SerializeField, Tooltip("Enable this if a WebSocket connection is unavailable or if the blockchain does not provide a WebSocket URL")]
private bool forceEventPolling;

[SerializeField, Tooltip("How often to poll/make requests to Rpc node in seconds in WebGL")]
private float pollingInterval = 10f;


public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
services.UseEvents(new PollingEventManagerConfig { PollInterval = TimeSpan.FromSeconds(pollingInterval) });
services.UseEvents(new PollingEventManagerConfig
{
PollInterval = TimeSpan.FromSeconds(pollingInterval),
ForceEventPolling = forceEventPolling
});
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public static class EventExtensionsUnity
public static IWeb3ServiceCollection UseEvents(this IWeb3ServiceCollection services, PollingEventManagerConfig eventPollerConfig = null)
{
#if !UNITY_WEBGL || UNITY_EDITOR
services.UseEventsWithWebSocket();

if (eventPollerConfig is { ForceEventPolling: true })
services.UseEventsWithPolling();
else
services.UseEventsWithWebSocket();
#else
if (eventPollerConfig == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1573338518}
m_HandleRect: {fileID: 1573338517}
m_Direction: 0
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down Expand Up @@ -1418,7 +1418,7 @@ PrefabInstance:
value: Web3Unity
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 8854369476742677865, guid: 6d183a51c0030794a8ff3fea5dbd6423, type: 3}
- {fileID: 0}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
Expand Down
2 changes: 1 addition & 1 deletion src/ChainSafe.Gaming/MultiCall/MultiCallConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public enum UnavailableBehaviourType
/// </summary>
public IReadOnlyDictionary<string, string> CustomNetworks { get; }

public UnavailableBehaviourType UnavailableBehaviour { get; set; } = UnavailableBehaviourType.Throw;
public UnavailableBehaviourType UnavailableBehaviour { get; set; } = UnavailableBehaviourType.DisableAndLog;
}
}
2 changes: 2 additions & 0 deletions src/ChainSafe.Gaming/RPC/Events/PollingEventManagerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ namespace ChainSafe.Gaming.RPC.Events
public class PollingEventManagerConfig
{
public TimeSpan PollInterval { get; set; } = TimeSpan.FromSeconds(10);

public bool ForceEventPolling { get; set; } = false;
}
}
2 changes: 1 addition & 1 deletion src/ChainSafe.Gaming/RPC/Events/WebSocketEventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async ValueTask WillStartAsync()
{
if (string.IsNullOrWhiteSpace(chainConfig.Ws))
{
throw new Web3Exception("No WebSocket URL was provided in config.");
throw new Web3Exception("No WebSocket URL was provided in config. Please toggle the ForceEventPolling to true in order to use event polling instead of WebSockets.");
}

webSocketClient = new StreamingWebSocketClient(chainConfig.Ws);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1573338518}
m_HandleRect: {fileID: 1573338517}
m_Direction: 0
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down Expand Up @@ -1418,7 +1418,7 @@ PrefabInstance:
value: Web3Unity
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 8854369476742677865, guid: 6d183a51c0030794a8ff3fea5dbd6423, type: 3}
- {fileID: 0}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
Expand Down
2 changes: 1 addition & 1 deletion src/UnitySampleProject/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"com.unity.collab-proxy": "2.4.4",
"com.unity.ide.rider": "3.0.31",
"com.unity.ide.rider": "3.0.34",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.vscode": "1.2.5",
"com.unity.nuget.newtonsoft-json": "3.2.1",
Expand Down
14 changes: 7 additions & 7 deletions src/UnitySampleProject/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.31",
"version": "3.0.34",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down Expand Up @@ -182,15 +182,15 @@
"source": "local",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.0.2",
"io.chainsafe.web3-unity": "3.0.1"
"io.chainsafe.web3-unity": "3.0.4"
}
},
"io.chainsafe.web3-unity.lootboxes": {
"version": "file:../../../Packages/io.chainsafe.web3-unity.lootboxes",
"depth": 0,
"source": "local",
"dependencies": {
"io.chainsafe.web3-unity": "3.0.1"
"io.chainsafe.web3-unity": "3.0.4"
}
},
"io.chainsafe.web3-unity.marketplace": {
Expand All @@ -199,15 +199,15 @@
"source": "local",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.0.2",
"io.chainsafe.web3-unity": "3.0.1"
"io.chainsafe.web3-unity": "3.0.4"
}
},
"io.chainsafe.web3-unity.mud": {
"version": "file:../../../Packages/io.chainsafe.web3-unity.mud",
"depth": 0,
"source": "local",
"dependencies": {
"io.chainsafe.web3-unity": "3.0.1"
"io.chainsafe.web3-unity": "3.0.4"
}
},
"io.chainsafe.web3-unity.ramp": {
Expand All @@ -216,7 +216,7 @@
"source": "local",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.0.2",
"io.chainsafe.web3-unity": "3.0.1"
"io.chainsafe.web3-unity": "3.0.4"
}
},
"io.chainsafe.web3-unity.web3auth": {
Expand All @@ -225,7 +225,7 @@
"source": "local",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.0.2",
"io.chainsafe.web3-unity": "3.0.1"
"io.chainsafe.web3-unity": "3.0.4"
}
},
"nuget.mono-cecil": {
Expand Down
Loading