Code Monkey home page Code Monkey logo

poxa's Introduction

Build Status

Poxa

Open Pusher implementation compatible with Pusher libraries. It's designed to be used as a single registered app with id, secret and key defined on start.

Features

  • Public channels;
  • Private channels;
  • Presence channels;
  • Client events;
  • SSL on websocket and REST api;

TODO

  • Complete REST api;
  • Mimic pusher error codes;
  • Simple console;
  • Integration test using pusher-js or other client library;
  • Web hooks;
  • Specify types signature to functions and use dyalizer to check them;

Typical usage

Poxa is a standalone elixir server implementation of the Pusher protocol.

You need Elixir 0.9.0 at least and we need at least Erlang R16B.

Clone this repository

Run

mix deps.get
mix compile

The default configuration is:

  • Port: 8080
  • App id: 'app_id'
  • App key: 'app_key'
  • App secret: 'secret'

You can run and configure these values using this command:

elixir --erl "-poxa port 9090 -poxa app_id '<<"12345">>' -poxa app_key '<<"key-12345">>' -poxa app_secret '<<"secret6789">>'" -S mix run --no-halt

Or you can setup a configuration file like this:

test.config

[{poxa, [{port, 8080},
         {app_id, <<"12345">>},
         {app_key, <<"key-12345">>},
         {app_secret, <<"secret6789">>}]}].

And run:

elixir --erl "-config test" -S mix run --no-halt

And if you want SSL, try something like this on your configuration file:

[{poxa, [{port, 8080},
         {app_id, <<"app_id">>},
         {app_key, <<"app_key">>},
         {app_secret, <<"secret">>},
         {ssl, [{port, 8443},
                {cacertfile, "priv/ssl/server-ca.crt"},
                {certfile, "priv/ssl/server.crt"},
                {keyfile, "priv/ssl/server.key"}]}]}].

Release

If you just want to run an executable, follow these instructions:

TODO

Your application

If you are using the pusher-gem:

Pusher.host   = 'localhost'
Pusher.port   = 8080

And pusher-js:

Pusher.host    = 'localhost'
Pusher.ws_port = 8080

Implementation

Poxa uses gproc extensively to register websocket connections as channels. So, when a client subscribes for channel 'example-channel', the websocket connection (which is a elixir process) is "tagged" as {pusher, example-channel}. When a pusher event is triggered on the 'example-channel', every websocket matching the tag receives the event.

Contributing

If you'd like to hack on Poxa, start by forking my repo on Github.

Dependencies can be fetched running:

MIX_ENV=dev mix deps.get

Compile:

mix compile

The test suite used is the ExUnit and meck to mock stuff. You can run the tests:

mix test

Pull requests are greatly appreciated.

Pusher

Pusher is an excellent service and you should use it on production.

poxa's People

Contributors

edgurgel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.