日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

signal自承载

發布時間:2025/6/15 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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自承载的全部內容,希望文章能夠幫你解決所遇到的問題。

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