Go to file
Ryan Lee e536dd2940 Change variable name 2016-09-20 20:10:49 -04:00
cmake Move to WebRTC branch-heads/54 branch 2016-09-12 08:03:45 -04:00
examples Update API 2016-09-20 20:04:20 -04:00
src Change variable name 2016-09-20 20:10:49 -04:00
.gitignore Update configuration 2016-08-12 12:54:01 +09:00
CMakeLists.txt Move to WebRTC branch-heads/54 branch 2016-09-12 08:03:45 -04:00
LICENSE Rename a project 2016-08-12 12:53:50 +09:00
README.md Update README.md 2016-09-14 19:25:14 -04:00
webrtcbranch Add supporting webrtc branch information file 2016-09-14 19:04:24 -04:00

README.md

PeerConnect

A peer-to-peer C++ library for network.

  • Network connection over firewall or NAT
  • No ip address and port number required
  • Support NAT traversal and WebRTC

Quick start

Peer A (listen)

PeerConnect pc("PEER_A");

pc.On("message", function_pc(string peer, PeerConnect::Buffer& data) {
  std::cout << "A message has been received." << std::endl;
});

pc.Open();

Peer B (connect)

PeerConnect pc("PEER_B");

pc.On("open", function_pc(string peer) {
  pc.>Connect("PEER_A");
});

pc.On("connect", function_pc(string peer) {
  pc.Send("PEER_A", "Hello");
});

pc.Open();

Example

See the examples directory.

Build

The currently supported platforms are Windows, Mac OS X and Linux.

Before You Start

First, be sure to get WebRTC source and install prerequisite software.

In the WebRTC development instruction

  • Follow 'Before You Start' step
  • Follow 'Getting the code' step

Currently PeerConnect supports branch-heads/54 so run

$ git checkout -b peers54 refs/remotes/branch-heads/54

To update build toolchain and dependencies of WebRTC, run:

$ gclient sync

Note that you don't have to follow 'Generating Ninja project files' or 'Compiling' step. PeerConnect will do that internally.

Build PeerConnect

Generate the build files

$ cd /path/to/src
$ mkdir build
$ cd build
$ cmake .. -DWEBRTC_ROOT_DIR=/path/to/webrtc-checkout/src \
      -DDEPOT_TOOLS_DIR=/path/to/depot_tools

NOTE On windows, you can generate Visual Studio 2015 project.

$ cmake -G "Visual Studio 14 2015" .. \
      -DWEBRTC_ROOT_DIR=/path/to/webrtc-checkout/src \
      -DDEPOT_TOOLS_DIR=/path/to/depot_tools

Finally you can build generated makefile.

$ make