# [Xavi](http://xavi.io) - Realtime Channel Server [![Build Status](https://travis-ci.org/xavi-js/xavi-client.png)](https://travis-ci.org/xavi-js/xavi-client)

_WebSocket interface for highly distributed systems_

### Client library

---

#### Features

- __Channel Subscriptions:__ subscribe to multiple distributed channels and backend services via a unified API
- __Two-way Messaging:__ communicate with backend services in an event driven fashion
- __Message Integrity:__ messages are queued until sent, preserving order and data integrity

---

#### Getting started

Install Xavi

```bash
$ bower install xavi
```

Include dependency

```html
<script src="xavi.min.js"></script>
```

Or load with RequireJS

```javascript
define(["xavi"], function(xavi) {
	// ...
});
```

Create new client and connect to server

```javascript
var client = new xavi.Client({
	host: "localhost",
	port: 8080
});

client.connect();
```

Subscribe to channels

```javascript
client.subscribe("test.*");
```

Send and receive messages

```javascript
client.on("test.channel", "command", function(message) {
	// ...
});

client.send(new xavi.Message({
	channel: "test.channel",
	command: "command",
	data: "Test message"
}));
```

_To get up and running with the server library, please visit the [xavi repository](https://github.com/footballradar/xavi)._

---

#### Contributing

Xavi is completely open source, and welcomes community contributions.

Before you start, please read our [contribution guidelines](CONTRIBUTING.md).

##### At a glance

- Fork this repository
- Create a new branch
- When ready, submit a pull request

To contribute to other Xavi projects, visit the relevant repos:

- [xavi](https://github.com/xavi-js/xavi-client) - _Server library_
- [xavi-middleware-auth](https://github.com/xavi-js/xavi-middleware-auth) - _Authentication middleware_
- [xavi-middleware-cookie](https://github.com/xavi-js/xavi-middleware-encoding) - _Cookie middleware_
- [xavi-service-echo](https://github.com/xavi-js/xavi-service-echo) - _Echo service binding_
- [xavi-service-irc](https://github.com/xavi-js/xavi-service-irc) - _IRC service binding_
- [xavi-service-rabbitmq](https://github.com/xavi-js/xavi-service-rabbitmq) - _RabbitMQ service binding_
- [xavi-service-redis](https://github.com/xavi-js/xavi-service-redis) - _Redis service binding_
- [xavi-service-thrift](https://github.com/xavi-js/xavi-service-redis) - _Thrift service binding_
- [xavi-service-zookeeper](https://github.com/xavi-js/xavi-service-zookeeper) - _ZooKeeper service wrapper_

#### License

Xavi is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT).

_&copy; 2014 [Football Radar](http://www.footballradar.com)_