user-img
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ/WebSocket 5
thumbnail
SpringBoot3 WebSocket ChattingServer๋งŒ๋“ค๊ธฐ 5๋‹จ๊ณ„ - ์ฑ„ํŒ…๋ฐฉ ์ธ์› ์ˆ˜ ์ฒดํฌ, Server Side Event ์ฒ˜๋ฆฌ
0. ๋ชฉ์ฐจ 1. ๊ฐœ์š” - ์ด์ „๊ณผ ๋‹ฌ๋ผ์ง„ ์  2. ์ „๊ฐœ๋„ 3. ์ฝ”๋“œ ๋ถ„์„ 4. ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ํ•˜๋ฉด์„œ ๊ฒช์—ˆ๋˜ ์˜ค๋ฅ˜๋“ค https://www.daddyprogrammer.org/post/5290/spring-websocket-chatting-server-enter-qut-event-view-user-count/ ๋ฅผ ๋ณด๊ณ  ์ง„ํ–‰ ํ–ˆ์Šต๋‹ˆ๋‹ค. 1. ๊ฐœ์š” โ“ ์ž…์žฅ ํ‡ด์žฅ ์‹œ ์ธ์› ์ˆ˜ ์ฒดํฌํ•ด์„œ ์ธ์› ์ˆ˜๋ฅผ ์ฑ„ํŒ…๋ฐฉ์— ํ‘œ์‹œ โ“‘ ์ €๋ฒˆ ํฌ์ŠคํŒ…๊นŒ์ง€๋Š” ์ฑ„ํŒ…๋ฐฉ ์ž…์žฅ๊ณผ ๊ตฌ๋…์„ ํด๋ผ์ด์–ธํŠธ์—์„œ ์ธ์ง€ํ•˜๊ณ  ๋ฐฑ์—”๋“œ๋กœ ๋ณด๋‚ด์ฃผ๊ณ , ๊ทธ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๋ฅผ ํ–ˆ์Œ. ์ด๋ฒˆ์—๋Š” Sever Side์—์„œ ํ•ด๋‹น ์ด๋ฒคํŠธ๋ฅผ ์ง์ ‘ ์ธ์ง€ ํ•˜๊ณ , ์ผ์„ ์ฒ˜๋ฆฌํ•˜๋„๋ก ๋ฐ”๊ฟจ์Œ. 2. ์ „๊ฐœ๋„ ์›๋ž˜ ๋ฐฐ์šธ ๋•Œ Controller -> service -> Repository๋กœ ์ผ์ด ์ •ํ•ด์ ธ ์žˆ์—ˆ์ง€..
2024.01.23
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ/WebSocket
thumbnail
SpringBoot WebSocket Chatting Server๋งŒ๋“ค๊ธฐ 4๋‹จ๊ณ„ - SpringBoot Security ์žฅ์ฐฉ
0.๋ชฉ์ฐจ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ๋“ค์˜ ์ถœ์ฒ˜: ddadyProgrammer๋‹˜์˜ ๋ธ”๋กœ๊ทธ Spring websocket chatting server(4) - SpringSecurity + Jwt๋ฅผ ์ ์šฉํ•˜์—ฌ ๋ณด์•ˆ๊ฐ•ํ™”ํ•˜๊ธฐ ์ด๋ฒˆ ์žฅ์—์„œ๋Š” SpringSecurity์™€ Jwt๋ฅผ ์ด์šฉํ•˜์—ฌ Web ๋ฐ Websocket์˜ ๋ณด์•ˆ์„ ์ข€ ๋” ๊ฐ•ํ™”ํ•˜๊ณ . ๊ธฐ์กด์˜ ๋ณต์žกํ•œ ๋กœ์ง์„ ๊ฐ„์†Œํ™”ํ•˜๋Š” ์ž‘์—…์„ ์ง„ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํฌ๊ฒŒ ์•„๋ž˜์˜ 3๊ฐ€์ง€ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. Spri www.daddyprogrammer.org 1. ๊ฐœ์š” (์ƒˆ๋กญ๊ฒŒ ์ถ”๊ฐ€ํ•œ ๊ฒƒ๋“ค) 2. ์ „๊ฐœ๋„ 3. ์ฝ”๋“œ ๋ถ„์„ 4. ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ํ•˜๋ฉฐ ๋งŒ๋‚ฌ๋˜ ์˜ค๋ฅ˜ ๋ชจ์Œ 1. ๊ฐœ์š” ์ด๋ฒˆ ์žฅ์—์„œ๋Š” ์ƒˆ๋กญ๊ฒŒ Spring Security๋ฅผ ์ ์šฉํ–ˆ๋‹ค. ์›๋ž˜ ํ”„๋กœ์ ํŠธ๋Š” ์ ‘๊ทผํ•œ ๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ๋Œ€ํ™”๋ช…๋งŒ ์ž…๋ ฅํ•˜๋ฉด ๋ชจ๋‘ ์‚ฌ์šฉ..
2024.01.22
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ/WebSocket
thumbnail
SpringBoot WebSocket Chatting Server ๋งŒ๋“ค๊ธฐ 3๋‹จ๊ณ„ - ์—ฌ๋Ÿฌ ์ฑ„ํŒ… ์„œ๋ฒ„ ๊ฐ„์˜ ๋ฉ”์„ธ์ง€ ๊ณต์œ  (by Redis Pub/sub)
2
https://www.daddyprogrammer.org/post/4731/spring-websocket-chatting-server-redis-pub-sub/ 0.๋ชฉ์ฐจ 1. ๊ฐœ์š” 2. ์ „๊ฐœ๋„, ์ „์ฒด์ ์ธ ํ๋ฆ„ ํŒŒ์•… 3. ์ฝ”๋“œ ๋ถ„์„ 4. ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์žˆ์—ˆ๋˜ ์—๋Ÿฌ ํ•ด๊ฒฐ 1. ๊ฐœ์š” ์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” Redis๋ผ๋Š” ์ธ๋ฉ”๋ชจ๋ฆฌํ˜• DB๋ฅผ ํ™œ์šฉํ•˜์—ฌ 2๋ฒˆ๊นŒ์ง€ ์ง„ํ–‰ํ–ˆ๋˜ STOMP์™€ WebSocket๋งŒ์œผ๋กœ ๊ตฌํ˜„ํ•œ Chatting Server ํ”„๋กœ์ ํŠธ๋ฅผ ๋” ๊ณ ๋„ํ™” ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. ์–ด? ์ด๋ฏธ ํ•˜๋‚˜์˜ ์„œ๋ฒ„์—์„œ ์„œ๋กœ ๋ฉ”์„ธ์ง€๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š” ๊ฒƒ์€ ์ถฉ๋ถ„ํžˆ ๋˜๋Š”๋ฐ ์™œ Redis๋ฅผ ์žฅ์ฐฉํ•ด์•ผ ํ• ๊นŒ์š”? ๊ทธ๋ ‡๋‹ค๋ฉด, ๋จผ์ € Redis๋ฅผ ์™œ ์žฅ์ฐฉํ•ด์•ผ ํ•˜๋Š”์ง€์— ๋Œ€ํ•ด์„œ ์„ค๋ช…ํ•˜๊ฒ ๋‹ค. โ“ STOMP์™€ WebSocket๋งŒ์„ ์“ฐ๋Š” Chatting Serv..
2024.01.20
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ/WebSocket
thumbnail
Spring websocket chatting server ๋งŒ๋“ค๊ธฐ 2๋‹จ๊ณ„ - ๊ณ ๋„ํ™”
๋ณธ ํ”„๋กœ์ ํŠธ๋Š” ์Šคํ”„๋ง ์›น์†Œ์ผ“ ์ฑ„ํŒ…์„œ๋ฒ„ ๋งŒ๋“ค๊ธฐ ๋ฅผ ์‹ค์Šตํ•˜๋ฉฐ ๊ณต๋ถ€ํ•˜๊ธฐ ์œ„ํ•œ ํ”„๋กœ์ ํŠธ ์ž…๋‹ˆ๋‹ค. branch ๋ณ„๋กœ ์ด 6๋‹จ๊ณ„ ๋ชจ๋‘ ์ง„ํ–‰ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. 0. STOMP๋ž€ ๋ฌด์—‡์ธ๊ฐ€? Stomp๋ž€ SimpleTextOrientedMessagingProtocol์˜ ์•ฝ์ž๋กœ, ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜ ์–‘๋ฐฉํ–ฅ ํ†ต์‹ ์„ ํšจ์œจ์ ์œผ๋กœ ํ•˜๊ธฐ ์œ„ํ•œ ํ†ต์‹  ๊ทœ์•ฝ์ด๋‹ค. Stomp์˜ ์›๋ฆฌ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. Stomp์—๋Š” 3๊ฐ€์ง€ ๊ฐœ๋…์ด ์กด์žฌํ•˜๋Š”๋ฐ, Topic, Publisher, Subscriber๊ฐ€ ๊ทธ๊ฒƒ์ด๋‹ค. Topic์€ ์šฐ์ฒดํ†ต์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค. publisher๋Š” ๋ฉ”์„ธ์ง€ ๋ฐœํ–‰์ž์ด๋‹ค. Publisher๊ฐ€ ์–ด๋–ค Topic์„ EndPoint๋กœ ์žก๊ณ  ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด๋ฉด ํ•ด๋‹น ์šฐ์ฒดํ†ต์œผ๋กœ ๋ฉ”์„ธ์ง€๊ฐ€ ๋“ค์–ด๊ฐ„๋‹ค. ์ด๋•Œ ํ•ด๋‹น Topic์„ ๊ตฌ๋…ํ•˜๊ณ  ์žˆ๋Š” Subscriber..
2024.01.14
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ/WebSocket
thumbnail
SpringBoot WebSocket chatting server ๋งŒ๋“ค๊ธฐ 1๋‹จ๊ณ„
๋ณธ ํ”„๋กœ์ ํŠธ๋Š” ์Šคํ”„๋ง ์›น์†Œ์ผ“ ์ฑ„ํŒ…์„œ๋ฒ„ ๋งŒ๋“ค๊ธฐ ๋ฅผ ์‹ค์Šตํ•˜๋ฉฐ ๊ณต๋ถ€ํ•˜๊ธฐ ์œ„ํ•œ ํ”„๋กœ์ ํŠธ ์ž…๋‹ˆ๋‹ค. branch ๋ณ„๋กœ ์ด 6๋‹จ๊ณ„ ๋ชจ๋‘ ์ง„ํ–‰ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ๋‚ด์šฉ์œผ๋กœ ๋งŒ๋“  ํ”„๋กœ๊ทธ๋žจ์ž…๋‹ˆ๋‹ค. ์ฒซ ๋‹จ๊ณ„๋ผ์„œ firstStep์ด๋ž€ branch์— ์ €์žฅํ•˜์˜€์Šต๋‹ˆ๋‹ค. https://github.com/dalcheonroadhead/WebSocketBEPractice/tree/firstStep 1. ์ „๊ฐœ๋„ 1-1 Server Logic ํ•ด๋‹น ๋ธ”๋กœ๊ทธ์˜ Basic WebSocket์˜ ์ „๊ฐœ๋„ ์ด๋‹ค. ์•„์ฃผ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์•„์ง DB์™€ ์—ฐ๊ฒฐํ•˜์ง€ ์•Š๊ณ , ์„œ๋น„์Šค์™€ ์ปจํŠธ๋กค๋Ÿฌ, ๋ชจ๋ธ, ์›น์†Œ์ผ“ ์„ค์ • ๋””๋ ‰ํ† ๋ฆฌ๋งŒ ํ•„์š”ํ–ˆ๋‹ค. 1-2 Server์™€ Client ์ „์ฒด Logic ๋จผ์ € ๋‚ด๊ฐ€ ํ—ท๊ฐˆ๋ ธ๋˜ ๋ถ€๋ถ„์€ Rest API์™€ ์†Œ์ผ“์ด ๋‹ค๋ฅธ ์žฅ์†Œ์—์„œ ma..
2024.01.07
๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ/WebSocket