GithubHelp home page GithubHelp logo

hookbox's Introduction

= HookBox Notes =

Hookbox is a comet server and message queue that tightly integrates with web application frameworks. The goal of Hookbox is to allow your web application (php, django, rails, etc.) to handle all of the logic pertaining to authentication, authorization, logging, message transformation, etc, while still hiding the hard parts of Comet.

== Hookbox HTTP Api ==

=== /publish ===

Request

    URL: [HOOKBOX]/publish

Request Form:
    channel_name: The destination to publish the message
    payload: (default null) The payload for the message

Responses
    true: It worked
    false: Some error occurred

=== /channel_info ===

Request

    URL: [HOOKBOX]/channel_info

Request Form:
    channel_name: The destination to publish the message
    payload: (default null) The payload for the message

Response:
    true: It worked
    false: Some error occurred

Response Data
    channel_name (string): The name of the channel
    subscribers (list): List of channel subscribers
    reflective (bool): Does this channel reflect publishes to publisher
    history (int): Length of history kept in the channel

=== /set_channel_options ===

Request

    URL: [HOOKBOX]/set_channel_options

Request Form:
    channel_name: The name of the channel to modify with the given options.
    reflective: (bool, default=true)
    history_size: (int, default=0) Determines the size of the history kept per channel. This history is sent to users when they subscribe to a channel.
    moderated: (bool, default=true) If true, then all events on the channel must be authorized via a callback.
    moderated_publish: (bool, default=true) If true, publish events must be authorized via a callback.
    moderated_subscribe: (bool, default=true) If true, subscribe events must be authorized via a callback.
    moderated_unsubscribe: (bool, default=true) If true, unsubscribe events must be authorized via a callback.
    presenceful: (bool, default=false) If true, presence lists will be attached to each publish frame. Also, SUBSCRIBED and UNSUBSCRIBED frames will be sent to all channel subscribers when another user subscribes or unsubscribes.
    anonymous: (bool, default=false) If true, usernames will be omitted from publish frames
Response:
    true: It worked
    false: Some error occurred

Response Data
    None

== HookBox Webhooks ==

Each webhook takes arguments in the form of a querystring encoded post body that should just work with existing form processing infrastructure.

Each webhook returns a JSON list, of the form [ boolean, object ]. The first argument signifies the authorization/success of the operation, and the object contains various options that vary by hook type.

All webhooks will have a "Cookie:" header with a value identical to the browser that caused the request to be initiated. The "context" of the webhook call should therefore contain a session for the originating browser.


=== connect ===

Request

    URL: [ROOT]/connect

Request Form:
    (empty)

Responses:
    true: Authorize connection
    false: Deny connection

Response Options
    name (optional): the Display Name for this connection; it will be used for presence.
    auto_subscribe (optional): (list) A list of channels to attempt to auto-subscribe the user. Each will generate a subscribe callback.
    auto_unsubscribe (optional): (list) A list of channels to attempt to auto-unsubscribe the user. Each will generate an unsubscribe callback.

=== create channel ===

Request
    URL: [ROOT]/create_channel

Request Form:
    destination: The channel's URI


Responses:
    true: Authorize channel creation
    false: Deny channel creation

Response Options
    history: (int, default 0) Specifies the amount of history that should be saved on the channel. When a user first subscribes they will be sent this history.
    set_history: (list, default []) Pre-populates history for the channel

Note: A create channel is issuing when a user subscribes to a non-existent destination. There will usually be a /subscribe callback immediately following a create_channel callback, unless the channel creation is denied.

=== publish ===

Request
    URL: [ROOT]/publish

Request Form:
    destination: The channel's URI
    payload: The json payload to be published

Responses:
    true: Authorize publishing
    false: Deny publishing

Response Options
    override_payload (optional): If specified, this payload will be delivered instead of the original payload
    auto_subscribe (optional): (list) A list of channels to attempt to auto-subscribe the user. Each will generate a subscribe callback.
    auto_unsubscribe (optional): (list) A list of channels to attempt to auto-unsubscribe the user. Each will generate an unsubscribe callback.


=== unsubscribe ===

Request
    URL: [ROOT]/unsubscribe

Request Form:
    destination: The channel's URI

Responses:
    true: Authorize unsubscribe
    false: Deny unsubscribe

Response Options
    auto_subscribe (optional): (list) A list of channels to attempt to auto-subscribe the user. Each will generate a subscribe callback.
    auto_unsubscribe (optional): (list) A list of channels to attempt to auto-unsubscribe the user. Each will generate an unsubscribe callback.


=== disconnect ===

Request
    URL: [ROOT]/disconnect

Request Form:
    channels: (list) The channels the users was in.

