Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 信号器从浏览器向同一台计算机上的.net客户端发送消息_Asp.net_.net_Websocket_Signalr_Nativeapplication - Fatal编程技术网

Asp.net 信号器从浏览器向同一台计算机上的.net客户端发送消息

Asp.net 信号器从浏览器向同一台计算机上的.net客户端发送消息,asp.net,.net,websocket,signalr,nativeapplication,Asp.net,.net,Websocket,Signalr,Nativeapplication,我们需要将本机应用程序与web应用程序进行通信 我们认为应该使用信号器来发送消息/命令 管道将是: 用户单击以执行操作 Javascript(带有信号器)向azure中的服务器发送消息 服务器将消息重新发送到特定的客户端。它必须是安装在同一台计算机上的客户端 一旦结果完成,NET将发送结果的反向 问题是,我如何在信号服务器中找到来自同一台机器的客户机 我们系统中的组织是: 有一个健身中心 每个中心都有可以登录的工作人员 我们可以通过一些文件配置来识别同一中心的客户机。例如,保存我们的密钥

我们需要将本机应用程序与web应用程序进行通信

我们认为应该使用信号器来发送消息/命令

管道将是:

  • 用户单击以执行操作
  • Javascript(带有信号器)向azure中的服务器发送消息
  • 服务器将消息重新发送到特定的客户端。它必须是安装在同一台计算机上的客户端
  • 一旦结果完成,NET将发送结果的反向
问题是,我如何在信号服务器中找到来自同一台机器的客户机

我们系统中的组织是:

  • 有一个健身中心
  • 每个中心都有可以登录的工作人员
我们可以通过一些文件配置来识别同一中心的客户机。例如,保存我们的密钥中心。但是,在一个中心中,可能有多个.NET客户端安装在不同的计算机上

我们认为使用计算机的私有IP在信号服务器上生成密钥

var ips = [];

    var RTCPeerConnection = window.RTCPeerConnection ||
        window.webkitRTCPeerConnection || window.mozRTCPeerConnection;

    var pc = new RTCPeerConnection({
        // Don't specify any stun/turn servers, otherwise you will
        // also find your public IP addresses.
        iceServers: []
    });
    // Add a media line, this is needed to activate candidate gathering.
    pc.createDataChannel('');

    // onicecandidate is triggered whenever a candidate has been found.
    pc.onicecandidate = function (e) {
        if (!e.candidate) { // Candidate gathering completed.
            pc.close();
            console.log(ips);
            return;
        }
        var ip = /^candidate:.+ (\S+) \d+ typ/.exec(e.candidate.candidate)[1];

        ips.push(ip);
    };
    pc.createOffer(function (sdp) {
        pc.setLocalDescription(sdp);
    }, function onerror() { });
可以在.NET客户端中毫无问题地获取这些数据。但是在javascript中,前面的代码可以正常工作。在某些PC中,它只返回ipv4。在Mozilla中,它不起作用

我们如何识别这两个客户?你知道实现目标的其他方法吗


谢谢,

最后,我们没有找到过滤ip地址的好方法

我们做了如下工作:

我们使用URI模式来启动我们的应用程序

公共类注册 常量URI_方案为String=“xxx” Const URI_KEY As String=“URL:xxx” 私有共享应用程序路径为String=Location.AssemblyDirectory()'“C:\Program Files(x86)\xxx.exe” 公共共享子注册表风险模式() 使用hkcrClass作为RegistryKey=Registry.ClassesRoot.CreateSubKey(URI\U方案) hkcrClass.SetValue(无,URI_键) hkcrClass.SetValue(“URL协议”,[String]。空,RegistryValueKind.[String]) 使用defaultIcon作为RegistryKey=hkcrClass.CreateSubKey(“defaultIcon”) Dim iconValue As String=[String]。格式(“{0}”,0),应用程序路径) defaultIcon.SetValue(无,iconValue) 终端使用 使用shell作为RegistryKey=hkcrClass.CreateSubKey(“shell”) 使用open As RegistryKey=shell.CreateSubKey(“打开”) 将命令用作RegistryKey=open.CreateSubKey(“命令”) Dim cmdValue为字符串=[String]。格式(“{0}”“%1”“,应用程序路径) command.SetValue(无,cmdValue) 终端使用 终端使用 终端使用 终端使用 端接头 末级 在Azure WebApp中,我们启动了一个信号服务器。此服务器将从我们的.NET应用程序向Chrome发送数据

为了实现这一点,当web加载时,我们连接到signar服务器。为了构建de uri,我们将connectionId从Javascript客户端发送到.NET客户端

然后,当本机进程完成时。NET客户端将信息发送到signalR服务器,该服务器使用connectionId将数据镜像到JavaScript客户端

为了避免启动本机应用程序的某些实例,我们使用IPC通道将数据发送到上一个实例,然后关闭新实例


链接至source

可能会使用另一个选项来启动我们的应用程序,并通过signalr发送结果。 Public Class RegistrarURI Const URI_SCHEME As String = "xxx" Const URI_KEY As String = "URL:xxx" Private Shared APP_PATH As String = Location.AssemblyDirectory() ' "C:\Program Files (x86)\xxx.exe" Public Shared Sub RegisterUriScheme() Using hkcrClass As RegistryKey = Registry.ClassesRoot.CreateSubKey(URI_SCHEME) hkcrClass.SetValue(Nothing, URI_KEY) hkcrClass.SetValue("URL Protocol", [String].Empty, RegistryValueKind.[String]) Using defaultIcon As RegistryKey = hkcrClass.CreateSubKey("DefaultIcon") Dim iconValue As String = [String].Format("""{0}"",0", APP_PATH) defaultIcon.SetValue(Nothing, iconValue) End Using Using shell As RegistryKey = hkcrClass.CreateSubKey("shell") Using open As RegistryKey = shell.CreateSubKey("open") Using command As RegistryKey = open.CreateSubKey("command") Dim cmdValue As String = [String].Format("""{0}"" ""%1""", APP_PATH) command.SetValue(Nothing, cmdValue) End Using End Using End Using End Using End Sub End Class