Skip to content

Commit

Permalink
fix(webgl): use NativeWebSocketClient in editor
Browse files Browse the repository at this point in the history
The `WebSocketClientFactory` was using the wrong preprocessor
directives, and using the Javascript library version of the
`IWebSocketClient`, which isn't supported in the editor. This sets the
correct `IWebSocketClient` when having a WebGL build target in the
editor.

fix #170
  • Loading branch information
jasonboukheir committed Dec 10, 2022
1 parent 9e3c9a1 commit 5188e5f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_WEBGL
#if UNITY_WEBGL && !UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Algorand.Unity.WebSocket
{
public class WebSocketClientFactory
{
#if UNITY_WEBGL
#if UNITY_WEBGL && !UNITY_EDITOR
public static JSWebSocketClient Client = new JSWebSocketClient();

internal delegate void OnOpenCallback();
Expand Down Expand Up @@ -67,7 +67,7 @@ internal static void OnCloseEvent(int disconnectCode)

public static IWebSocketClient Create(string url)
{
#if UNITY_WEBGL
#if UNITY_WEBGL && !UNITY_EDITOR
_SetUrl(url);
_SetOnOpen(OnOpenEvent);
_SetOnMessage(OnMessageEvent);
Expand Down
2 changes: 0 additions & 2 deletions Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Algorand.Unity.WebSocket
{
public class WebSocketEvent
Expand Down

0 comments on commit 5188e5f

Please sign in to comment.