quickblox 2.17.2-beta.2-logger → 2.17.3-logger

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/LICENSE +330 -201
  2. package/README.md +2 -2
  3. package/package.json +1 -2
  4. package/quickblox.js +19389 -21772
  5. package/quickblox.min.js +1 -1
  6. package/src/libs/strophe/strophe.common.js +6657 -0
  7. package/src/libs/strophe/strophe.esm.js +6649 -0
  8. package/src/libs/strophe/strophe.umd.js +6862 -0
  9. package/src/libs/strophe/strophe.umd.min.js +1 -0
  10. package/src/modules/chat/qbChat.js +131 -11
  11. package/src/modules/webrtc/qbWebRTCSignalingProcessor.js +2 -1
  12. package/src/modules/webrtc/qbWebRTCSignalingProvider.js +2 -1
  13. package/src/qbConfig.js +2 -2
  14. package/src/qbProxy.js +1 -1
  15. package/src/qbStrophe.js +2 -6
  16. package/strophejs-1.4.0/.eslintrc.json +264 -0
  17. package/strophejs-1.4.0/.gitattributes +1 -0
  18. package/strophejs-1.4.0/CHANGELOG.md +250 -0
  19. package/strophejs-1.4.0/LICENSE.txt +19 -0
  20. package/strophejs-1.4.0/Makefile +92 -0
  21. package/strophejs-1.4.0/README.md +45 -0
  22. package/strophejs-1.4.0/RELEASE_CHECKLIST.md +16 -0
  23. package/strophejs-1.4.0/contrib/discojs/README.txt +42 -0
  24. package/strophejs-1.4.0/contrib/discojs/css/disco.css +16 -0
  25. package/strophejs-1.4.0/contrib/discojs/index.html +47 -0
  26. package/strophejs-1.4.0/contrib/discojs/punjab.tac +18 -0
  27. package/strophejs-1.4.0/contrib/discojs/scripts/basic.js +102 -0
  28. package/strophejs-1.4.0/contrib/discojs/scripts/disco.js +60 -0
  29. package/strophejs-1.4.0/docs.css +797 -0
  30. package/strophejs-1.4.0/examples/amd.html +21 -0
  31. package/strophejs-1.4.0/examples/attach/README +37 -0
  32. package/strophejs-1.4.0/examples/attach/__init__.py +0 -0
  33. package/strophejs-1.4.0/examples/attach/attacher/__init__.py +0 -0
  34. package/strophejs-1.4.0/examples/attach/attacher/views.py +18 -0
  35. package/strophejs-1.4.0/examples/attach/boshclient.py +158 -0
  36. package/strophejs-1.4.0/examples/attach/manage.py +11 -0
  37. package/strophejs-1.4.0/examples/attach/settings.py +85 -0
  38. package/strophejs-1.4.0/examples/attach/templates/attacher/index.html +88 -0
  39. package/strophejs-1.4.0/examples/attach/urls.py +19 -0
  40. package/strophejs-1.4.0/examples/basic.html +23 -0
  41. package/strophejs-1.4.0/examples/basic.js +73 -0
  42. package/strophejs-1.4.0/examples/echobot.html +25 -0
  43. package/strophejs-1.4.0/examples/echobot.js +79 -0
  44. package/strophejs-1.4.0/examples/main.js +59 -0
  45. package/strophejs-1.4.0/examples/prebind.html +39 -0
  46. package/strophejs-1.4.0/examples/prebind.js +103 -0
  47. package/strophejs-1.4.0/examples/restore.html +24 -0
  48. package/strophejs-1.4.0/examples/restore.js +71 -0
  49. package/strophejs-1.4.0/package-lock.json +8631 -0
  50. package/strophejs-1.4.0/package.json +84 -0
  51. package/strophejs-1.4.0/rollup.config.js +76 -0
  52. package/strophejs-1.4.0/src/bosh.js +916 -0
  53. package/strophejs-1.4.0/src/core.js +3530 -0
  54. package/strophejs-1.4.0/src/md5.js +204 -0
  55. package/strophejs-1.4.0/src/sha1.js +172 -0
  56. package/strophejs-1.4.0/src/shared-connection-worker.js +114 -0
  57. package/strophejs-1.4.0/src/shims.js +123 -0
  58. package/strophejs-1.4.0/src/strophe.js +14 -0
  59. package/strophejs-1.4.0/src/utils.js +63 -0
  60. package/strophejs-1.4.0/src/websocket.js +557 -0
  61. package/strophejs-1.4.0/src/worker-websocket.js +150 -0
  62. package/strophejs-1.4.0/tests/index.html +21 -0
  63. package/strophejs-1.4.0/tests/main.js +49 -0
  64. package/strophejs-1.4.0/tests/tests.js +929 -0
  65. package/strophejs-1.6.1/.eslintrc.json +264 -0
  66. package/strophejs-1.6.1/.gitattributes +1 -0
  67. package/strophejs-1.6.1/.nvmrc +1 -0
  68. package/strophejs-1.6.1/CHANGELOG.md +288 -0
  69. package/strophejs-1.6.1/LICENSE.txt +19 -0
  70. package/strophejs-1.6.1/Makefile +92 -0
  71. package/strophejs-1.6.1/README.md +46 -0
  72. package/strophejs-1.6.1/RELEASE_CHECKLIST.md +18 -0
  73. package/strophejs-1.6.1/babel.config.json +10 -0
  74. package/strophejs-1.6.1/contrib/discojs/README.txt +42 -0
  75. package/strophejs-1.6.1/contrib/discojs/css/disco.css +16 -0
  76. package/strophejs-1.6.1/contrib/discojs/index.html +47 -0
  77. package/strophejs-1.6.1/contrib/discojs/punjab.tac +18 -0
  78. package/strophejs-1.6.1/contrib/discojs/scripts/basic.js +102 -0
  79. package/strophejs-1.6.1/contrib/discojs/scripts/disco.js +60 -0
  80. package/strophejs-1.6.1/docs.css +797 -0
  81. package/strophejs-1.6.1/examples/amd.html +21 -0
  82. package/strophejs-1.6.1/examples/attach/README +37 -0
  83. package/strophejs-1.6.1/examples/attach/__init__.py +0 -0
  84. package/strophejs-1.6.1/examples/attach/attacher/__init__.py +0 -0
  85. package/strophejs-1.6.1/examples/attach/attacher/views.py +18 -0
  86. package/strophejs-1.6.1/examples/attach/boshclient.py +158 -0
  87. package/strophejs-1.6.1/examples/attach/manage.py +11 -0
  88. package/strophejs-1.6.1/examples/attach/settings.py +85 -0
  89. package/strophejs-1.6.1/examples/attach/templates/attacher/index.html +88 -0
  90. package/strophejs-1.6.1/examples/attach/urls.py +19 -0
  91. package/strophejs-1.6.1/examples/basic.html +23 -0
  92. package/strophejs-1.6.1/examples/basic.js +73 -0
  93. package/strophejs-1.6.1/examples/echobot.html +25 -0
  94. package/strophejs-1.6.1/examples/echobot.js +79 -0
  95. package/strophejs-1.6.1/examples/main.js +59 -0
  96. package/strophejs-1.6.1/examples/prebind.html +39 -0
  97. package/strophejs-1.6.1/examples/prebind.js +103 -0
  98. package/strophejs-1.6.1/examples/restore.html +24 -0
  99. package/strophejs-1.6.1/examples/restore.js +71 -0
  100. package/strophejs-1.6.1/package-lock.json +18461 -0
  101. package/strophejs-1.6.1/package.json +87 -0
  102. package/strophejs-1.6.1/rollup.config.js +70 -0
  103. package/strophejs-1.6.1/src/bosh.js +916 -0
  104. package/strophejs-1.6.1/src/builder.js +239 -0
  105. package/strophejs-1.6.1/src/constants.js +155 -0
  106. package/strophejs-1.6.1/src/core.js +2377 -0
  107. package/strophejs-1.6.1/src/sasl-anon.js +17 -0
  108. package/strophejs-1.6.1/src/sasl-external.js +27 -0
  109. package/strophejs-1.6.1/src/sasl-oauthbearer.js +30 -0
  110. package/strophejs-1.6.1/src/sasl-plain.js +32 -0
  111. package/strophejs-1.6.1/src/sasl-sha1.js +24 -0
  112. package/strophejs-1.6.1/src/sasl-sha256.js +24 -0
  113. package/strophejs-1.6.1/src/sasl-sha384.js +24 -0
  114. package/strophejs-1.6.1/src/sasl-sha512.js +24 -0
  115. package/strophejs-1.6.1/src/sasl-xoauth2.js +27 -0
  116. package/strophejs-1.6.1/src/sasl.js +143 -0
  117. package/strophejs-1.6.1/src/scram.js +182 -0
  118. package/strophejs-1.6.1/src/shared-connection-worker.js +114 -0
  119. package/strophejs-1.6.1/src/shims.js +122 -0
  120. package/strophejs-1.6.1/src/strophe.js +15 -0
  121. package/strophejs-1.6.1/src/utils.js +626 -0
  122. package/strophejs-1.6.1/src/websocket.js +556 -0
  123. package/strophejs-1.6.1/src/worker-websocket.js +149 -0
  124. package/strophejs-1.6.1/tests.js +993 -0
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Strophe.js AMD Example</title>
5
+ <script src="../main.js"></script>
6
+ <script src="../node_modules/requirejs/require.js" data-main="main.js"></script>
7
+ </head>
8
+ <body>
9
+ <div id='login' style='text-align: center'>
10
+ <form name='cred'>
11
+ <label for='jid'>JID:</label>
12
+ <input type='text' id='jid'>
13
+ <label for='pass'>Password:</label>
14
+ <input type='password' id='pass'>
15
+ <input type='button' id='connect' value='connect'>
16
+ </form>
17
+ </div>
18
+ <hr>
19
+ <div id='log'></div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,37 @@
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.
File without changes
@@ -0,0 +1,18 @@
1
+ from django.http import HttpResponse
2
+ from django.template import Context, loader
3
+
4
+ from attach.settings import BOSH_SERVICE, JABBERID, PASSWORD
5
+ from attach.boshclient import BOSHClient
6
+
7
+ def index(request):
8
+ bc = BOSHClient(JABBERID, PASSWORD, BOSH_SERVICE)
9
+ bc.startSessionAndAuth()
10
+
11
+ t = loader.get_template("attacher/index.html")
12
+ c = Context({
13
+ 'jid': bc.jabberid.full(),
14
+ 'sid': bc.sid,
15
+ 'rid': bc.rid,
16
+ })
17
+
18
+ return HttpResponse(t.render(c))
@@ -0,0 +1,158 @@
1
+ import sys, os
2
+ import httplib, urllib
3
+ import random, binascii
4
+ from urlparse import urlparse
5
+
6
+ from punjab.httpb import HttpbParse
7
+
8
+ from twisted.words.xish import domish
9
+ from twisted.words.protocols.jabber import jid
10
+
11
+ TLS_XMLNS = 'urn:ietf:params:xml:ns:xmpp-tls'
12
+ SASL_XMLNS = 'urn:ietf:params:xml:ns:xmpp-sasl'
13
+ BIND_XMLNS = 'urn:ietf:params:xml:ns:xmpp-bind'
14
+ SESSION_XMLNS = 'urn:ietf:params:xml:ns:xmpp-session'
15
+
16
+
17
+ class BOSHClient:
18
+ def __init__(self, jabberid, password, bosh_service):
19
+ self.rid = random.randint(0, 10000000)
20
+ self.jabberid = jid.internJID(jabberid)
21
+ self.password = password
22
+
23
+ self.authid = None
24
+ self.sid = None
25
+ self.logged_in = False
26
+ self.headers = {"Content-type": "text/xml",
27
+ "Accept": "text/xml"}
28
+
29
+ self.bosh_service = urlparse(bosh_service)
30
+
31
+ def buildBody(self, child=None):
32
+ """Build a BOSH body.
33
+ """
34
+
35
+ body = domish.Element(("http://jabber.org/protocol/httpbind", "body"))
36
+ body['content'] = 'text/xml; charset=utf-8'
37
+ self.rid = self.rid + 1
38
+ body['rid'] = str(self.rid)
39
+ body['sid'] = str(self.sid)
40
+ body['xml:lang'] = 'en'
41
+
42
+ if child is not None:
43
+ body.addChild(child)
44
+
45
+ return body
46
+
47
+ def sendBody(self, body):
48
+ """Send the body.
49
+ """
50
+
51
+ parser = HttpbParse(True)
52
+
53
+ # start new session
54
+ conn = httplib.HTTPConnection(self.bosh_service.netloc)
55
+ conn.request("POST", self.bosh_service.path,
56
+ body.toXml(), self.headers)
57
+
58
+ response = conn.getresponse()
59
+ data = ''
60
+ if response.status == 200:
61
+ data = response.read()
62
+ conn.close()
63
+
64
+ return parser.parse(data)
65
+
66
+ def startSessionAndAuth(self, hold='1', wait='70'):
67
+ # Create a session
68
+ # create body
69
+ body = domish.Element(("http://jabber.org/protocol/httpbind", "body"))
70
+
71
+ body['content'] = 'text/xml; charset=utf-8'
72
+ body['hold'] = hold
73
+ body['rid'] = str(self.rid)
74
+ body['to'] = self.jabberid.host
75
+ body['wait'] = wait
76
+ body['window'] = '5'
77
+ body['xml:lang'] = 'en'
78
+
79
+
80
+ retb, elems = self.sendBody(body)
81
+ if type(retb) != str and retb.hasAttribute('authid') and \
82
+ retb.hasAttribute('sid'):
83
+ self.authid = retb['authid']
84
+ self.sid = retb['sid']
85
+
86
+ # go ahead and auth
87
+ auth = domish.Element((SASL_XMLNS, 'auth'))
88
+ auth['mechanism'] = 'PLAIN'
89
+
90
+ # TODO: add authzid
91
+ if auth['mechanism'] == 'PLAIN':
92
+ auth_str = ""
93
+ auth_str += "\000"
94
+ auth_str += self.jabberid.user.encode('utf-8')
95
+ auth_str += "\000"
96
+ try:
97
+ auth_str += self.password.encode('utf-8').strip()
98
+ except UnicodeDecodeError:
99
+ auth_str += self.password.decode('latin1') \
100
+ .encode('utf-8').strip()
101
+
102
+ auth.addContent(binascii.b2a_base64(auth_str))
103
+
104
+ retb, elems = self.sendBody(self.buildBody(auth))
105
+ if len(elems) == 0:
106
+ # poll for data
107
+ retb, elems = self.sendBody(self.buildBody())
108
+
109
+ if len(elems) > 0:
110
+ if elems[0].name == 'success':
111
+ retb, elems = self.sendBody(self.buildBody())
112
+
113
+ has_bind = False
114
+ for child in elems[0].children:
115
+ if child.name == 'bind':
116
+ has_bind = True
117
+ break
118
+
119
+ if has_bind:
120
+ iq = domish.Element(('jabber:client', 'iq'))
121
+ iq['type'] = 'set'
122
+ iq.addUniqueId()
123
+ iq.addElement('bind')
124
+ iq.bind['xmlns'] = BIND_XMLNS
125
+ if self.jabberid.resource:
126
+ iq.bind.addElement('resource')
127
+ iq.bind.resource.addContent(
128
+ self.jabberid.resource)
129
+
130
+ retb, elems = self.sendBody(self.buildBody(iq))
131
+ if type(retb) != str and retb.name == 'body':
132
+ # send session
133
+ iq = domish.Element(('jabber:client', 'iq'))
134
+ iq['type'] = 'set'
135
+ iq.addUniqueId()
136
+ iq.addElement('session')
137
+ iq.session['xmlns'] = SESSION_XMLNS
138
+
139
+ retb, elems = self.sendBody(self.buildBody(iq))
140
+
141
+ # did not bind, TODO - add a retry?
142
+ if type(retb) != str and retb.name == 'body':
143
+ self.logged_in = True
144
+ # bump up the rid, punjab already
145
+ # received self.rid
146
+ self.rid += 1
147
+
148
+
149
+ if __name__ == '__main__':
150
+ USERNAME = sys.argv[1]
151
+ PASSWORD = sys.argv[2]
152
+ SERVICE = sys.argv[3]
153
+
154
+ c = BOSHClient(USERNAME, PASSWORD, SERVICE)
155
+ c.startSessionAndAuth()
156
+
157
+ print c.logged_in
158
+
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python
2
+ from django.core.management import execute_manager
3
+ try:
4
+ import settings # Assumed to be in the same directory.
5
+ except ImportError:
6
+ import sys
7
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
8
+ sys.exit(1)
9
+
10
+ if __name__ == "__main__":
11
+ execute_manager(settings)
@@ -0,0 +1,85 @@
1
+ # Django settings for attach project.
2
+
3
+ DEBUG = True
4
+ TEMPLATE_DEBUG = DEBUG
5
+
6
+ ADMINS = (
7
+ ('Some Body', 'romeo@example.com'),
8
+ )
9
+
10
+ MANAGERS = ADMINS
11
+
12
+ DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
13
+ DATABASE_NAME = '/path/to/attach.db' # Or path to database file if using sqlite3.
14
+ DATABASE_USER = '' # Not used with sqlite3.
15
+ DATABASE_PASSWORD = '' # Not used with sqlite3.
16
+ DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
17
+ DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
18
+
19
+ # Local time zone for this installation. Choices can be found here:
20
+ # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
21
+ # although not all choices may be available on all operating systems.
22
+ # If running in a Windows environment this must be set to the same as your
23
+ # system time zone.
24
+ TIME_ZONE = 'America/Denver'
25
+
26
+ # Language code for this installation. All choices can be found here:
27
+ # http://www.i18nguy.com/unicode/language-identifiers.html
28
+ LANGUAGE_CODE = 'en-us'
29
+
30
+ SITE_ID = 1
31
+
32
+ # If you set this to False, Django will make some optimizations so as not
33
+ # to load the internationalization machinery.
34
+ USE_I18N = True
35
+
36
+ # Absolute path to the directory that holds media.
37
+ # Example: "/home/media/media.lawrence.com/"
38
+ MEDIA_ROOT = ''
39
+
40
+ # URL that handles the media served from MEDIA_ROOT. Make sure to use a
41
+ # trailing slash if there is a path component (optional in other cases).
42
+ # Examples: "http://media.lawrence.com", "http://example.com/media/"
43
+ MEDIA_URL = ''
44
+
45
+ # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
46
+ # trailing slash.
47
+ # Examples: "http://foo.com/media/", "/media/".
48
+ ADMIN_MEDIA_PREFIX = '/media/'
49
+
50
+ # Make this unique, and don't share it with anybody.
51
+ SECRET_KEY = 'asdf'
52
+
53
+ # List of callables that know how to import templates from various sources.
54
+ TEMPLATE_LOADERS = (
55
+ 'django.template.loaders.filesystem.load_template_source',
56
+ 'django.template.loaders.app_directories.load_template_source',
57
+ # 'django.template.loaders.eggs.load_template_source',
58
+ )
59
+
60
+ MIDDLEWARE_CLASSES = (
61
+ 'django.middleware.common.CommonMiddleware',
62
+ 'django.contrib.sessions.middleware.SessionMiddleware',
63
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
64
+ )
65
+
66
+ ROOT_URLCONF = 'attach.urls'
67
+
68
+ TEMPLATE_DIRS = (
69
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
70
+ # Always use forward slashes, even on Windows.
71
+ # Don't forget to use absolute paths, not relative paths.
72
+ '/path/to/attach/templates',
73
+ )
74
+
75
+ INSTALLED_APPS = (
76
+ 'django.contrib.auth',
77
+ 'django.contrib.contenttypes',
78
+ 'django.contrib.sessions',
79
+ 'django.contrib.sites',
80
+ 'attach.attacher',
81
+ )
82
+
83
+ BOSH_SERVICE = 'http://example.com/xmpp-httpbind'
84
+ JABBERID = 'romeo@example.com/bosh'
85
+ PASSWORD = 'juliet.is.hawt'
@@ -0,0 +1,88 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Strophe Attach Example</title>
5
+ <script language='javascript'
6
+ type='text/javascript'
7
+ src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
8
+ <script language='javascript'
9
+ type='text/javascript'
10
+ src='http://code.stanziq.com/svn/strophe/trunk/strophejs/b64.js'></script>
11
+ <script language='javascript'
12
+ type='text/javascript'
13
+ src='http://code.stanziq.com/svn/strophe/trunk/strophejs/md5.js'></script>
14
+ <script language='javascript'
15
+ type='text/javascript'
16
+ src='http://code.stanziq.com/svn/strophe/trunk/strophejs/sha1.js'></script>
17
+ <script language='javascript'
18
+ type='text/javascript'
19
+ src='http://code.stanziq.com/svn/strophe/trunk/strophejs/strophe.js'></script>
20
+ <script language='javascript'
21
+ type='text/javascript'>
22
+ <!--
23
+ var ATTACH_SID = "{{ sid }}";
24
+ var ATTACH_RID = "{{ rid }}";
25
+ var ATTACH_JID = "{{ jid }}";
26
+ var BOSH_SERVICE = '/xmpp-httpbind';
27
+ var connection = null;
28
+ var startTime = null;
29
+
30
+ function log(msg)
31
+ {
32
+ $('#log').append('<div></div>').append(
33
+ document.createTextNode(msg));
34
+ }
35
+
36
+ function onConnect(status)
37
+ {
38
+ if (status == Strophe.Status.DISCONNECTED)
39
+ log('Disconnected.');
40
+ }
41
+
42
+ function onResult(iq) {
43
+ var elapsed = (new Date()) - startTime;
44
+ log('Response from jabber.org took ' + elapsed + 'ms.');
45
+ }
46
+
47
+ $(document).ready(function () {
48
+ // create the connection and attach it
49
+ connection = new Strophe.Connection(BOSH_SERVICE);
50
+ connection.rawInput = function (data) {
51
+ log('RECV: ' + data);
52
+ };
53
+ connection.rawOutput = function (data) {
54
+ log('SENT: ' + data);
55
+ };
56
+ // uncomment for extra debugging
57
+ // Strophe.log = function (lvl, msg) { log(msg); };
58
+ connection.attach(ATTACH_JID, ATTACH_SID, ATTACH_RID,
59
+ onConnect);
60
+
61
+ // set up handler
62
+ connection.addHandler(onResult, null, 'iq',
63
+ 'result', 'disco-1', null);
64
+
65
+ log('Strophe is attached.');
66
+
67
+ // send disco#info to jabber.org
68
+ var iq = $iq({to: 'jabber.org',
69
+ type: 'get',
70
+ id: 'disco-1'})
71
+ .c('query', {xmlns: Strophe.NS.DISCO_INFO})
72
+ .tree()
73
+
74
+ startTime = new Date();
75
+ connection.send(iq);
76
+ });
77
+ // -->
78
+ </script>
79
+ </head>
80
+ <body>
81
+ <h1>Strophe Attach Example</h1>
82
+ <p>This example shows how to attach to an existing BOSH session with
83
+ Strophe.</p>
84
+ <h2>Log</h2>
85
+ <div id='log'>
86
+ </div>
87
+ </body>
88
+ </html>
@@ -0,0 +1,19 @@
1
+ from django.conf.urls.defaults import *
2
+
3
+ # Uncomment the next two lines to enable the admin:
4
+ # from django.contrib import admin
5
+ # admin.autodiscover()
6
+
7
+ urlpatterns = patterns('',
8
+ # Example:
9
+ # (r'^attach/', include('attach.foo.urls')),
10
+
11
+ # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
12
+ # to INSTALLED_APPS to enable admin documentation:
13
+ # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
14
+
15
+ # Uncomment the next line to enable the admin:
16
+ # (r'^admin/(.*)', admin.site.root),
17
+
18
+ (r'^$', 'attach.attacher.views.index'),
19
+ )
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Strophe.js Basic Example</title>
5
+ </head>
6
+ <body>
7
+ <div id='login' style='text-align: center'>
8
+ <form name='cred'>
9
+ <label for='jid'>JID:</label>
10
+ <input type='text' id='jid'>
11
+ <label for='pass'>Password:</label>
12
+ <input type='password' id='pass'>
13
+ <input type='button' id='connect' value='connect'>
14
+ </form>
15
+ </div>
16
+ <hr>
17
+ <table id='log'></table>
18
+ <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
19
+ <script src='../dist/strophe.js'></script>
20
+ <script src='https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/vkbeautify/vkbeautify.0.99.00.beta.js'></script>
21
+ <script src='basic.js'></script>
22
+ </body>
23
+ </html>
@@ -0,0 +1,73 @@
1
+ var BOSH_SERVICE = 'http://bosh.metajack.im:5280/xmpp-httpbind';
2
+ var connection = null;
3
+
4
+ function log(msg, data) {
5
+ var tr = document.createElement('tr');
6
+ var th = document.createElement('th');
7
+ th.setAttribute( "style", "text-align: left; vertical-align: top;" );
8
+ var td;
9
+
10
+ th.appendChild( document.createTextNode(msg) );
11
+ tr.appendChild( th );
12
+
13
+ if (data) {
14
+ td = document.createElement('td');
15
+ pre = document.createElement('code');
16
+ pre.setAttribute("style", "white-space: pre-wrap;");
17
+ td.appendChild(pre);
18
+ pre.appendChild( document.createTextNode( vkbeautify.xml(data) ) );
19
+ tr.appendChild(td);
20
+ } else {
21
+ th.setAttribute('colspan', '2');
22
+ }
23
+
24
+ $('#log').append(tr);
25
+ }
26
+
27
+ function rawInput(data)
28
+ {
29
+ log('RECV', data);
30
+ }
31
+
32
+ function rawOutput(data)
33
+ {
34
+ log('SENT', data);
35
+ }
36
+
37
+ function onConnect(status)
38
+ {
39
+ if (status == Strophe.Status.CONNECTING) {
40
+ log('Strophe is connecting.');
41
+ } else if (status == Strophe.Status.CONNFAIL) {
42
+ log('Strophe failed to connect.');
43
+ $('#connect').get(0).value = 'connect';
44
+ } else if (status == Strophe.Status.DISCONNECTING) {
45
+ log('Strophe is disconnecting.');
46
+ } else if (status == Strophe.Status.DISCONNECTED) {
47
+ log('Strophe is disconnected.');
48
+ $('#connect').get(0).value = 'connect';
49
+ } else if (status == Strophe.Status.CONNECTED) {
50
+ log('Strophe is connected.');
51
+ connection.disconnect();
52
+ }
53
+ }
54
+
55
+ $(document).ready(function () {
56
+ connection = new Strophe.Connection(BOSH_SERVICE);
57
+ connection.rawInput = rawInput;
58
+ connection.rawOutput = rawOutput;
59
+
60
+ $('#connect').bind('click', function () {
61
+ var button = $('#connect').get(0);
62
+ if (button.value == 'connect') {
63
+ button.value = 'disconnect';
64
+
65
+ connection.connect($('#jid').get(0).value,
66
+ $('#pass').get(0).value,
67
+ onConnect);
68
+ } else {
69
+ button.value = 'connect';
70
+ connection.disconnect();
71
+ }
72
+ });
73
+ });
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>Strophe.js Echobot Example</title>
5
+ <script type='text/javascript'
6
+ src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
7
+ <script type='text/javascript'
8
+ src='../strophe.js'></script>
9
+ <script type='text/javascript'
10
+ src='echobot.js'></script>
11
+ </head>
12
+ <body>
13
+ <div id='login' style='text-align: center'>
14
+ <form name='cred'>
15
+ <label for='jid'>JID:</label>
16
+ <input type='text' id='jid' />
17
+ <label for='pass'>Password:</label>
18
+ <input type='password' id='pass' />
19
+ <input type='button' id='connect' value='connect' />
20
+ </form>
21
+ </div>
22
+ <hr />
23
+ <div id='log'></div>
24
+ </body>
25
+ </html>
@@ -0,0 +1,79 @@
1
+ var BOSH_SERVICE = '/xmpp-httpbind';
2
+ var connection = null;
3
+
4
+ function log(msg)
5
+ {
6
+ $('#log').append('<div></div>').append(document.createTextNode(msg));
7
+ }
8
+
9
+ function onConnect(status)
10
+ {
11
+ if (status == Strophe.Status.CONNECTING) {
12
+ log('Strophe is connecting.');
13
+ } else if (status == Strophe.Status.CONNFAIL) {
14
+ log('Strophe failed to connect.');
15
+ $('#connect').get(0).value = 'connect';
16
+ } else if (status == Strophe.Status.DISCONNECTING) {
17
+ log('Strophe is disconnecting.');
18
+ } else if (status == Strophe.Status.DISCONNECTED) {
19
+ log('Strophe is disconnected.');
20
+ $('#connect').get(0).value = 'connect';
21
+ } else if (status == Strophe.Status.CONNECTED) {
22
+ log('Strophe is connected.');
23
+ log('ECHOBOT: Send a message to ' + connection.jid +
24
+ ' to talk to me.');
25
+
26
+ connection.addHandler(onMessage, null, 'message', null, null, null);
27
+ connection.send($pres().tree());
28
+ }
29
+ }
30
+
31
+ function onMessage(msg) {
32
+ var to = msg.getAttribute('to');
33
+ var from = msg.getAttribute('from');
34
+ var type = msg.getAttribute('type');
35
+ var elems = msg.getElementsByTagName('body');
36
+
37
+ if (type == "chat" && elems.length > 0) {
38
+ var body = elems[0];
39
+
40
+ log('ECHOBOT: I got a message from ' + from + ': ' +
41
+ Strophe.getText(body));
42
+
43
+ var reply = $msg({to: from, from: to, type: 'chat'})
44
+ .cnode(Strophe.copyElement(body));
45
+ connection.send(reply.tree());
46
+
47
+ log('ECHOBOT: I sent ' + from + ': ' + Strophe.getText(body));
48
+ }
49
+
50
+ // we must return true to keep the handler alive.
51
+ // returning false would remove it after it finishes.
52
+ return true;
53
+ }
54
+
55
+ $(document).ready(function () {
56
+ connection = new Strophe.Connection(BOSH_SERVICE);
57
+
58
+ // Uncomment the following lines to spy on the wire traffic.
59
+ //connection.rawInput = function (data) { log('RECV: ' + data); };
60
+ //connection.rawOutput = function (data) { log('SEND: ' + data); };
61
+
62
+ // Uncomment the following line to see all the debug output.
63
+ //Strophe.log = function (level, msg) { log('LOG: ' + msg); };
64
+
65
+
66
+ $('#connect').bind('click', function () {
67
+ var button = $('#connect').get(0);
68
+ if (button.value == 'connect') {
69
+ button.value = 'disconnect';
70
+
71
+ connection.connect($('#jid').get(0).value,
72
+ $('#pass').get(0).value,
73
+ onConnect);
74
+ } else {
75
+ button.value = 'connect';
76
+ connection.disconnect();
77
+ }
78
+ });
79
+ });