Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
f98357ed
Commit
f98357ed
authored
Sep 22, 2013
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve js disconnect method and tests
parent
cc6a0d89
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
pushstream.js
misc/js/pushstream.js
+4
-5
PushStreamSpec.js
misc/spec/javascripts/PushStreamSpec.js
+23
-1
No files found.
misc/js/pushstream.js
View file @
f98357ed
...
...
@@ -510,6 +510,7 @@
disconnect
:
function
()
{
if
(
this
.
connection
)
{
Log4js
.
debug
(
"
[EventSource] closing connection to:
"
,
this
.
connection
.
URL
);
this
.
connection
.
onclose
=
null
;
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onclose
();
}
...
...
@@ -562,6 +563,7 @@
var
oldIframe
=
document
.
getElementById
(
this
.
iframeId
);
if
(
oldIframe
)
{
oldIframe
.
onload
=
null
;
oldIframe
.
src
=
"
about:blank
"
;
if
(
oldIframe
.
parentNode
)
{
oldIframe
.
parentNode
.
removeChild
(
oldIframe
);
}
}
},
...
...
@@ -644,7 +646,6 @@
this
.
connection
=
null
;
this
.
lastModified
=
null
;
this
.
etag
=
0
;
this
.
connectionEnabled
=
false
;
this
.
opentimer
=
null
;
this
.
messagesQueue
=
[];
this
.
_linkedInternalListen
=
linker
(
this
.
_internalListen
,
this
);
...
...
@@ -667,7 +668,6 @@
connect
:
function
()
{
this
.
messagesQueue
=
[];
this
.
_closeCurrentConnection
();
this
.
connectionEnabled
=
true
;
this
.
xhrSettings
.
url
=
getSubscriberUrl
(
this
.
pushstream
,
this
.
pushstream
.
urlPrefixLongpolling
);
var
domain
=
Utils
.
extract_xss_domain
(
this
.
pushstream
.
host
);
var
currentDomain
=
Utils
.
extract_xss_domain
(
window
.
location
.
hostname
);
...
...
@@ -689,7 +689,7 @@
},
_internalListen
:
function
()
{
if
(
this
.
connectionEnabl
ed
)
{
if
(
this
.
pushstream
.
_keepConnect
ed
)
{
this
.
xhrSettings
.
data
=
extend
({},
this
.
pushstream
.
extraParams
(),
this
.
xhrSettings
.
data
);
if
(
this
.
useJSONP
)
{
this
.
connection
=
Ajax
.
jsonp
(
this
.
xhrSettings
);
...
...
@@ -700,7 +700,6 @@
},
disconnect
:
function
()
{
this
.
connectionEnabled
=
false
;
if
(
this
.
connection
)
{
Log4js
.
debug
(
"
[LongPolling] closing connection to:
"
,
this
.
xhrSettings
.
url
);
this
.
_closeCurrentConnection
();
...
...
@@ -749,7 +748,7 @@
},
onerror
:
function
(
status
)
{
if
(
this
.
connectionEnabl
ed
)
{
/* abort(), called by disconnect(), call this callback, but should be ignored */
if
(
this
.
pushstream
.
_keepConnect
ed
)
{
/* abort(), called by disconnect(), call this callback, but should be ignored */
if
(
status
===
304
)
{
this
.
_listen
();
}
else
{
...
...
misc/spec/javascripts/PushStreamSpec.js
View file @
f98357ed
...
...
@@ -301,6 +301,14 @@ describe("PushStream", function() {
runs
(
function
()
{
expect
(
status
).
toEqual
([
PushStream
.
CONNECTING
,
PushStream
.
OPEN
]);
setTimeout
(
function
()
{
$
.
ajax
({
url
:
"
http://
"
+
nginxServer
+
"
/pub?id=
"
+
channelName
,
success
:
function
(
data
)
{
expect
(
data
.
subscribers
).
toBe
(
"
1
"
);
}
});
},
1000
);
});
});
});
...
...
@@ -352,7 +360,13 @@ describe("PushStream", function() {
pushstream
.
connect
();
setTimeout
(
function
()
{
pushstream
.
disconnect
();
$
.
ajax
({
url
:
"
http://
"
+
nginxServer
+
"
/pub?id=
"
+
channelName
,
success
:
function
(
data
)
{
expect
(
data
.
subscribers
).
toBe
(
"
1
"
);
pushstream
.
disconnect
();
}
});
},
500
);
});
...
...
@@ -362,6 +376,14 @@ describe("PushStream", function() {
runs
(
function
()
{
expect
(
pushstream
.
readyState
).
toBe
(
PushStream
.
CLOSED
);
setTimeout
(
function
()
{
$
.
ajax
({
url
:
"
http://
"
+
nginxServer
+
"
/pub?id=
"
+
channelName
,
success
:
function
(
data
)
{
expect
(
data
.
subscribers
).
toBe
(
"
0
"
);
}
});
},
3000
);
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment