BLOG main image
분류 전체보기 (63)
(17)
성윤이 (0)
(5)
일상 (10)
낙관주의 (3)
삽질 (9)
웹사업개발팀 (5)
14661 Visitors up to today!
Today 28 hit, Yesterday 19 hit
daisy rss
tistory 티스토리 가입하기!
2008/01/22 14:27

http://svn.xantus.org/shortbus/trunk/bayeux/bayeux.html

문서를 읽고 한시간만에 다 까먹을거 같아서 대충 정리.



[Bayeux protocol]
서버와 클라이언트간의 비동기 메시지를 HTTP를 통해서 지연없이 전달하기위한 프로토콜.
Ajax과 Comet을 이용해서    양방향 이벤트 처리가 가능한 웹클라이언트를 만들기 위함.

[Transport Type]
- polling transports
  - 하나의 http request/response에 하나의 Bayeux Message를 처리하는 방식
- streaming transport
  - 하나의 http request/response에 복수의 Bayeux Message를 처리. (using forever response)
  - 불필요한 http reqeust로 인한 오버헤드가 없으나, 완결되 user agent 및 proxy가 non completed http response가 전달가능하도록 구현되어 있어야 한다.
- two connection operation
  - 양방향통신(bi-directional communications)이 비동기적으로 일으날수 있게 하기 위해서 두개의 tcp connection을 사용한다. (http client는 하나의 서버에 대해서 동시에 생성할수 있는 커넥션이 2개이다.(SHOULD)

[Protocol Values]
# Bayeux protocol을 통해서 전달되는 데이터는 JSON으로 표현된다.
- Channel :
- Version : 프로토콜 버전
- Client ID : 서버에서 할당한 클라이언트 구별자
- Messages : JSON encoded objects that contain an unordered sequence of name value pairs
representing fields and values
[
  {
    "channel": "/some/name",
    "clientId": "83js73jsh29sjd92",
    "data": { "myapp" : "specific data", value: 100 }
  }
]

[Message Type]
+ Meta Message
  - handshake request/response
    * connection negotiation 초기화
    * clientId 발급
  - connect request/response
    * connection 수립(establish)
    * connection type지정 (by client)
  - disconnect request/response
    * connection 해제
  - subscribe request/response
    * 채널에 구독요청 (요청된 채널에 발생한 이벤트를 전달받도록 셋팅)
      request that messages published to the subscribe channel are delivered to the client
  - unsubscribe request/response
    * 채널에 구독요청 해지
+ Event Message
  - publish request/response
    * 채널에 이벤트 발생시킴
    * 발생된 이벤트는 채널을 구독중인 다른 클라이언트에 전달 (deliver message)
  - deliver
    * 채널에 발생된 이벤트를 구독중인 클라이언트에 전달
+ Polling Message
- long-polling request
Messages are sent to the server as the body of a POST, encoded either as "application/x-www-form-urlencoded" or as "text/json".
- long-polling response
Messages are sent to the client as unencapsulated body content of a POST response with content type "text/json" or "text/json-comment-filtered".
- callback-polling request
Messages are sent to the server either using POST requests as per long-polling transport or as the "message" URL parameter of a GET request.
- callback-polling response
Messages are sent to the client as JavaScript function call returned for script source GET requests. The function called will be determined by the "jsonp" field of any associated request messages, or "jsonpcallback" if not specified. The called function will be passed a JSON array of Bayeux messages.


[Cross domain comunication]
- JSONP를 사용하여 우회


[JSONP]
+ JSON with Padding
+ JSONP는 JSON과 <script> 태그를 결합하여 사용함으로써 Same-Origin 정책을 우회하는 하나의 방식이다.

예제                
<script type="text/javascript" src="http://travel.com/findItinerary?username=sachiko&reservationNum=1234&output=json&callback=showItinerary" />

    
http://www.ibm.com/developerworks/kr/library/x-ajaxsecurity.html
http://ajaxpatterns.org/On-Demand_Javascript

이올린에 북마크하기(0) 이올린에 추천하기(0)
Trackback Address :: http://10year.tistory.com/trackback/93
망구 | 2008/01/27 16:11 | PERMALINK | EDIT/DEL | REPLY
안녕하세요 cometd 관련 자료를 찾다가 님의 블로그를 알게되었습니다.
글을 쭉 보다보니.. iframe,xhr 으로 cometd 를 구현하신거 같더군요...
사용하신 서버와 클라이언트 양쪽 모두에 대한 소스코드를 좀 참조하고싶은데 보여주실수있는지요?
제 메일은 tominku@naver.com 입니다.
10year | 2008/01/30 15:59 | PERMALINK | EDIT/DEL
제가 구현했다는 얘기는 없는데... ^^ ;
관련 문서를 읽고 정리한 거구요.
서버는 cometd 프로젝트에 가보면 jetty인가 하는 자바로 구현한 서버 프로젝트로의 링크가 있구요.
클라이언트는 기억에 없네요. 죄송. - ;
무쇠다리 | 2008/01/28 09:07 | PERMALINK | EDIT/DEL | REPLY
크로스도메인 문제를 jsonp 라는 것으로 우회한다...
어떻게 하는 것인지 좀 더 설명해 주세요.
xhr 을 이용해 코맷을 구현시 커넥션 하나는 코맷용으로 할당되고 하나만 겨우 동작해서 문제가 있네요.
document.domain 값을 지정해 줘도 소용이 없네요.
10year | 2008/01/30 16:28 | PERMALINK | EDIT/DEL
답글로 달기 애매해서 클라이언트 코드를 포스팅합니다.
^ ^
http://10year.tistory.com/entry/JSONP-%ED%81%B4%EB%9D%BC%EC%9D%B4%EC%96%B8%ED%8A%B8-%EC%98%88%EC%A0%9C
Name
Password
Homepage
Secret