Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
trismegisto-services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mauro Paolo Josue Zuñiga Mallqui
trismegisto-services
Commits
322fbf50
Commit
322fbf50
authored
Dec 10, 2023
by
paolo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SE AGREGO ENDPOINT WEBSOCKET
parent
215dd271
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
0 deletions
+125
-0
pom.xml
pom.xml
+15
-0
MVCConfig.java
src/main/java/web/multitask/app/config/MVCConfig.java
+16
-0
WebSocketConfig.java
src/main/java/web/multitask/app/config/WebSocketConfig.java
+23
-0
MessageController.java
.../java/web/multitask/app/controller/MessageController.java
+24
-0
Message.java
src/main/java/web/multitask/app/model/Message.java
+13
-0
Response.java
src/main/java/web/multitask/app/model/Response.java
+17
-0
application.properties
src/main/resources/application.properties
+3
-0
index.html
src/main/resources/static/index.html
+14
-0
app.war
target/app.war
+0
-0
No files found.
pom.xml
View file @
322fbf50
...
...
@@ -47,6 +47,21 @@
<artifactId>
json
</artifactId>
<version>
20230618
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-websocket
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<scope>
runtime
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
</dependencies>
<build>
...
...
src/main/java/web/multitask/app/config/MVCConfig.java
0 → 100644
View file @
322fbf50
package
web
.
multitask
.
app
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
@Configuration
public
class
MVCConfig
implements
WebMvcConfigurer
{
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedMethods
(
"HEAD"
,
"GET"
,
"PUT"
,
"POST"
,
"DELETE"
,
"PATCH"
);
}
}
\ No newline at end of file
src/main/java/web/multitask/app/config/WebSocketConfig.java
0 → 100644
View file @
322fbf50
package
web
.
multitask
.
app
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.messaging.simp.config.MessageBrokerRegistry
;
import
org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker
;
import
org.springframework.web.socket.config.annotation.StompEndpointRegistry
;
import
org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
;
@Configuration
@EnableWebSocketMessageBroker
public
class
WebSocketConfig
implements
WebSocketMessageBrokerConfigurer
{
@Override
public
void
configureMessageBroker
(
MessageBrokerRegistry
registry
)
{
registry
.
enableSimpleBroker
(
"/topic"
);
registry
.
setApplicationDestinationPrefixes
(
"/app"
);
}
@Override
public
void
registerStompEndpoints
(
StompEndpointRegistry
registry
)
{
registry
.
addEndpoint
(
"websocket"
).
setAllowedOrigins
(
"*"
);
}
}
\ No newline at end of file
src/main/java/web/multitask/app/controller/MessageController.java
0 → 100644
View file @
322fbf50
package
web
.
multitask
.
app
.
controller
;
import
org.springframework.messaging.handler.annotation.DestinationVariable
;
import
org.springframework.messaging.handler.annotation.MessageMapping
;
import
org.springframework.messaging.handler.annotation.SendTo
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
web.multitask.app.model.Message
;
import
web.multitask.app.model.Response
;
import
java.util.Date
;
@Controller
public
class
MessageController
{
@MessageMapping
(
"/websocket/{project}/{user}"
)
@SendTo
(
"/topic/message/{project}/{user}"
)
public
Response
envio
(
@PathVariable
(
"project"
)
String
project
,
@PathVariable
(
"user"
)
String
user
,
Message
message
)
{
return
new
Response
(
user
,
project
,
message
.
getContent
(),
new
Date
().
toString
());
}
}
\ No newline at end of file
src/main/java/web/multitask/app/model/Message.java
0 → 100644
View file @
322fbf50
package
web
.
multitask
.
app
.
model
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
@Data
@NoArgsConstructor
@Getter
public
class
Message
implements
java
.
io
.
Serializable
{
private
String
content
;
}
\ No newline at end of file
src/main/java/web/multitask/app/model/Response.java
0 → 100644
View file @
322fbf50
package
web
.
multitask
.
app
.
model
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
Response
implements
java
.
io
.
Serializable
{
private
String
user
;
private
String
project
;
private
String
content
;
private
String
date
;
}
\ No newline at end of file
src/main/resources/application.properties
View file @
322fbf50
...
...
@@ -2,3 +2,5 @@ spring.datasource.url=jdbc:mysql://13.59.147.125:3306/base
spring.datasource.username
=
server
spring.datasource.password
=
asd123
spring.datasource.driverClassName
=
com.mysql.cj.jdbc.Driver
server.port
=
8080
server.address
=
0.0.0.0
\ No newline at end of file
src/main/resources/static/index.html
0 → 100644
View file @
322fbf50
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<title>
Hello
</title>
</head>
<body>
<h1>
Hello World
</h1>
</body>
</html>
\ No newline at end of file
target/app.war
View file @
322fbf50
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment