Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlong committed Jun 2, 2021
1 parent abfb970 commit 9cb67eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 46 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<img src="https://s1.ax1x.com/2020/08/21/dYIAQU.png" width=20%/>
</div>

[![openupm](https://img.shields.io/npm/v/com.psygame.unitywebsocket?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.psygame.unitywebsocket/)

## **在线示例**

- **[https://psygames.github.io/UnityWebSocket/](https://psygames.github.io/UnityWebSocket/)**
Expand All @@ -16,14 +14,7 @@

### **安装方法**

- **通过 Package Manager 安装**

***待添加***


- **通过 Unity Package 安装**

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


### **使用方法**
Expand All @@ -50,14 +41,19 @@
// 发送 string 类型数据
socket.SendAsync(str);

// 或者 发送 byte[] 类型数据
// 或者 发送 byte[] 类型数据(建议使用)
socket.SendAsync(bytes);

// 关闭连接
socket.CloseAsync();
```

- 详细使用方法可参考项目中的 [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Samples~/Demo/UnityWebSocketDemo.cs) 示例代码。
- 更多使用方法可参考项目中的 [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs) 示例代码。

- 可添加 Unity 编译宏:
- `UNITY_WEB_SOCKET_LOG` 打开底层日志输出。
- `UNITY_WEB_SOCKET_SHARP` 使用 [websocket-sharp](https://github.com/sta/websocket-sharp) 插件。
- `UNITY_WEB_SOCKET_NINJA` 使用 [Ninja.WebSockets](https://github.com/ninjasource/Ninja.WebSockets) 插件。

### **注意(Warning)**
Expand Down
45 changes: 11 additions & 34 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,16 @@
<img src="https://s1.ax1x.com/2020/08/21/dYIAQU.png" width=20%/>
</div>

[![openupm](https://img.shields.io/npm/v/com.psygame.unitywebsocket?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.psygame.unitywebsocket/)

## **Online Demo**

- **[https://psygames.github.io/UnityWebSocket/](https://psygames.github.io/UnityWebSocket/)**


## **Quick Start**

### **Requirements**

- Unity 2018.3 or later
- No other SDK are required

### **Installation**

- **Using OpenUPM**

This package is available on [OpenUPM](https://openupm.com/packages/com.psygame.unitywebsocket/). You can install it via [openupm package installer](https://package-installer.glitch.me/v1/installer/OpenUPM/com.psygame.unitywebsocket?registry=https%3A%2F%2Fpackage.openupm.com).

- **Using Git**

Find the manifest.json file in the Packages folder of your project and edit it to look like this:
```js
{
"dependencies": {
"com.psygame.unitywebsocket": "https://github.com/psygames/UnityWebSocket.git",
...
},
}
```

To update the package, change suffix `#{version}` to the target version.
* e.g. `"com.psygame.unitywebsocket": "https://github.com/psygames/UnityWebSocket.git#2.3.0",`

- **Using Unity Package**

Download an `UnityWebSocket.unitypackage` file from [Releases](https://github.com/psygames/UnityWebSocket/releases) page.
- Download an `UnityWebSocket.unitypackage` file from [Releases](https://github.com/psygames/UnityWebSocket/releases) page.
Import it into your Unity project.


Expand All @@ -67,16 +39,21 @@
// connect
socket.ConnectAsync();

// send data (two ways)
socket.SendAsync(str); // send string data
socket.SendAsync(bytes); // send byte[] data
// send string data
socket.SendAsync(str);
// or send byte[] data (suggested)
socket.SendAsync(bytes);

// close connection
socket.CloseAsync();
```

- more detail usage, see the [UnityWebSocketDemo.cs](Samples~/Demo/UnityWebSocketDemo.cs) code in project。

- more detail usage, see the [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs) code in project.

- Unity Define Symbols:
- `UNITY_WEB_SOCKET_LOG` open internal log info.
- `UNITY_WEB_SOCKET_SHARP` use third-party plugin [websocket-sharp](https://github.com/sta/websocket-sharp).
- `UNITY_WEB_SOCKET_NINJA` use third-party plugin [Ninja.WebSockets](https://github.com/ninjasource/Ninja.WebSockets)
### **Attention(Warning)**

Expand Down

3 comments on commit 9cb67eb

@favoyang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psygames so the project is no longer available as a UPM format?

@psygames
Copy link
Owner

@psygames psygames commented on 9cb67eb Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, UPM was removed, we suggest use source code.

@favoyang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the information.

Please sign in to comment.