Sample Guide for WebSocket Components

WebSocket Sample Project

  1. 구조
    이 예제는 아래 그림과 같은 구조를 가진다.
    각 class 또는 file이 위치하거나 설정되는 곳을 표시하였다.

    Image

  2. 사용법

    • WAR를 maven build 하여 local WAS 에 deploy 한 후 브라우저에서 아래의 경로로 접속한다 (N개 가능, 크롬 권장)

      http://localhost:port/sample-websocket/client.mvc
      

      Image

    • connect 버튼을 클릭한다. 5초 정도 기다리면 자동으로 test 문자가 보여진다.
      AutoPublisher Thread가 보내는 Direct Message

      Image

    • TextForm 안에 전송하고 싶은 text를 입력하고 엔터를 친다
      Test 입력 문자를 입력하면 N개의 client에 전송된다

      Image

    • 또다른 브라우저에서 아래의 경로로 접속한다

      http://localhost:port/sample-websocket/sender.mvc
      

      web.xml과 dispatch-servlet.xml 의 설정에 의해서 sender.jsp 가 호출된다.

      Image

    • Send text message 버튼을 클릭하고 client 창을 확인하면 Sender가 보낸 message가 수신되어 표시된다.
      Glue service (activity) 를 통해서 보내지는 Direct Message

      Image