我正在編寫一個REST API提供對資源的CRUD操作。是一個API RESTful,如果它允許永久請求(服務器推送)
我希望用戶能夠註冊某些資源更改並通過服務器推送獲取更新。對於服務器推送,我將提供對反向ajax,隱藏的iframe和websockets的支持。爲了爲REST儘可能我創建了處理註冊和客戶端連接的流資源:
流媒體資源:
URI uri : A GET against this URI refreshes the client representation of the resources accessible to this user.
bool WebSocket : Indicate if websocket is available on this server
bool ReverseXHR : Indicate if ReverseXHR is available on this server
bool HiddenIframe : Indicate if HiddenIframe is available on this server
Registration[] Registrations : The set of registration tasks.
OpenChannel:開放式流道從Web服務器到客戶端。 GET參數類型=(websocket | xhr | hiddeniframe)
CloseChannel:關閉從網絡服務器到客戶端的流媒體頻道。 GET參數類型=(的WebSocket | XHR | hiddeniframe)
的openchannel?type=websocket
的調用將打開的WebSocket,並開始流的記錄值中的數據。
我讀過很多文章,但我仍然有點困惑。這樣做後,我還可以調用我的API REST嗎?如果沒有(或是)爲什麼?
謝謝你的幫助!
你是怎麼做到的?我不擔心這種模式的純潔性 - 服務器推送越來越重要。我想知道你是如何實現這個的。 – 2014-08-25 08:02:54