Skip to content

Commit

Permalink
fix not support buffer slice & new readme
Browse files Browse the repository at this point in the history
  • Loading branch information
psygames committed Aug 24, 2024
1 parent 1a25491 commit 12d7a9d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ var WebSocketLibrary =
instance.ws.send(HEAPU8.buffer.slice(bufferPtr, bufferPtr + length));
else if (typeof buffer !== 'undefined')
instance.ws.send(buffer.slice(bufferPtr, bufferPtr + length));
else
return -8; // not support buffer slice

return 0;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ internal static string GetErrorMessageFromCode(int errorCode)
case -4: return "WebSocket is already closing.";
case -5: return "WebSocket is already closed.";
case -6: return "WebSocket is not in open state.";
case -7: return "Cannot close WebSocket. An invalid code was specified or reason is too long.";
case -7: return "Cannot close WebSocket, An invalid code was specified or reason is too long.";
case -8: return "Not support buffer slice. ";
default: return $"Unknown error code {errorCode}.";
}
}
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@

## **快速开始**

### 安装环境

- Unity 2018.3 或更高版本。

### **安装方法**

-[Releases](https://github.com/psygames/UnityWebSocket/releases) 页面中,下载最新版本的 `UnityWebSocket.unitypackage` 安装包,然后导入到您的项目中。
- **方式一(推荐):通过 Package Manager 安装**

在 Unity 菜单栏中打开 `Window/Package Manager`,点击左上角 `+` 号,选择 `Add package from git URL...` ,输入 `https://github.com/psygames/UnityWebSocket.git#upm` 并确认。

- **方式二:通过 Unity Package 安装**

[Releases](https://github.com/psygames/UnityWebSocket/releases) 页面中,下载最新版本的 `UnityWebSocket.unitypackage` 安装包,然后手动导入到您的项目中。

### **使用方法**

Expand Down Expand Up @@ -55,7 +64,6 @@

- Unity 编译宏(可选项):
- `UNITY_WEB_SOCKET_LOG` 打开底层日志输出。
- `UNITY_WEB_SOCKET_ENABLE_ASYNC` 针对非WebGL平台使用异步线程处理消息(需自行处理跨线程访问Unity组件问题)。


### **QQ 交流群**
Expand Down
16 changes: 11 additions & 5 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@

## **Quick Start**

### **Requirements**

- Unity 2018.3 or higher.

### **Installation**

- Download latest `UnityWebSocket.unitypackage` file from [Releases](https://github.com/psygames/UnityWebSocket/releases) page.
Import it into your Unity project.
- **[Recommended] Install via Unity Package Manager**

Open Window/Package Manager in the Unity menu bar, click the `+` icon at the top left, select `Add package from git URL...`, enter `https://github.com/psygames/UnityWebSocket.git#upm` and confirm.

- **Install via Unity Package Manager**

Download the latest version of `UnityWebSocket.unitypackage` from the [Releases](https://github.com/psygames/UnityWebSocket/releases) page, then import the package into your project.

### **Usage**

Expand Down Expand Up @@ -48,12 +56,10 @@
socket.CloseAsync();
```

- More detail usages, see the [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs) code in project.
- For more usage, refer to the [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs) example code in the project.

- Menus
- Tools -> UnityWebSocket, version update check, bug report, etc.

- Unity Define Symbols(Optional):
- `UNITY_WEB_SOCKET_LOG` Open internal log info.
- `UNITY_WEB_SOCKET_ENABLE_ASYNC` Use network thread handle message (not WebGL platform).

0 comments on commit 12d7a9d

Please sign in to comment.