-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allowing multiple instances of javascript client (#14)
* refactoring js client to allow for multiple instances * tests for opening multiple instances of the client
- Loading branch information
1 parent
0154303
commit cc6e513
Showing
8 changed files
with
160 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
using System; | ||
#if UNITY_WEBGL | ||
using System.Runtime.InteropServices; | ||
#endif | ||
|
||
namespace Mirror.SimpleWeb | ||
{ | ||
internal static class SimpleWebJSLib | ||
{ | ||
#if UNITY_WEBGL | ||
[DllImport("__Internal")] | ||
internal static extern bool IsConnected(); | ||
internal static extern bool IsConnected(int index); | ||
|
||
#pragma warning disable CA2101 // Specify marshaling for P/Invoke string arguments | ||
[DllImport("__Internal")] | ||
#pragma warning restore CA2101 // Specify marshaling for P/Invoke string arguments | ||
internal static extern void Connect(string address, Action openCallback, Action closeCallBack, Action<IntPtr, int> messageCallback, Action errorCallback); | ||
internal static extern int Connect(string address, Action<int> openCallback, Action<int> closeCallBack, Action<int, IntPtr, int> messageCallback, Action<int> errorCallback); | ||
|
||
[DllImport("__Internal")] | ||
internal static extern void Disconnect(); | ||
internal static extern void Disconnect(int index); | ||
|
||
[DllImport("__Internal")] | ||
internal static extern bool Send(byte[] array, int offset, int length); | ||
internal static extern bool Send(int index, byte[] array, int offset, int length); | ||
#else | ||
internal static bool IsConnected() => throw new NotSupportedException(); | ||
internal static bool IsConnected(int index) => throw new NotSupportedException(); | ||
|
||
internal static void Connect(string address, Action openCallback, Action closeCallBack, Action<IntPtr, int> messageCallback, Action errorCallback) => throw new NotSupportedException(); | ||
internal static int Connect(string address, Action<int> openCallback, Action<int> closeCallBack, Action<int, IntPtr, int> messageCallback, Action<int> errorCallback) => throw new NotSupportedException(); | ||
|
||
internal static void Disconnect() => throw new NotSupportedException(); | ||
internal static void Disconnect(int index) => throw new NotSupportedException(); | ||
|
||
internal static bool Send(byte[] array, int offset, int length) => throw new NotSupportedException(); | ||
internal static bool Send(int index, byte[] array, int offset, int length) => throw new NotSupportedException(); | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.