chen0040 / spring-websocket-angular-4-demo

Demo on how to integrate spring websocket with angular 4 application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spring-websocket-angular-4-demo

Demo of connecting angular 4 application to spring web application via websocket

Usage

WebSocket Spring Boot Server

git clone this project, run the "./make.ps1" powershell script in the project root directory to build spring-boot-application.jar into the "bin" folder.

Run the following command to start the spring-boot-application at http://localhost:8080

java -jar bin/spring-boot-application.jar

The spring-boot-application defines an end point at http://localhost:8080/my-ws and sends a ping message to any connected client that subscribe to its topic "/topics/event" every 10 seconds. the angularjs demo can be viewed by navigating to http://localhost:8080 on your web browser.

Angular 4 Application

To run the angular application that communicate with the spring-boot-application:

cd ng4-application
npm install
ng serve

This will start the angular application at http://localhost:4200

The websocket implementation that subscribe to "/topics/event" websocket topic of the spring-boot-application can be found in the app.service.ts and app.component.ts

About

Demo on how to integrate spring websocket with angular 4 application

License:MIT License


Languages

Language:TypeScript 25.8%Language:Java 24.4%Language:JavaScript 21.8%Language:HTML 15.7%Language:CSS 11.2%Language:PowerShell 1.1%