GithubHelp home page GithubHelp logo

whale-board-core-setting-websocket's Introduction

核心板虚拟键配置 && 面积配置

板子是 armv7l架构 arm 32位衍生版本 oracle 只提供了jdk8 因此运行此项目时请使用jdk8 编译运行

jdk 8 Download

一些注意事项

一定要注入 ServerEndpointExporter

可以用@Configuration注入 也可以在Application.java中添加注解

本来为了安全是要在核心板上装nginx从而将端口转发出去的 暂时没找到 armv7l nginx

websocket 依赖 xml -> pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
private static final Set<Session> list = new HashSet<>();

此list保存着所有session 如果 client 正常进行断开会通过

 @OnClose
public void close(Session session){
        list.remove(session);
}

进行自动删除 python 和 js(uniapp) 断开的代码如下

py

ws.close()

js

onUnload(() => uni.closeSocket())
@OnMessage
public void message( Session session){
}

@OnMessage可以获取当前的session

  @OnMessage
    public void message(byte[] msg Session sion){
        list.forEach(s ->{
            try {
                s.getBasicRemote().sendBinary(ByteBuffer.wrap(msg));
//                System.out.println("onMessage:"+ Arrays.toString(msg));
            }catch (IOException i){
                i.printStackTrace();
            }
        });
    }

之后可以做相应处理

whale-board-core-setting-websocket's People

Contributors

loyaltly-cn avatar

Watchers

 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.