Vibe JavaScript Client A is a lightweight B JavaScript client for browser-based C and Node-based D application.
- A
- Vibe 3.0.0-Alpha4 client.
- B
- 9.46KB minified, 4.7KB minified and gzipped.
- C
- It has no dependency and follows jQuery 1.x's browser support that embraces Internet Explorer 6.
- D
- Though browser is the first runtime, it runs seamlessly on Node.js.
Quick Start
Vibe JavaScript Client is distributed at two places according to runtime engine: browser version through this web site in compressed and uncompressed forms and node version through npm.
Once you've loaded the module, you will be able to write the following echo and chat client. This page already loaded the uncompressed version, hence you can run and debug it directly here by using a JavaScript console and doing copy and paste.
var socket = vibe.open("http://localhost:8080/vibe");
// Built-in events
socket.on("connecting", function() {
console.log("The selected transport starts connecting to the server");
})
.on("open", function() {
console.log("The connection is established successfully and communication is possible");
socket.send("echo", "An echo message").send("chat", "A chat message");
})
.on("error", function(error) {
console.error("An error happens on the socket", error);
})
.on("close", function() {
console.log("The connection has been closed, has been regarded as closed or could not be opened");
})
.on("waiting", function(delay, attempts) {
console.log("The socket waits out the", attempts, (["st", "nd", "rd"][attempts - 1] || "th"), "reconnection delay", delay);
})
// User-defined events
.on("echo", function(data) {
console.log("on echo event", data);
})
.on("chat", function(data) {
console.log("on chat event", data);
});
Further Reading
- To play something right now, start with archetype example.
- To take a brief look at API, check out the testee.
- To get details of API, see API document.
- To have a thorough knowledge of the implementation, read out the reference.