Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.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
Javascript 如何使用Pusher将用户的存款和取款详细信息从客户端发送到Node.js(express)服务器?_Javascript_Node.js_Websocket_Pusher_Pusher Js - Fatal编程技术网

Javascript 如何使用Pusher将用户的存款和取款详细信息从客户端发送到Node.js(express)服务器?

Javascript 如何使用Pusher将用户的存款和取款详细信息从客户端发送到Node.js(express)服务器?,javascript,node.js,websocket,pusher,pusher-js,Javascript,Node.js,Websocket,Pusher,Pusher Js,我订阅“我的频道”并绑定到客户端中的“我的事件” pusher.html <!DOCTYPE html> <head> <title>Pusher Test</title> <script src="https://js.pusher.com/5.0/pusher.min.js"></script> <script> // Enable pusher logging - don't incl

我订阅“我的频道”并绑定到客户端中的“我的事件”

pusher.html

<!DOCTYPE html>
<head>
  <title>Pusher Test</title>
  <script src="https://js.pusher.com/5.0/pusher.min.js"></script>
  <script>

    // Enable pusher logging - don't include this in production
    Pusher.logToConsole = true;

    var pusher = new Pusher('******', {
      cluster: 'ap2',
      forceTLS: true
    });

    var channel = pusher.subscribe('my-channel');
    channel.bind('my-event', function(data) {
      alert(JSON.stringify(data));
    });

  </script>
</head>
<body>
  <h1>Pusher Test</h1>
  <p>
    Try publishing an event to channel <code>my-channel</code>
    with event name <code>my-event</code>.
  </p>
</body>
我正在“我的频道”中触发“我的事件”,并发送一条消息“hello world”

server.js

        var pusher = new Pusher({
            appId: '****',
            key: '****',
            secret: '******',
            cluster: 'ap2',
            encrypted: true
        });

        pusher.trigger('my-channel', 'my-event', {
            "message": "hello world"
        });
对于这段代码,我在客户端收到一条警报消息。i、 例如,我的服务器正在向客户端发送消息,但我的问题是,我希望整个过程以另一种方式进行,我希望客户端向服务器发送消息,以及如何在服务器中接收消息?如何使用node.js使用pusher来实现这一点


谢谢

频道提供的客户端库只能订阅频道并使用事件(它们还可以向其他客户端发送事件)-它们不能向服务器触发事件。 服务器库只能触发事件-它们不能订阅通道

可以通过使用和配置必要的工具来实现解决方案

更多信息可在推送器通道中找到