1
1
# YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
2
2
Create an account at http://www.pubnub.com/account
3
3
4
- ## The PubNub Network JavaScript Real-time SDK v3.5.0
4
+ ## The PubNub Network JavaScript Real-time SDK v3.5.1
5
5
http://www.pubnub.com - PubNub Real-time Push Service in the Cloud.
6
6
7
7
The PubNub Network is a blazingly fast Global Messaging Service for building
@@ -16,7 +16,7 @@ business collaborative solutions, and more.
16
16
You may access the latest PubNub JavaScript SDK on The PubNub Network CDN.
17
17
18
18
``` html
19
- <script src =http://cdn.pubnub.com/pubnub-3.5.0 .min.js ></script >
19
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1 .min.js ></script >
20
20
<script >(function (){
21
21
var pubnub = PUBNUB .init ({
22
22
publish_key : ' demo' ,
@@ -34,7 +34,7 @@ and for security considerations,
34
34
use this following method for initialization:
35
35
36
36
``` html
37
- <script src =http://cdn.pubnub.com/pubnub-3.5.0 .min.js ></script >
37
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1 .min.js ></script >
38
38
<script >(function (){
39
39
40
40
var pubnub = PUBNUB .init ({ subscribe_key : ' demo' });
@@ -145,7 +145,7 @@ JavaScript SDK using the **web** build. It's as easy as `copy/paste`.
145
145
146
146
``` html
147
147
<div id =pubnub pub-key =demo sub-key =demo ></div >
148
- <script src =http://cdn.pubnub.com/pubnub-3.5.0 .min.js ></script >
148
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1 .min.js ></script >
149
149
<script >
150
150
151
151
// LISTEN
@@ -169,11 +169,11 @@ JavaScript SDK using the **web** build. It's as easy as `copy/paste`.
169
169
## ADVANCED SUBSCRIBE CONNECTIVITY OPTIONS/CALLBACKS
170
170
``` html
171
171
<div id =pubnub pub-key =demo sub-key =demo ></div >
172
- <script src =http://cdn.pubnub.com/pubnub-3.5.0 .min.js ></script >
172
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1 .min.js ></script >
173
173
<script >(function (){
174
174
PUBNUB .subscribe ({
175
175
channel : " hello_world" , // CONNECT TO THIS CHANNEL.
176
- restore : false , // FETCH MISSED MESSAGES ON PAGE CHANGES.
176
+ restore : true , // FETCH MISSED MESSAGES ON PAGE CHANGES.
177
177
message : function ( message , env , channel ) {}, // RECEIVED A MESSAGE.
178
178
presence : function ( message , env , channel ) {}, // OTHER USERS JOIN/LEFT CHANNEL.
179
179
connect : function () {}, // CONNECTION ESTABLISHED.
@@ -184,6 +184,29 @@ JavaScript SDK using the **web** build. It's as easy as `copy/paste`.
184
184
</script >
185
185
```
186
186
187
+ ## CAPTURING ERRORS FOR DEBUGGING
188
+
189
+ Sometimes an error will occur and you may wish to log it.
190
+ Note that the PubNub JavaScript SDK auto-recovers connections
191
+ upon error so it is not necessary to act upon errors
192
+ when ** receiving messages** .
193
+
194
+ ``` html
195
+ <div id =pubnub pub-key =demo sub-key =demo ></div >
196
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1.min.js ></script >
197
+ <script >(function (){
198
+ PUBNUB .subscribe ({
199
+ channel : " hello_world" , // CONNECT TO THIS CHANNEL.
200
+ message : function ( message , env , channel ) {}, // RECEIVED A MESSAGE.
201
+ error : function (data ) { console .log (data) } // CONNECTION BACK ONLINE!
202
+ })
203
+ })();
204
+ </script >
205
+ ```
206
+
207
+ > ** Note:** the ` error ` callback is being used.
208
+
209
+
187
210
## FULL MULTIPLEXING (Single TCP Socket)
188
211
189
212
> Multiplexing enhances mobile performance and battery savings.
@@ -276,8 +299,8 @@ are open source, you’re welcome to see how we did it).
276
299
To use AES encryption in PubNub, simply do the following:
277
300
278
301
``` html
279
- <script src =https://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js ></script >
280
- <script src =https://pubnub.a.ssl.fastly.net/pubnub-crypto-3.5.0 .min.js ></script >
302
+ <script src =https://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js ></script >
303
+ <script src =https://pubnub.a.ssl.fastly.net/pubnub-crypto-3.5.1 .min.js ></script >
281
304
<script >(function (){
282
305
var secure_pubnub = PUBNUB .secure ({
283
306
publish_key : ' demo' ,
@@ -342,7 +365,7 @@ To use AES encryption in PubNub, simply do the following:
342
365
## SSL MODE
343
366
``` html
344
367
<div id =pubnub ssl =on ></div >
345
- <script src =https://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js ></script >
368
+ <script src =https://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js ></script >
346
369
<script >(function (){
347
370
348
371
var pubnub = PUBNUB .init ({
@@ -366,7 +389,7 @@ To use AES encryption in PubNub, simply do the following:
366
389
## HISTORY
367
390
``` html
368
391
<div id =pubnub ></div >
369
- <script src =http://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js ></script >
392
+ <script src =http://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js ></script >
370
393
<script >(function (){
371
394
372
395
var pubnub = PUBNUB .init ({
@@ -395,7 +418,7 @@ the timeline as they occured.
395
418
396
419
``` html
397
420
<div id =pubnub ></div >
398
- <script src =http://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js ></script >
421
+ <script src =http://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js ></script >
399
422
<script >(function (){
400
423
401
424
/* GENERATE CHANNEL */
@@ -432,7 +455,7 @@ and get back an answer with list of users and the occupancy count.
432
455
433
456
``` html
434
457
<div id =pubnub pub-key =demo sub-key =demo ></div >
435
- <script src =http://cdn.pubnub.com/pubnub-3.5.0 .min.js ></script >
458
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1 .min.js ></script >
436
459
<script >(function (){
437
460
PUBNUB .subscribe ({
438
461
channel : " hello_world" , // CONNECT TO THIS CHANNEL.
@@ -474,7 +497,7 @@ the `pubnub.subscribe` call below.
474
497
475
498
``` html
476
499
<div id =pubnub ></div >
477
- <script src =http://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js ></script >
500
+ <script src =http://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js ></script >
478
501
<script >(function (){
479
502
480
503
var pubnub = PUBNUB .init ({
@@ -524,7 +547,7 @@ The following example opens a `new WebSocket` in
524
547
525
548
``` html
526
549
<!-- Import PubNub Core Lib -->
527
- <script src =" https://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js" ></script >
550
+ <script src =" https://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js" ></script >
528
551
529
552
<!-- Use WebSocket Constructor for a New Socket Connection -->
530
553
<script >(function () {
@@ -572,7 +595,7 @@ The following example opens a `new WebSocket` in
572
595
573
596
``` html
574
597
<!-- NON-SSL Import PubNub Core Lib -->
575
- <script src =" http://pubnub.a.ssl.fastly.net/pubnub-3.5.0 .min.js" ></script >
598
+ <script src =" http://pubnub.a.ssl.fastly.net/pubnub-3.5.1 .min.js" ></script >
576
599
577
600
<!-- NON-SSL Use WebSocket Constructor for a New Socket Connection -->
578
601
<script >(function () {
@@ -589,7 +612,7 @@ How to create a new instance of the PubNub Object directly in JavaScript.
589
612
To do this, simply follow this ` init ` example:
590
613
591
614
``` html
592
- <script src =http://cdn.pubnub.com/pubnub-3.5.0 .min.js ></script >
615
+ <script src =http://cdn.pubnub.com/pubnub-3.5.1 .min.js ></script >
593
616
<script >(function (){
594
617
595
618
// INIT PubNub
0 commit comments