-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
172 additions
and
230 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
src/main/java/com/example/sign/websocket/ChatController.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/java/com/example/sign/websocket/RandomStringGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.sign.websocket; | ||
|
||
import java.security.SecureRandom; | ||
|
||
public class RandomStringGenerator { | ||
private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | ||
private static final SecureRandom RANDOM = new SecureRandom(); | ||
private static final int LENGTH = 20; | ||
|
||
public static String generateRandomString() { | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < LENGTH; i++) { | ||
int index = RANDOM.nextInt(ALPHABET.length()); | ||
sb.append(ALPHABET.charAt(index)); | ||
} | ||
return sb.toString(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.example.sign.websocket; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
|
||
@Entity | ||
public class Room { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String roomId; | ||
private String user1; | ||
private String user2; | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
public void setRoomId(String roomId) { | ||
this.roomId = roomId; | ||
} | ||
|
||
public void setUser1(String user1) { | ||
this.user1 = user1; | ||
} | ||
|
||
public void setUser2(String user2) { | ||
this.user2 = user2; | ||
} | ||
|
||
} | ||
|
||
|
21 changes: 21 additions & 0 deletions
21
src/main/java/com/example/sign/websocket/SpringApplicationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.sign.websocket; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SpringApplicationContext implements ApplicationContextAware { | ||
private static ApplicationContext context; | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext context) throws BeansException { | ||
SpringApplicationContext.context = context; | ||
} | ||
|
||
public static ApplicationContext getContext() { | ||
return context; | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
src/main/java/com/example/sign/websocket/SpringConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.sign.websocket; | ||
|
||
import org.springframework.context.ApplicationContext; | ||
import jakarta.websocket.server.ServerEndpointConfig.Configurator; | ||
|
||
public class SpringConfigurator extends Configurator { | ||
@Override | ||
public <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException { | ||
ApplicationContext context = SpringApplicationContext.getContext(); | ||
return context.getBean(clazz); | ||
} | ||
} | ||
|
69 changes: 0 additions & 69 deletions
69
src/main/java/com/example/sign/websocket/WebSockChatHandler.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/main/java/com/example/sign/websocket/WebSockConfig.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.