Skip to content

Commit

Permalink
🧪 웹소켓 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaeng committed Dec 1, 2024
1 parent 293552a commit e050790
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/apis/chat.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChatEvent } from '@src/types/domain/dm';
import { Client, Frame, IMessage } from '@stomp/stompjs';
import SockJS from 'sockjs-client';
// import SockJS from 'sockjs-client';

const WEBSOCKET_URL = process.env.REACT_APP_WEBSOCKET_URL_SECURE!;
const WEBSOCKET_URL = process.env.REACT_APP_WEBSOCKET_URL!;

let stompClient: Client | null = null;
type MessageHandler<T extends ChatEvent | MessageRequest> = (
Expand All @@ -17,14 +17,14 @@ export const connectHandler = <T extends ChatEvent | MessageRequest>(
const accessToken = localStorage.getItem('accessToken');

stompClient = new Client({
// brokerURL: WEBSOCKET_URL,
brokerURL: WEBSOCKET_URL,
connectHeaders: {
Authorization: `${accessToken}`.trim(),
},
forceBinaryWSFrames: true,
webSocketFactory: () => {
// const ws = new WebSocket(WEBSOCKET_URL);
const ws = new SockJS(WEBSOCKET_URL);
const ws = new WebSocket(WEBSOCKET_URL);
// const ws = new SockJS(WEBSOCKET_URL);

ws.onopen = () => {
console.log('[WebSocket Open]: Connection established');
Expand Down

0 comments on commit e050790

Please sign in to comment.