psygames / unitywebsocket Goto Github PK
View Code? Open in Web Editor NEW:whale: The Best Unity WebSocket Plugin for All Platforms.
License: MIT License
:whale: The Best Unity WebSocket Plugin for All Platforms.
License: MIT License
Hi! How can I implement reconnection?
I will notice that there is a timeout in the WebSocketManager
"bool clearCheck = Time.realtimeSinceStartup - clearCheckTimeStamp> = 60;"
which deletes the socket
And after 1 minute offline I don't get OnClose message
Release版本里面的UnityWebSocket.unitypackage 居然没有包涵WebSocketJS.jslib...
错误日志如下:
failed to asynchronously prepare wasm: LinkError: WebAssembly.instantiate(): memory import 0 is smaller than initial 512, got 256
printErr @ UnityLoader.js:4
UnityLoader.js:4 LinkError: WebAssembly.instantiate(): memory import 0 is smaller than initial 512, got 256
UnityLoader.js:4 LinkError: WebAssembly.instantiate(): memory import 0 is smaller than initial 512, got 256
printErr @ UnityLoader.js:4
(index):1 Uncaught (in promise) abort({}) at Error
at jsStackTrace (blob:http://localhost:54116/7b9ed2df-807b-49e4-a462-2f99819e16e2:8:22313)
at Object.stackTrace (blob:http://localhost:54116/7b9ed2df-807b-49e4-a462-2f99819e16e2:8:22484)
at Object.onAbort (http://localhost:54116/Build/UnityLoader.js:4:11118)
at abort (blob:http://localhost:54116/7b9ed2df-807b-49e4-a462-2f99819e16e2:8:512213)
at blob:http://localhost:54116/7b9ed2df-807b-49e4-a462-2f99819e16e2:8:31378
另外 Unity2019没有Publishing Settings -> Linker Target
这里的判断条件应该是 if(b < 16)
而不是 if(b < 10)
。
我在进行protobuf解析的时候,发现服务器发回来的数据客户端解析总是失败,然后发现是这里的问题,修复之后就好了。
如题,使用环境是2017.1.3。平台:WebGL
使用2.4.5的版本,可以連上ws但是要用wss時會無法連上
請問要如何設定SslConfiguration讓其連上wss呢?
謝謝
Hi there,
Just curious why the package.json file has been removed since tag 2.5.0?
Favo from OpenUPM
使用的Unity版本:2020.3.10f1c1。
打包平台:iOS 和 Android 使用 IL2CPP 都报错
详细报错信息:
Exception: IL2CPP error (no further information about what managed code was being converted is available)
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
解决办法:Api Level 默认为:.Net Standard 2.0。修改为.NET 4.x可以打包成功。
hello,
when i running webgl on the node server. he can connect the server, but when i prepare to send or receive messages, the webgl console always show the info: "SendMessage: object WebSocket not found!"
I don't known why and I have bloc here for a long time. thank you for response.
多谢指教。
receive buffer size too small, also send buffer size ?
I'm using version 2.6.4 connect to my wss server it's said "Unable to connect to the remote server" and then when I switch my server to ws it work normally.
Hi,
It'll be helpful if this project can support setting custom headers. I'm using JWT authentication, and need to set header:
Authorization: Bearer <myToken>
for websocket-sharp, it supports HTTP Authentication (Basic/Digest)
by using ws.SetCredentials ("nobita", "password", preAuth);
, which will add header:
Authorization: Basic <realmToken>
Cloud you please add a function to set headers like:
ws= new WebSocket(address);
ws.SetHeader("Authorization", "Bearer " + myToken);
Thanks!
偶然发现这个库,很不错,准备使用一下呢
should change to
instance.ws.send(HEAPU8.slice(bufferPtr, bufferPtr + length));
打开报错如下:
Socket onError: An error has occurred during the OnOpen event.
UnityWebSocket.WebSocket:<WebSocket>m__2(Object, ErrorEventArgs) (at UnityWebSocket/WebSocket.cs:112)
WebSocketSharp.Ext:Emit(EventHandler`1, Object, ErrorEventArgs) (at UnityWebSocket/websocket-sharp/Ext.cs:1254)
WebSocketSharp.WebSocket:error(String, Exception) (at UnityWebSocket/websocket-sharp/WebSocket.cs:1421)
WebSocketSharp.WebSocket:open() (at UnityWebSocket/websocket-sharp/WebSocket.cs:1537)
WebSocketSharp.WebSocket:Connect() (at UnityWebSocket/websocket-sharp/WebSocket.cs:3241)
UnityWebSocket.WebSocket:Connect() (at UnityWebSocket/WebSocket.cs:123)
关闭报错如下:
Socket onError: An error has occurred during the OnClose event.
UnityWebSocket.WebSocket:<WebSocket>m__2(Object, ErrorEventArgs) (at UnityWebSocket/WebSocket.cs:112)
WebSocketSharp.Ext:Emit(EventHandler`1, Object, ErrorEventArgs) (at UnityWebSocket/websocket-sharp/Ext.cs:1254)
WebSocketSharp.WebSocket:error(String, Exception) (at UnityWebSocket/websocket-sharp/WebSocket.cs:1421)
WebSocketSharp.WebSocket:close(PayloadData, Boolean, Boolean, Boolean) (at UnityWebSocket/websocket-sharp/WebSocket.cs:1140)
WebSocketSharp.WebSocket:close(UInt16, String) (at UnityWebSocket/websocket-sharp/WebSocket.cs:1094)
WebSocketSharp.WebSocket:Close() (at UnityWebSocket/websocket-sharp/WebSocket.cs:2566)
UnityWebSocket.WebSocket:Close() (at UnityWebSocket/WebSocket.cs:143)
虽然第一次打开连接会报错,不过最后OnOpen走了两次,第二次能连接成功
private void OnOpen(object sender, EventArgs e)
{
Debug.Log("Socket Connected");
}
Please add support for Options just like in the .Net socket - e.g. add custom TImeOut/SubProtocol.
Just make another class inside Core folder - UniformSocketOptions.cs, let it be a simple class and copy paste fields from the .Net Socket Options.
Also don't forget to add SetOptions(UniformSocketOptions) under the IWebSocket interface
介绍说:需要在主线程中加消息处理队列(需要加锁),缓存网络消息后,再在主线程中处理消息包。
请教具体实现方式? 或者demo
非常感谢
如标题,请教作者有没这个问题
服务器提供了1个xxx.cert文件,一个xxx.key结尾的文件
客户端这块该如何配置呢? 谢谢
大致看了下代码,WebSocket.cs中定义的只接受byte[]格式
public Action<byte[]> onReceive { get; set; }
调用的是MessageEventArgs.cs文件中的代码
public byte[] RawData { get { setData (); return _rawData; } }
如果服务器给client都以string的形式发送json数据,请教该怎么接收数据呢?(同理: client也会直接发送string给服务器端)
谢谢大神们!
错误提示如下:
Undefined symbols for architecture armv7: "_SendStrJS", referenced from: _WebSocket_SendStrJS_m828571625 in Bulk_Assembly-CSharp_2.o (maybe you meant: _WebSocket_SendStrJS_m828571625) "_SendJS", referenced from: _WebSocket_SendJS_m2279827315 in Bulk_Assembly-CSharp_2.o (maybe you meant: _WebSocket_SendJS_m2279827315) "_ConnectJS", referenced from: _WebSocket_ConnectJS_m1770216249 in Bulk_Assembly-CSharp_2.o (maybe you meant: _WebSocket_ConnectJS_m1770216249) "_GetReadyStateJS", referenced from: _WebSocket_GetReadyStateJS_m3781595125 in Bulk_Assembly-CSharp_2.o (maybe you meant: _WebSocket_GetReadyStateJS_m3781595125) "_CloseJS", referenced from: _WebSocket_CloseJS_m3737965298 in Bulk_Assembly-CSharp_2.o (maybe you meant: _WebSocket_CloseJS_m3737965298) "__copyTextToClipboard", referenced from: _InviteCodeManager__copyTextToClipboard_m3335060872 in Bulk_Assembly-CSharp_1.o (maybe you meant: _InviteCodeManager__copyTextToClipboard_m3335060872) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
我们只需要Android, IOS 如果不需要打包WebGL平台,websocket-jslib目录下的两个文件可以删除吗? 貌似是这里的错误
谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.