Giter Site home page Giter Site logo

signalr4miniapp's Introduction

signalR4Miniapp

供微信小程序与SignalR交互的js类库

如何使用

调用类库

在要使用的页面上:

///引入这个类库
var signalR = require('../../lib/signalr/signalr.js')
///实例化一个对象
let _client = new signalR.signalR();

创建 一个映射方法

这是为了让小程序收到SignalR的消息之后进行回调

callMethods(methods, args) {
        console.log(methods, args);
        let self = this;
        switch (methods) {
            case 'sayHello':
                self.sayHello(args[0]);
                break;
        }
    },

例子里有一个sayHello方法,我们用字符串作为key。

进行连接

_client.connection(url, methodMapping);
  • url : signalR服务器
  • methodMapping : 方法和字符串之间的Mapping

调用SignalR方法

 _client.call(methodName, args, success, fail)
  • methodName:远程方法名
  • args:参数,这里注意一定要数组格式
  • success:调用成功后的回调
  • fail:失败后的回调

signalr4miniapp's People

Contributors

jamesying avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.