Skip to content

Commit

Permalink
feat: WebSocket 채팅 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
airoca committed Jan 24, 2024
1 parent ba0edcb commit 95b8988
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 230 deletions.
42 changes: 0 additions & 42 deletions src/main/java/com/example/sign/websocket/ChatController.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/com/example/sign/websocket/ChatMessage.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/com/example/sign/websocket/ChatRoom.java

This file was deleted.

47 changes: 0 additions & 47 deletions src/main/java/com/example/sign/websocket/ChatService.java

This file was deleted.

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();
}
}

34 changes: 34 additions & 0 deletions src/main/java/com/example/sign/websocket/Room.java
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;
}

}


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 src/main/java/com/example/sign/websocket/SpringConfigurator.java
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 src/main/java/com/example/sign/websocket/WebSockChatHandler.java

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/com/example/sign/websocket/WebSockConfig.java

This file was deleted.

Loading

0 comments on commit 95b8988

Please sign in to comment.