Responses:
    true: Required (Doesn't really do anything)
    false: Meaningless (but does the same as true.)

Response Options
    (None)

== Overview ==

A typical session with a Hookbox application might Look like this:

1) User navigates to http://www.example.com/index.html
    The user is given a login page, which he fills out.
2) Browser POSTs to http://www.example.com/login
    Included in the post body is the username and password
3) Web application returns Cookie: session_id=abc;
4) Web application redirects user to http://www.example.com/home
    The user is now logged into the application and sees the gui
5) Browser calls hookbox.connect('http://hookbox.example.com')
6) Browser send a CONNECT frame to hookbox, including { cookie: "session_id=abc"; }
7) Hookbox makes an HTTP POST to http://www.example.com/hookbox/connect
    Hookbox includes the header "Cookie: session_id=abc;"
8) The Web Application responds with a json payload: [ true, {}]
    This gives authorization for the client to connect
9) Browser calls hookbox.publish('test.location', ["Hello", "World"]

10) Hookbox makes an HTTP POST to http://www.example.com/hookbox/publish
    Hookbox includes the header "Cookie: session_id=abc;"
    Hookbox includes a query string in the POST body with the data
        payload=["Hello", "World"]
        channel_name=test.location
11) The Web app returns the json payload: [true, { } ]
    This gives authorization for the client to publish the message
12) Hookbox sends a PUBLISH frame to all clients currently subscribed to the
    channel 'test.location'

hookbox's People

Contributors

alanjds avatar alcides avatar alexharo avatar briandorsey avatar bubbleboy14 avatar desmaj avatar dlg avatar ergo avatar fairfieldt avatar faulkner avatar fdiary avatar geoffreyplitt avatar heckj avatar honzakral avatar jezdez avatar jordoh avatar leopd avatar mcarter avatar msch avatar mviamari avatar philipn avatar skaughtx0r avatar wrichert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hookbox's Issues

Trying to install on Centos 6.3 and having error installing from source or pip setuptool

I'm trying to install hookbox on centos 6.3 but seems its not working i have installed all dependencies using yum install libevent-*

Traceback (most recent call last):
File "/usr/bin/hookbox", line 9, in
load_entry_point('hookbox==0.3.3', 'console_scripts', 'hookbox')()
File "/usr/lib/python2.6/site-packages/hookbox_dax-0.3.4a1-py2.6.egg/hookbox/start.py", line 26, in main
hubs.use_hub("pyevent") # dlg test of alternate hub
File "/usr/lib/python2.6/site-packages/eventlet-0.15.2-py2.6.egg/eventlet/hubs/init.py", line 96, in use_hub
'eventlet.hubs.' + mod, globals(), locals(), ['Hub'])
File "/usr/lib/python2.6/site-packages/eventlet-0.15.2-py2.6.egg/eventlet/hubs/pyevent.py", line 3, in
import event
ImportError: /usr/lib64/python2.6/site-packages/event-0.4.2-py2.6-linux-x86_64.egg/event.so: undefined symbol: event_loop

Invalid JSON parsing

Passing in this URL fails with ExpectedException: Invalid json for payload:
/web/publish?payload=%7B%22code%22:%22new_task%22,%22message%22:%22Task%20was%20successfully%20created.%22,%22status_id%22:1,%22project_id%22:13,%22test%22:%22complete:function(request)%7B$('.dashboard_task[task_id=205]%20.dashboard_task_loading').hide();%7D%22,%22release_id%22:-1,%22result%22:true%7D&channel_name=testing&security_token=secret

The payload should be decoded as this, which is valid JSON:
{"code":"new_task","message":"Task was successfully created.","status_id":1,"project_id":13,"test":"complete:function(request){$('.dashboard_task[task_id=205] .dashboard_task_loading').hide();}","release_id":-1,"result":true}

I suspect it has something to do with having curly braces in its content.

ValueError: Unkown error: response object is None

Hi guys,

I'm new to using hookbox and I'm having a bit of a problem. I managed to build and run hookbox on my windows server and I'm trying to use a small C# server for the webhooks. I can get the webhook callback for the "connect" action, but when I try to send my http response, the hookbox server gives me an error message saying "ValueError: Unkown error: response object is None"

Here is the full traceback

2011-05-11 20:30:08,783 - hookbox - WARNING - Exception with webhook http://192.168.0.198:8000
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\hookbox-0.3.4dev-py2.7.egg\hookbox\server.py", line 211, in http_request
response = http.request(method='POST', path=path, payload=form_body, headers=headers)
File "build\bdist.win32\egg\restkit\resource.py", line 193, in request
raise ValueError("Unkown error: response object is None")
ValueError: Unkown error: response object is None

Any idea what might be causing this?

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.