日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

signal自承载

發布時間:2025/6/15 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 signal自承载 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

?需要在nuget下載dll ? 命令

Install-Package Microsoft.AspNet.SignalR.SelfHost Install-Package Microsoft.Owin.Cors static void Main(string[] args) {string url = "http://localhost:8080";using (WebApp.Start(url)){Console.WriteLine("Server running on {0}", url);Console.ReadLine();} }

?

class Startup {public void Configuration(IAppBuilder app){app.UseCors(CorsOptions.AllowAll);app.MapSignalR();} }

Startup ? 名字不能變,Configuration也不能邊否則將會出現以下錯誤

System.EntryPointNotFoundException:“The following errors occurred while attempting to load
the app.
?- No assembly found containing an OwinStartupAttribute.
?- No assembly found containing a Startup or [AssemblyName].Startup class.”
?

簡單的服務端就這樣了

?

那么客戶端需要訪問訪問服務斷

Install-Package Microsoft.AspNet.SignalR.JS

下載之后將在項目中出現jquery.js, ?signal.js文件,所以在項目中需要引用這倆文件, ? 其中還需要引用一個自承載的hub服務文件

<script src="Scripts/jquery-1.6.4.min.js"></script>

<script src="Scripts/jquery.signalR-2.2.2.min.js"></script>

<script src="http://localhost:8080/signalr/hubs"></script>

http://localhost:8080/signalr/hubs一定是要把自承載服務打開才能訪問的到的,?

<script type="text/javascript">$(function () { //Set the hubs URL for the connection$.connection.hub.url = "http://localhost:8080/signalr"; var chat = $.connection.myHub; // Create a function that the hub can call to broadcast messages.chat.client.addMessage = function (name, message) {//返回的數據, 根據參數來接收};// Start the connection.$.connection.hub.start().done(function () { $('#sendmessage').click(function () { chat.server.send($('#displayname').val(), $('#message').val(),'11'); //推送數據到服務器});});});</script>

?

轉載于:https://my.oschina.net/objectboy/blog/1524646

總結

以上是生活随笔為你收集整理的signal自承载的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。