Revision 2271,
1.2 KB
checked in by alexandrecorreia, 15 years ago
(diff) |
Ticket #986 - Reimplementar interface mais leve para o IM, sem a necessidades de plugins adicionais.
|
-
Property svn:executable set to
*
|
Line | |
---|
1 | This is an example of Strophe attaching to a pre-existing BOSH session |
---|
2 | that is created externally. This example requires a bit more than |
---|
3 | HTML and JavaScript. Specifically it contains a very simple Web |
---|
4 | application written in Django which creates a BOSH session before |
---|
5 | rendering the page. |
---|
6 | |
---|
7 | Requirements: |
---|
8 | |
---|
9 | * Django 1.0 (http://www.djangoproject.com) |
---|
10 | * Twisted 8.1.x (http://twistedmatrix.com) |
---|
11 | * Punjab 0.3 (http://code.stanziq.com/punjab) |
---|
12 | |
---|
13 | Note that Twisted and Punjab are only used for small functions related |
---|
14 | to JID and BOSH parsing. |
---|
15 | |
---|
16 | How It Works: |
---|
17 | |
---|
18 | The Django app contains one view which is tied to the root URL. This |
---|
19 | view uses the BOSHClient class to start a BOSH session using the |
---|
20 | settings from settings.py. |
---|
21 | |
---|
22 | Once the connection is established, Django passes the JID, SID, and |
---|
23 | RID for the BOSH session into the template engine and renders the |
---|
24 | page. |
---|
25 | |
---|
26 | The template assigns the JID, SID, and RID to global vars like so: |
---|
27 | |
---|
28 | var BOSH_JID = {{ jid }}; |
---|
29 | var BOSH_SID = {{ sid }}; |
---|
30 | var BOSH_RID = {{ rid }}; |
---|
31 | |
---|
32 | The connection is attached to Strophe by calling |
---|
33 | Strophe.Connection.attach() with this data and a connection callback |
---|
34 | handler. |
---|
35 | |
---|
36 | To show that the session is attached and works, a disco info ping is |
---|
37 | done to jabber.org. |
---|
Note: See
TracBrowser
for help on using the repository browser.