Skip to content

Commit

Permalink
remove binarytype blob
Browse files Browse the repository at this point in the history
  • Loading branch information
psygames committed Aug 22, 2024
1 parent c537de5 commit 08887bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
12 changes: 4 additions & 8 deletions Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var WebSocketLibrary =
* {
* url: string,
* ws: WebSocket,
* binaryType: string,
* subProtocols: string[],
* }
*/
Expand Down Expand Up @@ -80,15 +79,13 @@ var WebSocketLibrary =
*
* @param url Server URL
*/
WebSocketAllocate: function(urlPtr, binaryTypePtr)
WebSocketAllocate: function(urlPtr)
{
var url = UTF8ToString(urlPtr);
var binaryType = UTF8ToString(binaryTypePtr);
var id = ++webSocketManager.lastId;
webSocketManager.instances[id] = {
url: url,
ws: null,
binaryType: binaryType
};

return id;
Expand Down Expand Up @@ -154,8 +151,6 @@ var WebSocketLibrary =
else
instance.ws = new WebSocket(instance.url);

instance.ws.binaryType = instance.binaryType;

instance.ws.onopen = function()
{
Module.dynCall_vi(webSocketManager.onOpen, instanceId);
Expand Down Expand Up @@ -253,7 +248,7 @@ var WebSocketLibrary =
{
instance.ws.close(code, reason);
}
catch(err)
catch (err)
{
return -7;
}
Expand All @@ -275,7 +270,8 @@ var WebSocketLibrary =
if (instance.ws === null) return -3;
if (instance.ws.readyState !== 1) return -6;

instance.ws.send(buffer.slice(bufferPtr, bufferPtr + length));
var bufferBlock = buffer.slice(bufferPtr, bufferPtr + length)
instance.ws.send(bufferBlock);

return 0;
},
Expand Down
15 changes: 1 addition & 14 deletions Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace UnityWebSocket
{
Expand Down Expand Up @@ -120,19 +120,6 @@ public interface IWebSocket
/// </value>
WebSocketState ReadyState { get; }

/// <summary>
/// Gets the current binaryType of the connection, supported on WEBGL platform only.
/// </summary>
/// <value>
/// <para>
/// It indicates the current binaryType of the connection.
/// </para>
/// <para>
/// The default value is "arraybuffer", options: "blob" or "arraybuffer".
/// </para>
/// </value>
string BinaryType { get; set; }

/// <summary>
/// Occurs when the WebSocket connection has been established.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NET_LEGACY && (UNITY_EDITOR || !UNITY_WEBGL)
#if !NET_LEGACY && (UNITY_EDITOR || !UNITY_WEBGL)
using System;
using System.Collections.Generic;
using System.Text;
Expand Down Expand Up @@ -37,8 +37,6 @@ public WebSocketState ReadyState
}
}

public string BinaryType { get; set; } = "arraybuffer";

public event EventHandler<OpenEventArgs> OnOpen;
public event EventHandler<CloseEventArgs> OnClose;
public event EventHandler<ErrorEventArgs> OnError;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !UNITY_EDITOR && UNITY_WEBGL
#if !UNITY_EDITOR && UNITY_WEBGL
using System;

namespace UnityWebSocket
Expand All @@ -8,7 +8,6 @@ public class WebSocket : IWebSocket
public string Address { get; private set; }
public string[] SubProtocols { get; private set; }
public WebSocketState ReadyState { get { return (WebSocketState)WebSocketManager.WebSocketGetState(instanceId); } }
public string BinaryType { get; set; } = "arraybuffer";

public event EventHandler<OpenEventArgs> OnOpen;
public event EventHandler<CloseEventArgs> OnClose;
Expand Down Expand Up @@ -39,7 +38,7 @@ public WebSocket(string address, string[] subProtocols)

internal void AllocateInstance()
{
instanceId = WebSocketManager.AllocateInstance(this.Address, this.BinaryType);
instanceId = WebSocketManager.AllocateInstance(this.Address);
Log($"Allocate socket with instanceId: {instanceId}");
if (this.SubProtocols == null) return;
foreach (var protocol in this.SubProtocols)
Expand Down

0 comments on commit 08887bd

Please sign in to comment.