找传奇、传世资源到传世资源站!
Windows 正文

SignalR 寄宿 windows服务 实例源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

installutil signalrwindowsservice.exe

using System.ServiceProcess;using Microsoft.AspNet.SignalR;using Microsoft.Owin.Hosting;using Owin;using Microsoft.Owin.Cors;using Microsoft.Owin;[assembly: OwinStartup(typeof(SignalRWindowsService.Startup))]namespace SignalRWindowsService{ public partial class SignalRChat : ServiceBase { public SignalRChat() { InitializeComponent(); } protected override void OnStart(string[] args) { if (!System.Diagnostics.EventLog.SourceExists("SignalRChat")) { System.Diagnostics.EventLog.CreateEventSource( "SignalRChat", "Application"); } eventLog1.Source = "SignalRChat"; eventLog1.Log = "Application"; eventLog1.WriteEntry("In OnStart"); string url = "http://localhost:8080"; WebApp.Start(url); } protected override void OnStop() { eventLog1.WriteEntry("In OnStop"); } } class Startup { public void Configuration(IAppBuilder app) { app.UseCors(CorsOptions.AllowAll); app.MapSignalR(); } } public class MyHub : Hub { public void Send(string name, string message) { Clients.All.addMessage(name, message); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复