Welcome to the Fayecpp Documentation
This page contains detailed documentation for Fayecpp, a C++ implementation of the Faye messaging protocol.
Installation
To use Fayecpp in your C++ projects, you need to install it first. Follow the steps below:
- Open your terminal.
- Run the following command to install Fayecpp:
$ git clone https://github.com/fayecpp/fayecpp.git
$ cd fayecpp
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install
Usage
Once Fayecpp is installed, you can start using it in your C++ projects. Here’s a basic example:
#include <fayecpp/fayecpp.hpp>
#include <iostream>
int main() {
fayecpp::Client client("http://localhost:8000/faye");
client.connect();
fayecpp::SubscriptionPtr subscription = client.subscribe("/channel", [](const fayecpp::MessagePtr& message) {
std::cout << "Received message: " << message->data() << std::endl;
});
client.publish("/channel", "Hello, Faye!");
client.disconnect();
return 0;
}
API Reference
The following is a list of classes and functions available in the Fayecpp library:
Class / Function | Description |
---|---|
fayecpp::Client |
A class representing a Faye client. |
fayecpp::Subscription |
A class representing a Faye subscription. |
fayecpp::Message |
A class representing a Faye message. |
fayecpp::MessagePtr |
A shared pointer to a Faye message. |
fayecpp::SubscriptionPtr |
A shared pointer to a Faye subscription. |
fayecpp::ConnectionState |
An enumeration representing the connection state of a Faye client. |
fayecpp::connect |
A function to establish a connection to a Faye server. |
fayecpp::disconnect |
A function to disconnect from a Faye server. |
fayecpp::publish |
A function to publish a message to a Faye server. |
fayecpp::subscribe |
A function to subscribe to a channel on a Faye server. |
fayecpp::unsubscribe |
A function to unsubscribe from a channel on a Faye server. |
Conclusion
Now that you have a basic understanding of Fayecpp, you can start exploring its features and use it to implement real-time messaging in your C++ applications.