Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

almightycouch/meteorpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meteor++

Build Status Coverage Status Github Releases Documentation Status GitHub license Github Issues

Cover image

Meteor DDP & Minimongo implementation in C++.

With this library you can:

  • communicate with Meteor applications over Websockets
  • subscribe to real-time feeds, track changes and observe specific queries
  • call server-side methods, query and modify collections
  • keep your data mirrored and simulate server operations (latency compensation)

Quick Start

Install Meteor++:

git clone --recursive git://github.com/almightycouch/meteorpp.git
cd meteorpp/build/
cmake ..
make

Run the examples:

ddp-monitor test

Intregrate the library to your project and enjoy the power of Meteor with the speed of C++.

Documentation

One of the seven principles of Meteor is "simplicity equals productivity".

No esoteric concepts, clear documentation, well-established coding conventions, a set of simple tools designed to integrate seamlessly together.

Meteor++ was built from ground up with the very same philosophy, keep things simple. Both APIs share many similar patterns. If you are familiar to Meteor, you will feel right at home.

Integration

The library is written in modern C++. It depends on following third-party libraries:

Most of these libraries are header-only and do not require any specific installation. However, you must install boost_random, boost_system and ejdb to successfully build Meteor++.

In order to support features such as latency compensation and atomic operations, some files in the EJDB library must be patched. You can get the patch to apply here.

Note that a fork of EJDB containing the required changes is available as a submodule.

Though it's 2015 already, the support for C++11 is still a bit sparse. Do not forget to set the necessary switches to enable C++11 (e.g., -std=c++11 for GCC and Clang).

Installing Boost

Installing Boost is straight forward on most systems.

OSX:

brew install boost

Linux:

sudo apt-get install libboost-dev libboost-program-options-dev libboost-random-dev libboost-system-dev

If you require more specific informations about the installation process, please read this Getting Started on Unix Variants guide.

Installing EJDB

Installing EJDB is pretty easy as well as we provide the patched library as submodule.

cd ejdb/
mkdir build/
cd build/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../dist ../
make && make install
cd ../../

Building Meteor++

Once the dependencies installed, you can build meteorpp as follow:

cd meteorpp/build/
cmake ..
make

Examples

Here are some examples to give you an idea how to use the library.

#include <boost/asio.hpp>

#include <meteorpp/ddp.hpp>
#include <meteorpp/ddp_collection.hpp>
#include <meteorpp/live_query.hpp>

void print_live_query(std::shared_ptr<meteorpp::live_query> const& live_query)
{
    std::cout << live_query->data().dump(4) << std::endl;
}

int main(int argc, char** argv)
{
    boost::asio::io_service io;

    std::shared_ptr<meteorpp::ddp_collection> coll;
    std::shared_ptr<meteorpp::live_query> live_query;

    auto ddp = std::make_shared<meteorpp::ddp>(io);
    ddp->connect("ws://localhost:3000/websocket", [&](std::string const& id) {
        coll = std::make_shared<meteorpp::ddp_collection>(ddp, "test");
        coll->on_ready([&]() {
            live_query = coll->track({{ "foo", "bar" }});
            live_query->on_changed(std::bind(print_live_query, live_query));
            print_live_query(live_query);
        });
    });

    io.run();
    return 0;
}

License & Warranty

Copyright (c) 2015 Mario Flach under the MIT License (MIT)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Meteor DDP & Minimongo implementation in C++.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published