https://github.com/benpope/pusher-cpp
Pusher++ is a header-only cross-platform C++ library for connecting to Pusher
https://github.com/benpope/pusher-cpp
asio beast boost cmake cpp openssl pusher
Last synced: 12 months ago
JSON representation
Pusher++ is a header-only cross-platform C++ library for connecting to Pusher
- Host: GitHub
- URL: https://github.com/benpope/pusher-cpp
- Owner: BenPope
- License: bsl-1.0
- Created: 2017-01-23T22:41:48.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-25T15:21:09.000Z (about 8 years ago)
- Last Synced: 2025-04-11T21:21:43.842Z (12 months ago)
- Topics: asio, beast, boost, cmake, cpp, openssl, pusher
- Language: C++
- Size: 26.4 KB
- Stars: 18
- Watchers: 3
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE_1_0.txt
Awesome Lists containing this project
README
# Pusher client and server built on Boost.Asio
## Contents
- [Introduction](#introduction)
- [Features](#features)
- [Usage](#usage)
- [Requirements](#requirements)
- [Status](#status)
- [Licence](#licence)
- [Contact](#contact)
## Introduction
Pusher++ is a header-only cross-platform C++ library for connecting to [Pusher](https://pusher.com). It's built on top of Boost.Asio via Boost.Beast for HTTP and Websocket support.
## Features
* **Performance.** Supports both synchronous and asynchronous APIs.
* **SSL support.** Connect securely to endpoints at Pusher and bypass problematic proxies.
* **Symmetric API** Client and Server share the same API.
## Usage
These examples are complete, but you will have to set your application specific credentials. The [examples](pusher++/examples) directory contains examples that parse the command line.
Example Server:
```C++
#include
#include
int main()
{
std::string const app_id = "Your App ID";
std::string const secret = "Your Secret";
std::string const key = "Your Key";
boost::asio::io_service ios;
pusher::server server{ios, app_id, key, secret};
server.connect();
std::string input;
while(input != "bye" && std::cout << "\nMessage: " && std::getline(std::cin, input))
{
std::cout << server.trigger("test_channel", "test_name", input);
}
ios.run();
}
```
Example Client:
```C++
#include
#include
int main(int argc, char* argv[])
{
std::string const key = "Your Key";
boost::asio::io_service ios;
pusher::client client{ios, key};
client.connect();
client.bind_all([](pusher::event const& event)
{
std::cout << event.data << '\n';
});
auto test_channel = client.channel("test_channel");
test_channel.bind("test_name", [&client](pusher::event const& event)
{
if(event.data == "bye")
client.disconnect();
});
ios.run();
}
```
## Requirements
* C++14
* [Beast](https://boostorg/beast) >= 121
* [Boost](http://www.boost.org) >= 1.63
* [RapidJSON](https://github.com/miloyip/rapidjson/) >= v1.1.0
* [Crypto++](https://github.com/weidai11/cryptopp) >= 5.6.5 (server)
* [OpenSSL](https://www.openssl.org/) = 1.0.2 (optional)
## Build
This is a header only library, no building is required.
However, a cmake build system is in place for tests and examples. Currently, it is assumed that the environment is the environment is linux-ish and that Boost and OpenSSL headers are installed; other dependencies are managed by cmake. Building on Windows should work, but is untested and will likely require some minor changes to find Boost and OpenSSL.
```
mkdir -p build && cd build && cmake .. && make -j
```
## Status
Caveat emptor. This is very early work; it's incomplete and has not been used in anger. Everything is subject to change, but it may not be completed or even maintained.
However, you are free to use it under the terms set out below.
## Licence
Distributed under the Boost Software License, Version 1.0. (See accompanying file [LICENSE_1_0.txt](LICENSE_1_0.txt) or copy at [http://www.boost.org/LICENSE_1_0.txt](http://www.boost.org/LICENSE_1_0.txt))
## Contact
Please report issues or questions here:
https://github.com/BenPope/pusher-cpp/issues