如何解决在Unity中使用AspNetCore.SignalR.Client
我想统一使用SignalR,我在解决方案中添加了Microsoft.AspNetCore.SignalR.Client
nuget
软件包。但统一出现以下错误:
error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft'
解决方法
要在SignalR
中使用unity
,可以使用bestHttp
unity package,我用过它,它工作正常
软件包链接:link或在bestHttp
中搜索UnityAssetStore
首先需要创建连接:
using BestHTTP.SignalR;
Uri uri = new Uri("http://besthttpsignalr.azurewebsites.net/raw-connection/");
创建连接后,可以通过在服务器上调用Open()
函数来开始连接到服务器:
signalRConnection.Open();
处理一般事件:
已连接
signalRConnection.OnConnected += (con) => Debug.Log("Connected to the SignalR server!");
已关闭
signalRConnection.OnClosed += (con) => Debug.Log("Connection Closed");
OnError
signalRConnection.OnError += (conn,err) => Debug.Log("Error: " + err);
更多信息,您可以阅读文档This link
希望有帮助:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。