Shuttle

lejehwan·2021년 9월 25일

Project

목록 보기
3/4

1. Web Socket

그 전에 HTTP 통신부터 설명하자

  • HTTP 통신??

    client가 브라우저를 통해 server 에게 request(요청)
    request를 받은 server는 요청 데이터를 담아 브라우저를 통해 client에게 response(응답) 해주는 것

client -> request -> server -> response -> client

  • Web Socket 통신??

    채팅기능을 사용하려고 할 때, 채팅 메세지를 계속해서 request 해서 받아 올 수 없기 때문에 open - close의 양방향 통신을 함

  • When to Use it??

    • 채팅(우리의 이유)
    • 주식 관련 앱
    • 리얼 타임 등등

2. Stomp

STOMP is the Simple (or Streaming) Text Orientated Messaging Protocol.
STOMP provides an interoperable wire format so that STOMP clients can communicate with any STOMP message broker to provide easy and widespread messaging interoperability among many languages, platforms and brokers.
출처 : https://stomp.github.io/

Web Socket 위에서 동작하는 Protocol 로써 클라이언트와 서버가 전달할 메세지의 유형, 형식, 내용등을 정의 하는 매커니즘

여기서 우리는

채팅방 생성 : pub/sub 구현을 위한 TOPIC 생성
채팅방 입장 : TOPIC 구독
메세지 송수신 : 해당 TOPIC으로 메세지를 송신(pub), 수신(sub)

spring은 메세지를 외부 Broker에게 전달하고,
Broker는 Web Socket으로 연결된 클라이언트에게 메세지를 전달하는 구조

  • Merits??

    • 메세지 형식에 대해 커스터마이징 할 필요가 없다.
    • Broker을 통해 Subscription을 관리하고 broadcasting을 할 수 있다.
    • destination 헤더를 기반으로 @Controller의 @MethodMapping 메서드로 라우팅 된다
    • spring security로 메세지를 보호 할 수 있다.

출처 : https://dev-gorany.tistory.com/235?category=901854


3. More Info

https://github.com/CarrotStudy/Shuttle_Project

profile
물지만 않으면 괜찮아

0개의 댓글