Go to file
Ryan Lee ea11b4baa2 Supports WebRTC branch head 60 2017-10-23 00:39:33 +09:00
cmake Supports WebRTC branch head 60 2017-10-23 00:39:33 +09:00
examples Added strict namespace macro 2016-09-23 08:15:23 -04:00
src Supports WebRTC branch head 60 2017-10-23 00:39:33 +09:00
.gitignore Update configuration 2016-08-12 12:54:01 +09:00
API.md Write API documentation 2016-09-20 20:56:21 -04:00
CMakeLists.txt Supports WebRTC branch head 60 2017-10-23 00:39:33 +09:00
LICENSE Rename a project 2016-08-12 12:53:50 +09:00
README.md Supports WebRTC branch head 60 2017-10-23 00:39:33 +09:00
webrtcbranch Supports WebRTC branch head 60 2017-10-23 00:39:33 +09: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, char* data, size_t size) {
  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();

API

See the API.md document.

Example

See the examples directory.

Build

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

  • Visual Studio 2015 Update 2 or later on Windows. (Windows 7 x64 or later)
  • Linux 64bit - Most luck on Ubuntu 14.04
  • Xcode 5 or later on OS X - Latest Xcode is recommended
  • CMake 2.8 or later (On OS X, CMake 3.2 or later)

Before You Start

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

In the WebRTC development instruction

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

Currently PeerConnect supports WebRTC branch-heads/60 so run

$ git checkout -b peers60 refs/remotes/branch-heads/60

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