Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
psygames committed Aug 12, 2020
2 parents 6094909 + 5136209 commit 1a94544
Show file tree
Hide file tree
Showing 82 changed files with 5,141 additions and 1,492 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
```csharp
// 命名空间
using UnityWebSocket;
using UnityWebSocket.Synchronized;

// 创建实例
WebSocket scoket = new WebSocket();
Expand All @@ -46,15 +45,15 @@
socket.CloseAsync();
```

- 详细使用方法可参考项目中的 [Example](UnityWebSocket/Assets/Scripts/Plugins/UnityWebSocket/Example/TestWebSocket.cs) 示例代码。
- 详细使用方法可参考项目中的 [Example.cs](UnityWebSocket/Assets/UnityWebSocket/Example/Example.cs) 示例代码。

#### 3. 注意(Warning)

- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境。

命名空间 | 平台 | 方式 | 说明
-|-|-|-
UnityWebSocket.Synchronized | 全平台 | 同步(无阻塞) | **[推荐]** 无需考虑异步回调使用 Unity 组件的问题。
UnityWebSocket | 全平台 | 同步(无阻塞) | **[推荐]** 无需考虑异步回调使用 Unity 组件的问题。
UnityWebSocket.Uniform | 全平台 | 异步 | 需要考虑异步回调使用 Unity 组件的问题。
UnityWebSocket.WebGL | WebGL平台 | 异步 | 仅支持WebGL平台下的通信。
UnityWebSocket.NoWebGL |WebGL平台 | 异步 | 仅支持非WebGL平台下的通信。
Expand All @@ -63,14 +62,9 @@

- WebSocket.jslib 语法格式需要遵循 [asm.js](http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html)。
路径:Plugins/WebSocketJS/WebSocketJS.jslib
路径:Plugins/WebGL/WebSocket.jslib
作用:Unity发布WebGL版本会将其加入到js运行库中。

- WebSocketReceiver.cs

作用:与 jslib 交互,负责收发多个WebSocket消息。
该脚本在使用WebSocket时会自动加载到场景中,并添加到DonDestroyOnLoad

- Example 场景

作用:WebSocket的使用方法示例。
Expand Down
13 changes: 4 additions & 9 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
```csharp
// the namespace
using UnityWebSocket;
using UnityWebSocket.Synchronized;

// create instance
WebSocket scoket = new WebSocket();
Expand All @@ -46,15 +45,15 @@
socket.CloseAsync();
```

- more detail usage, see the [Example](UnityWebSocket/Assets/Scripts/Plugins/UnityWebSocket/Example/TestWebSocket.cs) code in project
- more detail usage, see the [Example.cs](UnityWebSocket/Assets/UnityWebSocket/Example/Example.cs) code in project

#### 3. Attention(Warning)

- there are many **WebSocket** class in different namespace, use in different situations.

namespace | platform | sync style | description
-|-|-|-
UnityWebSocket.Synchronized | all | synchronized(no block) | **[recommend]** no need consider the problem by using unity component in asynchronized callback.
UnityWebSocket | all | synchronized(no block) | **[recommend]** no need consider the problem by using unity component in asynchronized callback.
UnityWebSocket.Uniform | all | asynchronized | consider the problem by using unity component in asynchronized callback.
UnityWebSocket.WebGL | WebGL only | asynchronized | only run in WebGL platform.
UnityWebSocket.NoWebGL | WebGL except | asynchronized | only run in not WebGL platforms.
Expand All @@ -63,16 +62,12 @@

- WebSocket.jslib, syntax follow to [asm.js](http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html)。
Path: Plugins/WebSocketJS/WebSocketJS.jslib
Path: Plugins/WebGL/WebSocket.jslib
Fucntion:Unity will deploy it to web js runtime on WebGL platform.

- WebSocketReceiver.cs

Function: interact with jslib. this script set as DonDestroyOnLoad.

- Example Scene

Function: show how to use UnityWebSocket.
Function: Example how to use UnityWebSocket.

#### 5. WebSocket Server

Expand Down
308 changes: 308 additions & 0 deletions UnityWebSocket/Assembly-CSharp-firstpass.csproj

Large diffs are not rendered by default.

26 changes: 11 additions & 15 deletions UnityWebSocket/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\CloseEventArgs.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\CloseStatusCode.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\ErrorEventArgs.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\IWebSocket.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\MessageEventArgs.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\Opcode.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\OpenEventArgs.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Core\WebSocketState.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Example\TestWebSocket.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\NoWebGL\WebSocket.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\Synchronized\UnityWebSocketDebuger.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\Synchronized\UnityWebSocketManager.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\Synchronized\WebSocket.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\Uniform\WebSocket.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\WebGL\WebSocket.cs" />
<Compile Include="Assets\Scripts\Plugins\UnityWebSocket\Implementation\WebGL\WebSocketReceiver.cs" />
<None Include="Assets\Scripts\Plugins\UnityWebSocket\Example\UnityWebSocket.Example.asmdef" />
<Reference Include="Unity.PackageManagerUI.Editor">
<HintPath>/Users/yinlong/Documents/github/UnityWebSocket/UnityWebSocket/Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -629,6 +615,16 @@
<HintPath>/Applications/Unity/2018.4.21f1/Unity.app/Contents/NetStandard/compat/2.0.0/shims/netfx/mscorlib.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="UnityWebSocket.Runtime.csproj">
<Project>{1600FD27-F8F3-E01A-5597-A3E922150CA4}</Project>
<Name>UnityWebSocket.Runtime</Name>
</ProjectReference>
<ProjectReference Include="UnityWebSocket.Editor.csproj">
<Project>{A5A4144C-6723-BE5C-957D-698FD90C4513}</Project>
<Name>UnityWebSocket.Editor</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="GenerateTargetFrameworkMonikerAttribute" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
167 changes: 0 additions & 167 deletions UnityWebSocket/Assets/Plugins/WebSocketJS/WebSocketJS.jslib

This file was deleted.

94 changes: 0 additions & 94 deletions UnityWebSocket/Assets/Plugins/WebSocketJS/WebSocketJS.jslib.meta

This file was deleted.

Loading

0 comments on commit 1a94544

Please sign in to comment.