Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.Hofmanix:sockjs-rpc-spring-boot:0.1.1'
}
dependencies {
implementation("com.github.Hofmanix:sockjs-rpc-spring-boot:0.1.1")
}
<dependency>
<groupId>com.github.Hofmanix</groupId>
<artifactId>sockjs-rpc-spring-boot</artifactId>
<version>0.1.1</version>
</dependency>
libraryDependencies += "com.github.Hofmanix" % "sockjs-rpc-spring-boot" % "0.1.1"
:dependencies [[com.github.Hofmanix/sockjs-rpc-spring-boot "0.1.1"]]
#SockJS RPC for Spring Boot
Library can be used with ng2-sockjs-rpc plugin for angular 2 for calling methods from client to server and from server to client
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.beans.factory.annotation.Autowired;
import cz.hofmanix.wsrpc.WsRpcHandler;
public class WebSocketsConfig extends WebSocketConfigurer {
@Autowired
public WsRpcHandler wsRpcHandler;
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(wsRpcHandler, "/site").withSockJS();
}
@Bean
public WsRpcHandler wsRpcHandler() {
return new WsRpcHandler();
}
}
import cz.hofmanix.wsrpc.WsRpcController;
@WsRpcController
public class SomeController {
public String someMethod(String name) {
return "Hello " + name;
}
}
Function will now accepts argument from given call from client and returns Hello argument to the client;