Coder Social home page Coder Social logo

cloud-paper-cgi's Introduction

后端说明

功能概述

  1. 接受创建请求,生成token,返回客户端
  2. 接受用户的数据,通过websocket广播转发,并在本地存储
  3. 房间id、密码、

接口

  1. /token/create 向服务器申请创建一个演示间,获取一个token,然后马上建立ws连接
    • method:GET
    • 传入:
      • { id: String,房间id, password: String,房间密码,若无密码则为空字符串 }
    • 返回: token:一个16位随机字符串,每4个字母用一个-分割,因此字符串长度一共为16+3
  2. /token/destroy/:token 销毁演示间
    • method:GET
    • token:要销毁的token。仅有“发送绘制事件”权限的用户发送的该请求才会被处理
  3. /websocket/connect/:token 客户端通过ajax请求将token传到服务器请求建立ws连接,相当于加入演示间
    • method: GET
    • 返回:
      • { state: "success" || "failed", token: token || "" }
    • 客户端请求成功后执行回掉函数建立ws连接, url:http://host:post/' + token
  4. /websocket/getRooms
    • method: GET
    • 返回:
      • [{ id: string,房间名 token: string,令牌 },***]

结构说明

  • api
    • websocket.js
    • token.js
  • storage 数据存储
  • app.js
  • api_router.js
  • dispatch.js

扩展建议

  1. 不用创建token,AR扫一扫类似物品进入同一个房间(类似于支付宝那种)

cloud-paper-cgi's People

Contributors

xuboxun avatar pea3nut avatar

Watchers

James Cloos avatar tanrich avatar  avatar snovey avatar

Forkers

pea3nut

cloud-paper-cgi's Issues

CORS跨域Express中间件

app.use(function(req ,res ,next){
    res.header('Access-Control-Allow-Origin', '*');
    res.header(
        'Access-Control-Allow-Headers',
        'Content-Type, Content-Length, Authorization, Accept, X-Requested-With'
    );
    res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
    res.header('Access-Control-Allow-Credentials', 'true');
    if (req.method == 'OPTIONS') {
        res.send(200); //options快速响应
    }
    else {
        next();
    }
});

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.