GithubHelp home page GithubHelp logo

marcinwieprzkowicz / ruby_bosh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mikemarsian/ruby_bosh

0.0 1.0 0.0 49 KB

An XMPP BOSH session pre-initializer for Ruby web applications (updated for Ruby 2+)

Home Page: http://github.com/mikemarsian/ruby_bosh

License: MIT License

Ruby 100.00%

ruby_bosh's Introduction

RubyBosh

The RubyBOSH library handles creating and pre-authenticating BOSH streams inside your Ruby application before passing them off to your template engine.

This method allows you to hide authentication details for your users' XMPP accounts.

Tested on Rails 4.2, Ruby 2.1.2 with eJabberd 16.04

References

BOSH: http://xmpp.org/extensions/xep-0124.html

XMPP via BOSH: http://xmpp.org/extensions/xep-0206.html

Example

In your Ruby app controller (or equivalent):

@session_jid, @session_id, @session_random_id = 
  RubyBOSH.initialize_session("[email protected]", "my_password", "http://localhost:5280/http-bind")

If you want to define your own resource name, include it within the jid. RubyBOSH will create a random one if none is supplied. To define a resource name of 'home', do the following:

@session_jid, @session_id, @session_random_id = 
  RubyBOSH.initialize_session("[email protected]/home", "my_password", "http://localhost:5280/http-bind")

In your template, you would then pass these directly to your javascript BOSH connector:

var bosh_jid = '<%= @session_jid %>';
var bosh_sid = '<%= @session_id %>';
var bosh_rid = '<%= @session_random_id %>';
// using Strophe:
connect.attach(bosh_jid, bosh_sid, bosh_rid, onConnectHandlerFunction);

// using ConverseJS:
converse.initialize({
        jid: bosh_jid, sid: bosh_sid, rid: bosh_rid
        // ... the rest of the initialization data
  })

Acknowledgements

Jack Moffit - thanks for the nice Django example

Copyright (c) 2008 Pradeep Elankumaran. See LICENSE for details.

Copyright (c) 2016 Mike Polischuk. See LICENSE for details.

ruby_bosh's People

Contributors

skyfallsin avatar mikemarsian avatar sishen avatar hamzakc avatar matzko avatar terceiro avatar brimil01 avatar willbailey avatar

Watchers

James Cloos 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.