美文网首页
SignalR 即时通信

SignalR 即时通信

作者: 把我推进深海的你真善良 | 来源:发表于2019-08-16 13:16 被阅读0次

proxy.on 需要写在  hub.start()前边

initconnect() {

      var self = this

      const hub = jQuery.hubConnection(self.apiurl)

      const proxy = hub.createHubProxy('SignalRServerHub')

      proxy.on('getorderinfo', function(message) {

        console.log('message', message)

        self.playVoice('./static/audio/newmes.mp3')

      })

      hub.start().done((connection) => {

        proxy.invoke('sendloginmsg', { source: this.source, companyID: this.comid, employeeid: this.eid })

      }).fail(() => {

        console.log('Could not connect')

      })

      hub.error(function(error) {

        console.log('SignalR error: ' + error)

      })

      hub.connectionSlow(function() {

        console.log('We are currently experiencing difficulties with the connection.')

      })

      hub.disconnected(function() {

        console.log('disconnected')

      })

      return proxy

    },

相关文章

网友评论

      本文标题:SignalR 即时通信

      本文链接:https://www.haomeiwen.com/subject/govfsctx.html