io.higgs.ws.demo.WebSocketDemo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of websocket Show documentation
Show all versions of websocket Show documentation
Higgs' WebSocket server and client implementation
package io.higgs.ws.demo;
import io.higgs.core.HiggsServer;
import io.higgs.http.server.Transcription;
import io.higgs.http.server.config.HttpConfig;
import io.higgs.http.server.protocol.HttpProtocolConfiguration;
import io.higgs.ws.protocol.WebSocketConfiguration;
/**
* @author Courtney Robinson
*/
public class WebSocketDemo {
private WebSocketDemo() {
}
public static void main(String... args) {
//handles HTTP GET requests
WebSocketConfiguration ws = new WebSocketConfiguration();
//handles all other HTTP requests
HttpProtocolConfiguration http = new HttpProtocolConfiguration();
//re-write all requests to /app/* to index.html
ws.getTranscriber().addTranscription(new Transcription("/app((?:\\/[\\w([^\\..]{1,4}\b)\\-]+)+)",
"/index.html"));
HiggsServer server = new HiggsServer().setConfig("config.yml", HttpConfig.class);
server.registerProtocol(ws);
//HTTP must be registered after WebSockets
server.registerProtocol(http);
//
server.registerClass(Api.class);
server.start();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy