Git Product home page Git Product logo

channelstream's Introduction

Channelstream

Build Status

This is a websocket-based real-time communication server, your applications communicate with it via simple JSON REST API.

Visit http://channelstream.org for more information.

Installation and Setup

Use from docker:

docker pull channelstream/channelstream:latest
docker run --rm -p 8000:8000 -e CHANNELSTREAM_ALLOW_POSTING_FROM=0.0.0.0 channelstream/channelstream:latest

Direct usage

Obtain source from github and do:

YOUR_PYTHON_ENV/bin/pip install channelstream

Generate new configuration:

YOUR_PYTHON_ENV/bin/channelstream_utils make_config -o config.ini

Start the server:

YOUR_PYTHON_ENV/bin/channelstream -i config.ini

Demos

Demo applications live in https://github.com/Channelstream/channelstream_demos repository.

They show common patterns used in real-time applications.

Security and communication model

Channelstream provides API explorer that you can use to interact with various endpoints, it is available by default under http://127.0.0.1:8000/api-explorer.

To send information client interacts only with your normal www application. Your app handled authentication and processing messages from client, then passed them as signed message to channelstream server for broadcast.

websocket client -> webapp (security and transformation happens here) -> REST call to socket server -> broadcast to other clients

This model is easy to implement, secure, easy to scale and allows all kind of languages/apps/work queues to interact with socket server.

All messages need to be signed with a HMAC of destination endpoint ::

import requests
from itsdangerous import TimestampSigner
signer = TimestampSigner(SERVER_SECRET)
sig_for_server = signer.sign('/connect')
secret_headers = {'x-channelstream-secret': sig_for_server,
                  'Content-Type': 'application/json'}
response = requests.post(url, data=json.dumps(payload),
                         headers=secret_headers).json()

Data format and endpoints

Please consult API Explorer (http://127.0.0.1:8000/api-explorer) for in depth information about endpoints.

Some examples:

  • /connect POST connects users to the server
  • /subscribe POST Subscribes connection to new channels
  • /unsubscribe POST Removes connection from channels
  • /user_state POST set the state of specific user
  • /message POST Send message to channels and/or users
  • /message DELETE Delete message from history and emit changes
  • /message PATCH Edit existing message in history and emit changes
  • /channel_config POST Set channel configuration
  • /info POST Returns channel information

Client API

  • /ws GET Handles websocket connections
  • /listen GET Handles long polling connections
  • /disconnect GET Permanently remove connection from server
  • /disconnect POST Permanently remove connection from server

Admin API

  • /admin/admin.json GET Return server information in json format for admin panel purposes
  • /admin/admin.json POST Return server information in json format for admin panel purposes

Responses to js client

Responses to client are in form of list containing objects:

examples:

new message ::

{
"date": "2011-09-15T11:36:18.471862",
"message": MSG_PAYLOAD,
"type": "message",
"user": "NAME_OF_POSTER",
"channel": "CHAN_NAME"
}

presence info ::

{
"date": "2011-09-15T11:43:47.434905",
"message": {"action":"joined/parted"},
"type": "presence",
"user": "NAME_OF_POSTER",
"channel": "CHAN_NAME"
}

Currently following message types are emited: message, message:edit, message:delete, presence, user_state_change.

channelstream's People

Contributors

dependabot[bot] avatar ergo avatar kwasielew 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

channelstream's Issues

Spec out 1.0 API

There is legacy API right now that generally works, but there should be a better versioned API for the server, that utilizes HTTP verbs better, we probably should revamp some configuration keys and response formats too.

AttributeError: 'collections.OrderedDict' object has no attribute 'data'

Running
YOUR_PYTHON_ENV/bin/channelstream

This error appears in console:

File "/home/manu/workspace/channelstream/channelstream/wsgi_views/server.py", line 145, in connect
json_body = schema.load(request.json_body).data
AttributeError: 'collections.OrderedDict' object has no attribute 'data'

Executed under python3.7

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.