zoukankan      html  css  js  c++  java
  • NetCore.SignalR.Demo演示

    项目github,点击https://github.com/wangpengzong/NetCore.SignalR.Demo

    1.打开服务端Server(SignalR.ServerinDebug etcoreapp2.2win10-x64SignalR.Server.exe)

    2.打开客户端,开5个标签页,分别是

    两个http://localhost:63891/test/index     groupid:1,用户1,identifier = "00000000-0000-0000-0000-000000000000"

    一个http://localhost:63891/test/index1   groupid:1,用户2,identifier = "11111111-1111-1111-1111-111111111111"

    一个http://localhost:63891/test/index2   groupid:2,用户3,identifier = "33333333-3333-3333-3333-333333333333"

    一个http://localhost:63891/test/index3   groupid:3,用户4,identifier = "44444444-4444-4444-4444-444444444444"

     

    Javascript调用:

    test/index中的user框,输入00000000-0000-0000-0000-000000000000message输入hi,点击sendmessage,就可以在全部的标签页看到以上页面,此时调用的是

    document.getElementById("sendButton").addEventListener("click", event => {

                const user = document.getElementById("userInput").value;

                const message = document.getElementById("messageInput").value;

                connection.invoke("SendMessageToAll", { From: user, Content: message }).catch(err => console.error(err.toString()));

                event.preventDefault();

            });   

    .net 客户端调用

    再打开一个标签页,输入http://localhost:63891/test/SendMessageToAll

     

    这个和上面的say hi都是调用SendMessageToAll方法,发送给所有人

    将此标签页输入http://localhost:63891/test/SendMessageToUser,调用SendMessageToUser方法,此时前两个页面显示00000000-0000-0000-0000-000000000000 says SendMessageTo1,这个是发给用户1

     

    将此标签页输入http://localhost:63891/test/SendMessageToGroup1,调用SendMessageToMyGroup方法,此时前三个页面显示00000000-0000-0000-0000-000000000000 says SendMessageToGroup1,这个是发给组1

     

    将此标签页输入http://localhost:63891/test/SendMessageToGroup1and2,调用SendMessageToMyGroup方法,此时前四个页面显示00000000-0000-0000-0000-000000000000 says SendMessageToGroup1,这个是发给组1和组2

     

  • 相关阅读:
    HTML DOM 节点
    HTML DOM 简介
    XML DOM
    JavaScript Window Screen
    JavaScript Window
    JavaScript Date(日期) 对象
    11.2 正睿停课训练 Day15
    10.31 正睿停课训练 Day13
    10.29 正睿停课训练 Day11
    BZOJ.4361.isn(DP 树状数组 容斥)
  • 原文地址:https://www.cnblogs.com/wangpengzong/p/11175665.html
Copyright © 2011-2022 走看看