项目作者: lvlick

项目描述 :
A minimalistic TCP Server written in elixir.
高级语言: Elixir
项目地址: git://github.com/lvlick/Compound.git
创建时间: 2018-06-28T18:21:03Z
项目社区:https://github.com/lvlick/Compound

开源协议:GNU General Public License v3.0

下载


Compound

A minimalistic TCP Server written in Elixir.

Introduction

Compound goal is to offer a simple API that allows users to send and receive packets via TCP connections.
Each TCP connection is handled by its own process utilizing Elixir’s GenServer behavior.
For your applications to be able to handle packets received by Compound, callbacks are used with the possibility of each connection having its own callback.

Installation

Compound can be added to your project
by append compound to your list of dependencies in mix.exs:

  1. def deps do
  2. [
  3. {:compound, "~> 0.1.0"}
  4. ]
  5. end

and then running mix deps.get to install it.

Preparation

Before you can use Compound you have to take a few steps.

First you need to add one or more server configurations to your config.exs:

  1. config :compound, tcp_servers: [
  2. %{id: "example", port: 3001},
  3. ...
  4. ]

A server configuration consists of an id (as a string) and a port (as an integer).

After starting your elixir app simply call Compound.TCP.set_default_callback(server, callback) with the id of the server from the configuration and a pid.
Incoming packets for that server will be forwarded to your callback process as {:new_packet, packet, sender}.