Ajax轮询 传输视频

需要做一个智能家居的项目,室内的温度,湿度,光照,实时以及视频传输。采用方案,H5和java组合做客户端(app),硬件用C去实现。正好我做客户端。。

H5 是用mui。。java用的是springBoot的WebFlux

app端



	
		
		
		
		
		
		
	

	
		

控制

温度:

湿度:

光照:

java端

①controller层

package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.*;
import java.util.HashMap;
import java.util.UUID;

@RestController
public class IndexController {

    @PostMapping("/getIfo.action")
    public Object getIfo() {
        HashMap hashMap = null;
        String wendu = UUID.randomUUID().toString();
        String shidu = UUID.randomUUID().toString();
        String guangzhao = UUID.randomUUID().toString();
        hashMap = new HashMap();
        hashMap.put("wendu", wendu);
        hashMap.put("shidu", shidu);
        hashMap.put("guangzhao", guangzhao);
        return hashMap;
    }

    @PostMapping("/getReslut.action")
    public Object getResult() throws IOException {
        File[] files = new File[]{
                new File("C:\\img/1.png"), new File("C:\\img/2.png"), new File("C:\\img/3.png"), new File("C:\\img/4.png")};
        int i = (int) (Math.random() * 3);
        FileInputStream fileInputStream = new FileInputStream(files[i]);
        byte[] bytes = new byte[fileInputStream.available()];
        fileInputStream.read(bytes);
        return JSON.toJSONString(bytes);

    }

}

2.pom.xml



    4.0.0

    com.example
    demo
    0.0.1-SNAPSHOT
    jar

    demo
    Demo project for Spring Boot

    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.4.RELEASE
         
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
        
            com.alibaba
            fastjson
            1.2.47
        

        
            org.springframework.boot
            spring-boot-starter-webflux
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            io.projectreactor
            reactor-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    



效果---》

 

Ajax轮询 传输视频_第1张图片

你可能感兴趣的:(前端)