<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title></title>
<script src="jquery-3.3.1.js"></script>
<script>
var ws;
$().ready(function () {
$('#conn').click(function () {
//ws = new WebSocket('ws://' + window.location.hostname + ':' + window.location.port + '/WSHandler.ashx?user=' + $("#user").val());
ws = new WebSocket('ws://' + window.location.host + '/WSHandler.ashx?user=' + $("#user").val());
$('#msg').append('<p>正在连接</p>');
ws.onopen = function () {
$('#msg').append('<p>已经连接</p>');
}
ws.onmessage = function (evt) {
$('#msg').append('<p>' + evt.data + '</p>');
}
ws.onerror = function (evt) {
$('#msg').append('<p>' + JSON.stringify(evt) + '</p>');
}
ws.onclose = function () {
$('#msg').append('<p>已经关闭</p>');
}
});
$('#close').click(function () {
ws.close();
});
$('#send').click(function () {
if (ws.readyState == WebSocket.OPEN) {
ws.send($("#to").val() + "|" + $('#content').val());
}
else {
$('#tips').text('连接已经关闭');
}
});
});
</script>
</head>
<body>
<div>
用 户:<input id="user" type="text" />
<input id="conn" type="button" value="连接" />
<input id="close" type="button" value="关闭" /><br />
<span id="tips"></span>
内 容:<input id="content" type="text" />
<input id="send" type="button" value="发送" /><br />
目的用户:<input id="to" type="text" />
<div id="msg">
</div>
</div>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
.NET 4.5 WebSocket简易聊天室、离线消息(MSMQ)
共24个文件
cs:8个
html:5个
ashx:5个
4星 · 超过85%的资源 需积分: 30 49 下载量 121 浏览量
2018-05-23
11:41:33
上传
评论 4
收藏 118KB ZIP 举报
温馨提示
.NET 4.5简化了WebSocket的处理,不用再单独用socket去解析RFC6455的协议。 Windows .NET平台上要使用WebSocket,.NET版本不低于4.5、IIS至少8、IIS要启用WebSocket。 本资源为练习代码,比较简单,适合初学者。
资源推荐
资源详情
资源评论
收起资源包目录
MSMQ_WebSocket.zip (24个子文件)
MSMQ_WebSocket
index5.html 2KB
WSHandler4.ashx 102B
index4.html 2KB
packages.config 367B
Web.config 1KB
MSMQ_WebSocket.csproj 8KB
Web.Debug.config 1KB
WSHandler4.ashx.cs 5KB
WSHandler2.ashx 102B
index.html 2KB
WSHandler3.ashx.cs 4KB
jquery-3.3.1.js 265KB
index2.html 2KB
Web.Release.config 1KB
WSHandler.ashx 100B
WSHandler2.ashx.cs 5KB
index3.html 2KB
MSMQ_SRV5.cs 2KB
MSMQ_SRV.cs 3KB
WSHandler5.ashx 102B
WSHandler3.ashx 102B
WSHandler.ashx.cs 7KB
WSHandler5.ashx.cs 3KB
Properties
AssemblyInfo.cs 1KB
共 24 条
- 1
资源评论
- 活在当下&2020-03-24没深入看,下下来研究学习
- 舊區东江源2019-01-11不能直接运行,报错。qq8746555512019-08-22有使用到消息队列,看你电脑有没有配MSMQ
qq874655551
- 粉丝: 55
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功