0
我是nodeJS和faye/websockets的新手。NodeJS中的Faye Websocket
使用webix製作了一個數據表,我想對它進行實時更新。
眼下試圖與王菲做,但不能肯定我應該王菲之後做什麼派我看起來像一個請求:
[{"channel":"/meta/handshake","version":"1.0","supportedConnectionTypes":["websocket","eventsource","long-polling","cross-origin-long-polling","callback-polling"],"id":"1"}]
,並得到一個階躍響應:
[{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"8bkeysctea7ucerz9h3tyjz0n52s5os","advice":{"reconnect":"retry","interval":0,"timeout":45000}}]
在服務器(的NodeJS)我有以下代碼:
var http = require("http"),
faye = require("faye");
var server = http.createServer(function (request, response) {
//Here i have some code for the CRUD operations for the webix Datatable
}),
bayeux = new faye.NodeAdapter({ mount: '/faye', timeout: 45 });
bayeux.attach(server);
server.listen(1212, function() {
console.log("\r\n" + new Date() + "\n -->> HTTP Server listens to Port 1212 <<--\r\n ");
});
在客戶端側(JS) :
webix.proxy.faye.client = new Faye.Client("//localhost:1212/faye");
webix.proxy.faye.clientId = webix.uid(); // unique client id
webix.proxy.faye.client.connect();
HTML:
<script type="text/javascript" src="//localhost:1212/faye/client.js"></script>
(從webix例子+王菲的例子都preatty太多的一切)
也許有人可以解釋我下一步要做什麼,或者給一個鏈接,我可以閱讀更多關於Websockets以及如何使用它們的信息。
謝謝你的時間。
ssry延遲,您的答案是正確的。而且我的桌子也沒有工作,因爲正如你所說'faye只用於在客戶之間同步數據',我認爲我可以使它與faye一起加載和更新 – MarkL