资源简介
winform与MVC开发的SignalR相互发送信息 今天刚更新。跟昨天的只能winform发送
代码片段和文件信息
using Microsoft.AspNet.SignalR.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SignaIRClient
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private String UserName { get; set; }
private IHubProxy HubProxy { get; set; }
const string ServerURI = “http://localhost:61704“;
private HubConnection Connection { get; set; }
private void Form1_Load(object sender EventArgs e)
{
}
private void button1_Click(object sender EventArgs e)
{
HubProxy.Invoke(“sendWinform“ TextBoxMessage.Text);
TextBoxMessage.Text = String.Empty;
TextBoxMessage.Focus();
}
private async void ConnectAsync()
{
Connection = new HubConnection(ServerURI);
Connection.Closed += Connection_Closed;
HubProxy = Connection.CreateHubProxy(“ServerHub“);
HubProxy.On(“sendPrivateMessage“ (name message) =>
this.Invoke((Action)(() =>
RichTextBoxConsole.AppendText(String.Format(“{0}: {1}“ + Environment.NewLine name message))
))
);
try
{
await Connection.Start();
}
catch (HttpRequestException)
{
StatusText.Text = “Unable to connect to server: Start server before connecting clients.“;
//No connection: Don‘t enable Send button or show chat UI
return;
}
TextBoxMessage.Focus();
RichTextBoxConsole.AppendText(“Connected to server at “ + ServerURI + Environment.NewLine);
}
///
/// If the server is stopped the connection will time out after 30 seconds (default) and the
/// Closed event will fire.
///
private void Connection_Closed()
{
this.Invoke((Action)(() => StatusText.Text = “需要重新打开“));
}
///
/// 登录
///
///
///
private void button2_Click(object sender EventArgs e)
{
UserName = “test“;
//Connect to server (use async method to avoid blocking UI thread)
if (!String.IsNullOrEmpty(UserName))
{
StatusText.Visible = true;
StatusText.Text = “正在连接...“;
ConnectAsync();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-25 16:49 SignaIRCode\
目录 0 2018-12-25 16:39 SignaIRCode\.vs\
目录 0 2018-12-25 16:39 SignaIRCode\.vs\config\
文件 85795 2018-12-25 16:39 SignaIRCode\.vs\config\applicationhost.config
目录 0 2018-12-25 16:36 SignaIRCode\.vs\SignaIRCode\
目录 0 2018-12-25 16:36 SignaIRCode\.vs\SignaIRCode\v15\
文件 93184 2018-12-26 18:06 SignaIRCode\.vs\SignaIRCode\v15\.suo
目录 0 2018-12-25 16:36 SignaIRCode\.vs\SignaIRCode\v15\Server\
目录 0 2018-12-25 16:36 SignaIRCode\.vs\SignaIRCode\v15\Server\sqlite3\
文件 0 2018-12-25 16:36 SignaIRCode\.vs\SignaIRCode\v15\Server\sqlite3\db.lock
文件 1449984 2018-12-25 17:58 SignaIRCode\.vs\SignaIRCode\v15\Server\sqlite3\storage.ide
文件 32768 2018-12-26 08:39 SignaIRCode\.vs\SignaIRCode\v15\Server\sqlite3\storage.ide-shm
文件 4140632 2018-12-26 18:05 SignaIRCode\.vs\SignaIRCode\v15\Server\sqlite3\storage.ide-wal
目录 0 2018-12-25 17:26 SignaIRCode\packages\
目录 0 2018-12-25 16:39 SignaIRCode\packages\Antlr.3.5.0.2\
文件 146648 2018-12-25 16:39 SignaIRCode\packages\Antlr.3.5.0.2\Antlr.3.5.0.2.nupkg
目录 0 2018-12-25 16:39 SignaIRCode\packages\Antlr.3.5.0.2\lib\
文件 103424 2013-09-10 16:29 SignaIRCode\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll
文件 435712 2013-09-10 16:29 SignaIRCode\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.pdb
目录 0 2018-12-25 16:39 SignaIRCode\packages\bootstrap.3.3.7\
文件 374152 2018-12-25 16:39 SignaIRCode\packages\bootstrap.3.3.7\bootstrap.3.3.7.nupkg
目录 0 2018-12-25 16:39 SignaIRCode\packages\bootstrap.3.3.7\content\
目录 0 2018-12-25 16:39 SignaIRCode\packages\bootstrap.3.3.7\content\Content\
文件 26132 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap-theme.css
文件 47706 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap-theme.css.map
文件 23409 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap-theme.min.css
文件 25648 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap-theme.min.css.map
文件 146010 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap.css
文件 389287 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap.css.map
文件 121200 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap.min.css
文件 542194 2016-07-25 16:42 SignaIRCode\packages\bootstrap.3.3.7\content\Content\bootstrap.min.css.map
............此处省略1384个文件信息
- 上一篇:fastreprot控件原码
- 下一篇:C# 实现完整功能的截图控件
相关资源
- MVC model层代码生成器 C#
- C#代码生成器(生成MVC三层代码)
- MvCodeReaderSDKNet海康相机SDK二次开发,
- C# MVC根据Word模板导出Word
- SignalR在线聊天(websocket)
- 基于easy-mvc的后台管理系统源码 v1.1
- C#网站项目使用SignalR技术实现实时聊
- MVC图片上传实例58438
- SignalR 2.0 Winform版
- ASP.net MVC vcard名片二维码自动生成
- ASP.NET MVC5+EasyUI企业开发框架源码
- 精通ASP.NET MVC 5 随书源码
- C# mvc 订单系统(数据库+源码)
- asp.net MVC5+EasyUI事例
- MVC网上书店(ASP.NET 4.0)
- ASP.NET MVC5 入门PPT
- 基于MVC的简单验证码验证不区分大小
- MVC+ASP.NET 博客系统
- 2018年最新版c# mvc5 源代码
- asp.net mvc4 +sqlite
- Asp.net Mvc开源论坛mvcforum中版源码
- 新闻发布系统包括用户界面部分和后
- ASP.NET MVC 5入门指南(中文PDF+源码)
- ASP.NET MVC入门教程
- C#三层架构的MVC项目源码
- 实验室设备管理系统 asp.net MVC
- PureMVC for Unity3d Demo
- 基于MVC架构的学生信息管理系统的设
- 网上书店用mvc实现
- HW内部使用 asp.net mvc框架 OA系统 模
评论
共有 条评论