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
ea485a7a
Commit
ea485a7a
authored
Nov 12, 2012
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing jshint gem by jshintrb, and making some adjusts suggested by new gem
parent
28d9df7a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
150 deletions
+72
-150
pushstream.js
misc/js/pushstream.js
+52
-50
Gemfile
test/Gemfile
+2
-1
Gemfile.lock
test/Gemfile.lock
+12
-2
Rakefile
test/Rakefile
+6
-6
jshint.yml
test/spec/javascripts/support/jshint.yml
+0
-91
No files found.
misc/js/pushstream.js
View file @
ea485a7a
/*global PushStream WebSocketWrapper EventSourceWrapper EventSource*/
/*global PushStream WebSocketWrapper EventSourceWrapper EventSource*/
/*jshint evil: true */
/*jshint evil: true
, plusplus: false, regexp: false
*/
/**
/**
* Copyright (C) 2010-2012 Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider <stockrt@gmail.com>
* Copyright (C) 2010-2012 Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider <stockrt@gmail.com>
*
*
...
@@ -25,12 +25,14 @@
...
@@ -25,12 +25,14 @@
* Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider <stockrt@gmail.com>
* Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider <stockrt@gmail.com>
*/
*/
(
function
(
window
,
undefined
)
{
(
function
(
window
,
undefined
)
{
"
use strict
"
;
/* prevent duplicate declaration */
/* prevent duplicate declaration */
if
(
window
.
PushStream
)
{
return
;
}
if
(
window
.
PushStream
)
{
return
;
}
var
extend
=
function
()
{
var
extend
=
function
()
{
var
object
=
arguments
[
0
]
||
{};
var
object
=
arguments
[
0
]
||
{};
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
var
settings
=
arguments
[
i
];
var
settings
=
arguments
[
i
];
for
(
var
attr
in
settings
)
{
for
(
var
attr
in
settings
)
{
if
(
!
settings
.
hasOwnProperty
||
settings
.
hasOwnProperty
(
attr
))
{
if
(
!
settings
.
hasOwnProperty
||
settings
.
hasOwnProperty
(
attr
))
{
...
@@ -100,17 +102,17 @@
...
@@ -100,17 +102,17 @@
};
};
var
isArray
=
Array
.
isArray
||
function
(
obj
)
{
var
isArray
=
Array
.
isArray
||
function
(
obj
)
{
return
Object
.
prototype
.
toString
.
call
(
obj
)
==
'
[object Array]
'
;
return
Object
.
prototype
.
toString
.
call
(
obj
)
==
=
'
[object Array]
'
;
};
};
var
isString
=
function
(
obj
)
{
var
isString
=
function
(
obj
)
{
return
Object
.
prototype
.
toString
.
call
(
obj
)
==
'
[object String]
'
;
return
Object
.
prototype
.
toString
.
call
(
obj
)
==
=
'
[object String]
'
;
};
};
var
Log4js
=
{
var
Log4js
=
{
logger
:
null
,
logger
:
null
,
debug
:
function
()
{
if
(
PushStream
.
LOG_LEVEL
===
'
debug
'
)
Log4js
.
_log
.
apply
(
Log4js
.
_log
,
arguments
);
},
debug
:
function
()
{
if
(
PushStream
.
LOG_LEVEL
===
'
debug
'
)
{
Log4js
.
_log
.
apply
(
Log4js
.
_log
,
arguments
);
}
},
info
:
function
()
{
if
((
PushStream
.
LOG_LEVEL
===
'
info
'
)
||
(
PushStream
.
LOG_LEVEL
===
'
debug
'
))
Log4js
.
_log
.
apply
(
Log4js
.
_log
,
arguments
);
},
info
:
function
()
{
if
((
PushStream
.
LOG_LEVEL
===
'
info
'
)
||
(
PushStream
.
LOG_LEVEL
===
'
debug
'
))
{
Log4js
.
_log
.
apply
(
Log4js
.
_log
,
arguments
);
}
},
error
:
function
()
{
Log4js
.
_log
.
apply
(
Log4js
.
_log
,
arguments
);
},
error
:
function
()
{
Log4js
.
_log
.
apply
(
Log4js
.
_log
,
arguments
);
},
_log
:
function
()
{
_log
:
function
()
{
if
(
!
Log4js
.
logger
)
{
if
(
!
Log4js
.
logger
)
{
...
@@ -118,12 +120,12 @@
...
@@ -118,12 +120,12 @@
if
(
console
&&
console
.
log
)
{
if
(
console
&&
console
.
log
)
{
if
(
console
.
log
.
apply
)
{
if
(
console
.
log
.
apply
)
{
Log4js
.
logger
=
console
.
log
;
Log4js
.
logger
=
console
.
log
;
}
else
if
((
typeof
console
.
log
==
"
object
"
)
&&
Function
.
prototype
.
bind
)
{
}
else
if
((
typeof
console
.
log
==
=
"
object
"
)
&&
Function
.
prototype
.
bind
)
{
Log4js
.
logger
=
Function
.
prototype
.
bind
.
call
(
console
.
log
,
console
);
Log4js
.
logger
=
Function
.
prototype
.
bind
.
call
(
console
.
log
,
console
);
}
else
if
((
typeof
console
.
log
==
"
object
"
)
&&
Function
.
prototype
.
call
)
{
}
else
if
((
typeof
console
.
log
==
=
"
object
"
)
&&
Function
.
prototype
.
call
)
{
Log4js
.
logger
=
function
()
{
Log4js
.
logger
=
function
()
{
Function
.
prototype
.
call
.
call
(
console
.
log
,
console
,
Array
.
prototype
.
slice
.
call
(
arguments
));
Function
.
prototype
.
call
.
call
(
console
.
log
,
console
,
Array
.
prototype
.
slice
.
call
(
arguments
));
}
}
;
}
}
}
}
}
}
...
@@ -171,23 +173,23 @@
...
@@ -171,23 +173,23 @@
settings
=
settings
||
{};
settings
=
settings
||
{};
settings
.
timeout
=
settings
.
timeout
||
30000
;
settings
.
timeout
=
settings
.
timeout
||
30000
;
var
xhr
=
Ajax
.
_getXHRObject
();
var
xhr
=
Ajax
.
_getXHRObject
();
if
(
!
xhr
||!
settings
.
url
)
return
;
if
(
!
xhr
||!
settings
.
url
)
{
return
;
}
Ajax
.
clear
(
settings
);
Ajax
.
clear
(
settings
);
xhr
.
onreadystatechange
=
function
()
{
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
==
4
)
{
if
(
xhr
.
readyState
==
=
4
)
{
Ajax
.
clear
(
settings
);
Ajax
.
clear
(
settings
);
if
(
settings
.
afterReceive
)
settings
.
afterReceive
(
xhr
);
if
(
settings
.
afterReceive
)
{
settings
.
afterReceive
(
xhr
);
}
if
(
xhr
.
status
==
200
)
{
if
(
xhr
.
status
==
=
200
)
{
if
(
settings
.
success
)
settings
.
success
(
xhr
.
responseText
);
if
(
settings
.
success
)
{
settings
.
success
(
xhr
.
responseText
);
}
}
else
{
}
else
{
if
(
settings
.
error
)
settings
.
error
(
xhr
.
status
||
304
);
if
(
settings
.
error
)
{
settings
.
error
(
xhr
.
status
||
304
);
}
}
}
}
}
}
};
if
(
settings
.
beforeOpen
)
settings
.
beforeOpen
(
xhr
);
if
(
settings
.
beforeOpen
)
{
settings
.
beforeOpen
(
xhr
);
}
var
params
=
{};
var
params
=
{};
var
body
=
null
;
var
body
=
null
;
...
@@ -201,7 +203,7 @@
...
@@ -201,7 +203,7 @@
xhr
.
open
(
method
,
addParamsToUrl
(
settings
.
url
,
extend
({},
params
,
currentTimestampParam
())),
true
);
xhr
.
open
(
method
,
addParamsToUrl
(
settings
.
url
,
extend
({},
params
,
currentTimestampParam
())),
true
);
if
(
settings
.
beforeSend
)
settings
.
beforeSend
(
xhr
);
if
(
settings
.
beforeSend
)
{
settings
.
beforeSend
(
xhr
);
}
var
onerror
=
function
()
{
var
onerror
=
function
()
{
try
{
xhr
.
abort
();
}
catch
(
e
)
{
/* ignore error on closing */
}
try
{
xhr
.
abort
();
}
catch
(
e
)
{
/* ignore error on closing */
}
...
@@ -224,7 +226,7 @@
...
@@ -224,7 +226,7 @@
// Handling memory leak in IE, removing and dereference the script
// Handling memory leak in IE, removing and dereference the script
if
(
script
)
{
if
(
script
)
{
script
.
onerror
=
script
.
onload
=
script
.
onreadystatechange
=
null
;
script
.
onerror
=
script
.
onload
=
script
.
onreadystatechange
=
null
;
if
(
script
.
parentNode
)
script
.
parentNode
.
removeChild
(
script
);
if
(
script
.
parentNode
)
{
script
.
parentNode
.
removeChild
(
script
);
}
}
}
},
},
...
@@ -263,8 +265,8 @@
...
@@ -263,8 +265,8 @@
}
}
};
};
if
(
settings
.
beforeOpen
)
settings
.
beforeOpen
({});
if
(
settings
.
beforeOpen
)
{
settings
.
beforeOpen
({});
}
if
(
settings
.
beforeSend
)
settings
.
beforeSend
({});
if
(
settings
.
beforeSend
)
{
settings
.
beforeSend
({});
}
settings
.
timeoutId
=
window
.
setTimeout
(
onerror
,
settings
.
timeout
+
2000
);
settings
.
timeoutId
=
window
.
setTimeout
(
onerror
,
settings
.
timeout
+
2000
);
settings
.
scriptId
=
settings
.
scriptId
||
new
Date
().
getTime
();
settings
.
scriptId
=
settings
.
scriptId
||
new
Date
().
getTime
();
...
@@ -310,7 +312,7 @@
...
@@ -310,7 +312,7 @@
};
};
return
message
;
return
message
;
}
}
;
var
getBacktrack
=
function
(
options
)
{
var
getBacktrack
=
function
(
options
)
{
return
(
options
.
backtrack
)
?
"
.b
"
+
Number
(
options
.
backtrack
)
:
""
;
return
(
options
.
backtrack
)
?
"
.b
"
+
Number
(
options
.
backtrack
)
:
""
;
...
@@ -331,7 +333,7 @@
...
@@ -331,7 +333,7 @@
var
useSSL
=
pushstream
.
useSSL
;
var
useSSL
=
pushstream
.
useSSL
;
var
url
=
(
websocket
)
?
((
useSSL
)
?
"
wss://
"
:
"
ws://
"
)
:
((
useSSL
)
?
"
https://
"
:
"
http://
"
);
var
url
=
(
websocket
)
?
((
useSSL
)
?
"
wss://
"
:
"
ws://
"
)
:
((
useSSL
)
?
"
https://
"
:
"
http://
"
);
url
+=
pushstream
.
host
;
url
+=
pushstream
.
host
;
url
+=
((
!
useSSL
&&
pushstream
.
port
==
80
)
||
(
useSSL
&&
pushstream
.
port
==
443
))
?
""
:
(
"
:
"
+
pushstream
.
port
);
url
+=
((
!
useSSL
&&
pushstream
.
port
==
=
80
)
||
(
useSSL
&&
pushstream
.
port
=
==
443
))
?
""
:
(
"
:
"
+
pushstream
.
port
);
url
+=
prefix
;
url
+=
prefix
;
var
channels
=
getChannelsPath
(
pushstream
.
channels
);
var
channels
=
getChannelsPath
(
pushstream
.
channels
);
...
@@ -349,7 +351,7 @@
...
@@ -349,7 +351,7 @@
var
channel
=
""
;
var
channel
=
""
;
var
url
=
(
pushstream
.
useSSL
)
?
"
https://
"
:
"
http://
"
;
var
url
=
(
pushstream
.
useSSL
)
?
"
https://
"
:
"
http://
"
;
url
+=
pushstream
.
host
;
url
+=
pushstream
.
host
;
url
+=
((
pushstream
.
port
!=
80
)
&&
(
pushstream
.
port
!
=
443
))
?
(
"
:
"
+
pushstream
.
port
)
:
""
;
url
+=
((
pushstream
.
port
!=
=
80
)
&&
(
pushstream
.
port
!=
=
443
))
?
(
"
:
"
+
pushstream
.
port
)
:
""
;
url
+=
pushstream
.
urlPrefixPublisher
;
url
+=
pushstream
.
urlPrefixPublisher
;
for
(
var
channelName
in
pushstream
.
channels
)
{
for
(
var
channelName
in
pushstream
.
channels
)
{
if
(
!
pushstream
.
channels
.
hasOwnProperty
||
pushstream
.
channels
.
hasOwnProperty
(
channelName
))
{
if
(
!
pushstream
.
channels
.
hasOwnProperty
||
pushstream
.
channels
.
hasOwnProperty
(
channelName
))
{
...
@@ -402,12 +404,12 @@
...
@@ -402,12 +404,12 @@
}
}
this
.
_closeCurrentConnection
();
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onerror
({
type
:
((
event
&&
(
event
.
type
===
"
load
"
))
||
(
this
.
pushstream
.
readyState
===
PushStream
.
CONNECTING
))
?
"
load
"
:
"
timeout
"
});
this
.
pushstream
.
_onerror
({
type
:
((
event
&&
(
event
.
type
===
"
load
"
))
||
(
this
.
pushstream
.
readyState
===
PushStream
.
CONNECTING
))
?
"
load
"
:
"
timeout
"
});
}
}
;
/* wrappers */
/* wrappers */
var
WebSocketWrapper
=
function
(
pushstream
)
{
var
WebSocketWrapper
=
function
(
pushstream
)
{
if
(
!
window
.
WebSocket
&&
!
window
.
MozWebSocket
)
throw
"
WebSocket not supported
"
;
if
(
!
window
.
WebSocket
&&
!
window
.
MozWebSocket
)
{
throw
"
WebSocket not supported
"
;
}
this
.
type
=
WebSocketWrapper
.
TYPE
;
this
.
type
=
WebSocketWrapper
.
TYPE
;
this
.
pushstream
=
pushstream
;
this
.
pushstream
=
pushstream
;
this
.
connection
=
null
;
this
.
connection
=
null
;
...
@@ -450,7 +452,7 @@
...
@@ -450,7 +452,7 @@
};
};
var
EventSourceWrapper
=
function
(
pushstream
)
{
var
EventSourceWrapper
=
function
(
pushstream
)
{
if
(
!
window
.
EventSource
)
throw
"
EventSource not supported
"
;
if
(
!
window
.
EventSource
)
{
throw
"
EventSource not supported
"
;
}
this
.
type
=
EventSourceWrapper
.
TYPE
;
this
.
type
=
EventSourceWrapper
.
TYPE
;
this
.
pushstream
=
pushstream
;
this
.
pushstream
=
pushstream
;
this
.
connection
=
null
;
this
.
connection
=
null
;
...
@@ -525,7 +527,7 @@
...
@@ -525,7 +527,7 @@
var
oldIframe
=
document
.
getElementById
(
this
.
iframeId
);
var
oldIframe
=
document
.
getElementById
(
this
.
iframeId
);
if
(
oldIframe
)
{
if
(
oldIframe
)
{
oldIframe
.
onload
=
null
;
oldIframe
.
onload
=
null
;
if
(
oldIframe
.
parentNode
)
oldIframe
.
parentNode
.
removeChild
(
oldIframe
);
if
(
oldIframe
.
parentNode
)
{
oldIframe
.
parentNode
.
removeChild
(
oldIframe
);
}
}
}
},
},
...
@@ -536,7 +538,7 @@
...
@@ -536,7 +538,7 @@
this
.
frameloadtimer
=
clearTimer
(
this
.
frameloadtimer
);
this
.
frameloadtimer
=
clearTimer
(
this
.
frameloadtimer
);
this
.
connection
=
null
;
this
.
connection
=
null
;
this
.
transferDoc
=
null
;
this
.
transferDoc
=
null
;
if
(
typeof
window
.
CollectGarbage
===
'
function
'
)
window
.
CollectGarbage
();
if
(
typeof
window
.
CollectGarbage
===
'
function
'
)
{
window
.
CollectGarbage
();
}
}
}
},
},
...
@@ -596,7 +598,7 @@
...
@@ -596,7 +598,7 @@
},
},
setPingTimer
:
function
()
{
setPingTimer
:
function
()
{
if
(
this
.
pingtimer
)
clearTimer
(
this
.
pingtimer
);
if
(
this
.
pingtimer
)
{
clearTimer
(
this
.
pingtimer
);
}
this
.
pingtimer
=
window
.
setTimeout
(
linker
(
onerrorCallback
,
this
),
this
.
pushstream
.
pingtimeout
);
this
.
pingtimer
=
window
.
setTimeout
(
linker
(
onerrorCallback
,
this
),
this
.
pushstream
.
pingtimeout
);
}
}
};
};
...
@@ -621,7 +623,7 @@
...
@@ -621,7 +623,7 @@
beforeOpen
:
linker
(
this
.
beforeOpen
,
this
),
beforeOpen
:
linker
(
this
.
beforeOpen
,
this
),
beforeSend
:
linker
(
this
.
beforeSend
,
this
),
beforeSend
:
linker
(
this
.
beforeSend
,
this
),
afterReceive
:
linker
(
this
.
afterReceive
,
this
)
afterReceive
:
linker
(
this
.
afterReceive
,
this
)
}
}
;
};
};
LongPollingWrapper
.
TYPE
=
"
LongPolling
"
;
LongPollingWrapper
.
TYPE
=
"
LongPolling
"
;
...
@@ -634,7 +636,7 @@
...
@@ -634,7 +636,7 @@
this
.
xhrSettings
.
url
=
getSubscriberUrl
(
this
.
pushstream
,
this
.
pushstream
.
urlPrefixLongpolling
);
this
.
xhrSettings
.
url
=
getSubscriberUrl
(
this
.
pushstream
,
this
.
pushstream
.
urlPrefixLongpolling
);
var
domain
=
extract_xss_domain
(
this
.
pushstream
.
host
);
var
domain
=
extract_xss_domain
(
this
.
pushstream
.
host
);
var
currentDomain
=
extract_xss_domain
(
window
.
location
.
hostname
);
var
currentDomain
=
extract_xss_domain
(
window
.
location
.
hostname
);
this
.
useJSONP
=
(
domain
!=
currentDomain
)
||
this
.
pushstream
.
longPollingUseJSONP
;
this
.
useJSONP
=
(
domain
!=
=
currentDomain
)
||
this
.
pushstream
.
longPollingUseJSONP
;
this
.
xhrSettings
.
scriptId
=
"
PushStreamManager_
"
+
this
.
pushstream
.
id
;
this
.
xhrSettings
.
scriptId
=
"
PushStreamManager_
"
+
this
.
pushstream
.
id
;
if
(
this
.
useJSONP
)
{
if
(
this
.
useJSONP
)
{
this
.
pushstream
.
longPollingByHeaders
=
false
;
this
.
pushstream
.
longPollingByHeaders
=
false
;
...
@@ -646,7 +648,7 @@
...
@@ -646,7 +648,7 @@
},
},
_listen
:
function
()
{
_listen
:
function
()
{
if
(
this
.
_internalListenTimeout
)
clearTimer
(
this
.
_internalListenTimeout
);
if
(
this
.
_internalListenTimeout
)
{
clearTimer
(
this
.
_internalListenTimeout
);
}
this
.
_internalListenTimeout
=
window
.
setTimeout
(
this
.
_linkedInternalListen
,
this
.
pushstream
.
longPollingInterval
);
this
.
_internalListenTimeout
=
window
.
setTimeout
(
this
.
_linkedInternalListen
,
this
.
pushstream
.
longPollingInterval
);
},
},
...
@@ -681,7 +683,7 @@
...
@@ -681,7 +683,7 @@
},
},
beforeOpen
:
function
(
xhr
)
{
beforeOpen
:
function
(
xhr
)
{
if
(
this
.
lastModified
==
null
)
{
if
(
this
.
lastModified
==
=
null
)
{
var
date
=
new
Date
();
var
date
=
new
Date
();
if
(
this
.
pushstream
.
secondsAgo
)
{
date
.
setTime
(
date
.
getTime
()
-
(
this
.
pushstream
.
secondsAgo
*
1000
));
}
if
(
this
.
pushstream
.
secondsAgo
)
{
date
.
setTime
(
date
.
getTime
()
-
(
this
.
pushstream
.
secondsAgo
*
1000
));
}
this
.
lastModified
=
date
.
toUTCString
();
this
.
lastModified
=
date
.
toUTCString
();
...
@@ -805,7 +807,7 @@
...
@@ -805,7 +807,7 @@
this
.
extraParams
=
settings
.
extraParams
||
this
.
extraParams
;
this
.
extraParams
=
settings
.
extraParams
||
this
.
extraParams
;
for
(
var
i
=
0
;
i
<
this
.
modes
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
this
.
modes
.
length
;
i
++
)
{
try
{
try
{
var
wrapper
=
null
;
var
wrapper
=
null
;
switch
(
this
.
modes
[
i
])
{
switch
(
this
.
modes
[
i
])
{
...
@@ -819,7 +821,7 @@
...
@@ -819,7 +821,7 @@
}
}
this
.
_setState
(
0
);
this
.
_setState
(
0
);
}
}
;
/* constants */
/* constants */
PushStream
.
LOG_LEVEL
=
'
error
'
;
/* debug, info, error */
PushStream
.
LOG_LEVEL
=
'
error
'
;
/* debug, info, error */
...
@@ -837,16 +839,16 @@
...
@@ -837,16 +839,16 @@
},
},
addChannel
:
function
(
channel
,
options
)
{
addChannel
:
function
(
channel
,
options
)
{
if
(
escapeText
(
channel
)
!=
channel
)
{
if
(
escapeText
(
channel
)
!=
=
channel
)
{
throw
"
Invalid channel name! Channel has to be a set of [a-zA-Z0-9]
"
;
throw
"
Invalid channel name! Channel has to be a set of [a-zA-Z0-9]
"
;
}
}
Log4js
.
debug
(
"
entering addChannel
"
);
Log4js
.
debug
(
"
entering addChannel
"
);
if
(
typeof
(
this
.
channels
[
channel
])
!==
"
undefined
"
)
throw
"
Cannot add channel
"
+
channel
+
"
: already subscribed
"
;
if
(
typeof
(
this
.
channels
[
channel
])
!==
"
undefined
"
)
{
throw
"
Cannot add channel
"
+
channel
+
"
: already subscribed
"
;
}
options
=
options
||
{};
options
=
options
||
{};
Log4js
.
info
(
"
adding channel
"
,
channel
,
options
);
Log4js
.
info
(
"
adding channel
"
,
channel
,
options
);
this
.
channels
[
channel
]
=
options
;
this
.
channels
[
channel
]
=
options
;
this
.
channelsCount
++
;
this
.
channelsCount
++
;
if
(
this
.
readyState
!=
PushStream
.
CLOSED
)
this
.
connect
();
if
(
this
.
readyState
!=
=
PushStream
.
CLOSED
)
{
this
.
connect
();
}
Log4js
.
debug
(
"
leaving addChannel
"
);
Log4js
.
debug
(
"
leaving addChannel
"
);
},
},
...
@@ -865,7 +867,7 @@
...
@@ -865,7 +867,7 @@
},
},
_setState
:
function
(
state
)
{
_setState
:
function
(
state
)
{
if
(
this
.
readyState
!=
state
)
{
if
(
this
.
readyState
!=
=
state
)
{
Log4js
.
info
(
"
status changed
"
,
state
);
Log4js
.
info
(
"
status changed
"
,
state
);
this
.
readyState
=
state
;
this
.
readyState
=
state
;
if
(
this
.
onstatuschange
)
{
if
(
this
.
onstatuschange
)
{
...
@@ -876,10 +878,10 @@
...
@@ -876,10 +878,10 @@
connect
:
function
()
{
connect
:
function
()
{
Log4js
.
debug
(
"
entering connect
"
);
Log4js
.
debug
(
"
entering connect
"
);
if
(
!
this
.
host
)
throw
"
PushStream host not specified
"
;
if
(
!
this
.
host
)
{
throw
"
PushStream host not specified
"
;
}
if
(
isNaN
(
this
.
port
))
throw
"
PushStream port not specified
"
;
if
(
isNaN
(
this
.
port
))
{
throw
"
PushStream port not specified
"
;
}
if
(
!
this
.
channelsCount
)
throw
"
No channels specified
"
;
if
(
!
this
.
channelsCount
)
{
throw
"
No channels specified
"
;
}
if
(
this
.
wrappers
.
length
===
0
)
throw
"
No available support for this browser
"
;
if
(
this
.
wrappers
.
length
===
0
)
{
throw
"
No available support for this browser
"
;
}
this
.
_keepConnected
=
true
;
this
.
_keepConnected
=
true
;
this
.
_lastUsedMode
=
0
;
this
.
_lastUsedMode
=
0
;
...
@@ -935,7 +937,7 @@
...
@@ -935,7 +937,7 @@
_onmessage
:
function
(
data
,
id
,
channel
,
eventid
,
isLastMessageFromBatch
)
{
_onmessage
:
function
(
data
,
id
,
channel
,
eventid
,
isLastMessageFromBatch
)
{
Log4js
.
debug
(
"
message
"
,
data
,
id
,
channel
,
eventid
,
isLastMessageFromBatch
);
Log4js
.
debug
(
"
message
"
,
data
,
id
,
channel
,
eventid
,
isLastMessageFromBatch
);
if
(
id
==
-
2
)
{
if
(
id
==
=
-
2
)
{
if
(
this
.
onchanneldeleted
)
{
this
.
onchanneldeleted
(
channel
);
}
if
(
this
.
onchanneldeleted
)
{
this
.
onchanneldeleted
(
channel
);
}
}
else
if
((
id
>
0
)
&&
(
typeof
(
this
.
channels
[
channel
])
!==
"
undefined
"
))
{
}
else
if
((
id
>
0
)
&&
(
typeof
(
this
.
channels
[
channel
])
!==
"
undefined
"
))
{
if
(
this
.
onmessage
)
{
this
.
onmessage
(
data
,
id
,
channel
,
eventid
,
isLastMessageFromBatch
);
}
if
(
this
.
onmessage
)
{
this
.
onmessage
(
data
,
id
,
channel
,
eventid
,
isLastMessageFromBatch
);
}
...
@@ -944,12 +946,12 @@
...
@@ -944,12 +946,12 @@
_onerror
:
function
(
error
)
{
_onerror
:
function
(
error
)
{
this
.
_setState
(
PushStream
.
CLOSED
);
this
.
_setState
(
PushStream
.
CLOSED
);
this
.
_reconnect
((
error
.
type
==
"
timeout
"
)
?
this
.
reconnecttimeout
:
this
.
checkChannelAvailabilityInterval
);
this
.
_reconnect
((
error
.
type
==
=
"
timeout
"
)
?
this
.
reconnecttimeout
:
this
.
checkChannelAvailabilityInterval
);
if
(
this
.
onerror
)
{
this
.
onerror
(
error
);
}
if
(
this
.
onerror
)
{
this
.
onerror
(
error
);
}
},
},
_reconnect
:
function
(
timeout
)
{
_reconnect
:
function
(
timeout
)
{
if
(
this
.
_keepConnected
&&
!
this
.
reconnecttimer
&&
(
this
.
readyState
!=
PushStream
.
CONNECTING
))
{
if
(
this
.
_keepConnected
&&
!
this
.
reconnecttimer
&&
(
this
.
readyState
!=
=
PushStream
.
CONNECTING
))
{
Log4js
.
info
(
"
trying to reconnect in
"
,
timeout
);
Log4js
.
info
(
"
trying to reconnect in
"
,
timeout
);
this
.
reconnecttimer
=
window
.
setTimeout
(
linker
(
this
.
_connect
,
this
),
timeout
);
this
.
reconnecttimer
=
window
.
setTimeout
(
linker
(
this
.
_connect
,
this
),
timeout
);
}
}
...
@@ -959,7 +961,7 @@
...
@@ -959,7 +961,7 @@
message
=
escapeText
(
message
);
message
=
escapeText
(
message
);
if
(
this
.
wrapper
.
type
===
WebSocketWrapper
.
TYPE
)
{
if
(
this
.
wrapper
.
type
===
WebSocketWrapper
.
TYPE
)
{
this
.
wrapper
.
sendMessage
(
message
);
this
.
wrapper
.
sendMessage
(
message
);
if
(
successCallback
)
successCallback
();
if
(
successCallback
)
{
successCallback
();
}
}
else
{
}
else
{
Ajax
.
post
({
url
:
getPublisherUrl
(
this
),
data
:
message
,
success
:
successCallback
,
error
:
errorCallback
});
Ajax
.
post
({
url
:
getPublisherUrl
(
this
),
data
:
message
,
success
:
successCallback
,
error
:
errorCallback
});
}
}
...
@@ -980,7 +982,7 @@
...
@@ -980,7 +982,7 @@
};
};
PushStream
.
unload
=
function
()
{
PushStream
.
unload
=
function
()
{
for
(
var
i
=
0
;
i
<
PushStreamManager
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
PushStreamManager
.
length
;
i
++
)
{
try
{
PushStreamManager
[
i
].
disconnect
();
}
catch
(
e
){}
try
{
PushStreamManager
[
i
].
disconnect
();
}
catch
(
e
){}
}
}
};
};
...
...
test/Gemfile
View file @
ea485a7a
...
@@ -7,7 +7,8 @@ group :test do
...
@@ -7,7 +7,8 @@ group :test do
gem
'em-http-request'
,
'0.2.14'
gem
'em-http-request'
,
'0.2.14'
gem
'json'
,
'1.4.3'
gem
'json'
,
'1.4.3'
gem
'jasmine'
,
'1.0.2.1'
gem
'jasmine'
,
'1.0.2.1'
gem
'jshint'
gem
'jshintrb'
gem
'therubyracer'
platforms
:mri_18
do
platforms
:mri_18
do
gem
"ruby-debug"
gem
"ruby-debug"
...
...
test/Gemfile.lock
View file @
ea485a7a
...
@@ -16,6 +16,8 @@ GEM
...
@@ -16,6 +16,8 @@ GEM
addressable (>= 2.0.0)
addressable (>= 2.0.0)
eventmachine (>= 0.12.9)
eventmachine (>= 0.12.9)
eventmachine (0.12.10)
eventmachine (0.12.10)
execjs (1.4.0)
multi_json (~> 1.0)
ffi (1.0.9)
ffi (1.0.9)
github-markup (0.7.1)
github-markup (0.7.1)
jasmine (1.0.2.1)
jasmine (1.0.2.1)
...
@@ -23,12 +25,17 @@ GEM
...
@@ -23,12 +25,17 @@ GEM
rack (>= 1.1)
rack (>= 1.1)
rspec (>= 1.3.1)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
selenium-webdriver (>= 0.1.3)
jshint (0.1.1)
jshintrb (0.2.1)
execjs
multi_json (>= 1.3)
rake
json (1.4.3)
json (1.4.3)
json_pure (1.5.3)
json_pure (1.5.3)
libv8 (3.3.10.4)
linecache (0.43)
linecache (0.43)
linecache19 (0.5.11)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
ruby_core_source (>= 0.1.4)
multi_json (1.3.7)
nokogiri (1.5.0)
nokogiri (1.5.0)
open4 (1.0.1)
open4 (1.0.1)
rack (1.3.2)
rack (1.3.2)
...
@@ -62,6 +69,8 @@ GEM
...
@@ -62,6 +69,8 @@ GEM
ffi (>= 1.0.7)
ffi (>= 1.0.7)
json_pure
json_pure
rubyzip
rubyzip
therubyracer (0.10.2)
libv8 (~> 3.3.10)
PLATFORMS
PLATFORMS
ruby
ruby
...
@@ -72,9 +81,10 @@ DEPENDENCIES
...
@@ -72,9 +81,10 @@ DEPENDENCIES
em-http-request (= 0.2.14)
em-http-request (= 0.2.14)
github-markup
github-markup
jasmine (= 1.0.2.1)
jasmine (= 1.0.2.1)
jshint
jshint
rb
json (= 1.4.3)
json (= 1.4.3)
nokogiri
nokogiri
rake
rake
ruby-debug
ruby-debug
ruby-debug19
ruby-debug19
therubyracer
test/Rakefile
View file @
ea485a7a
...
@@ -129,13 +129,13 @@ rescue LoadError
...
@@ -129,13 +129,13 @@ rescue LoadError
end
end
begin
begin
require
'jshint/tasks'
require
"jshintrb/jshinttask"
J
SHint
.
config_path
=
File
.
expand_path
(
File
.
join
(
'test/spec/javascripts/support/jshint.yml'
),
base_dir
)
J
shintrb
::
JshintTask
.
new
:jshint
do
|
t
|
jasmine_config
=
YAML
.
load
(
File
.
read
(
File
.
expand_path
(
File
.
join
(
'test/spec/javascripts/support/jasmine.yml'
),
base_dir
)))
t
.
pattern
=
'../misc/js/pushstream.js'
t
.
options
=
:defaults
ENV
[
'PATHS'
]
=
jasmine_config
[
"src_files"
].
map
{
|
file
|
File
.
expand_path
(
File
.
join
(
file
),
base_dir
)
}.
join
(
','
)
end
rescue
LoadError
rescue
LoadError
task
:jshint
do
task
:jshint
do
abort
"
jshint is not available. In order to run jshint, you must: (sudo) gem install jshint
"
abort
"
Jshintrb is not available. In order to run jshint, you must: (sudo) gem install jshintrb
"
end
end
end
end
test/spec/javascripts/support/jshint.yml
deleted
100644 → 0
View file @
28d9df7a
# ------------ rake task options ------------
# JS files to check by default, if no parameters are passed to rake jshint
# (you may want to limit this only to your own scripts and exclude any external scripts and frameworks)
# this can be overridden by adding 'paths' and 'exclude_paths' parameter to rake command:
# rake jshint paths=path1,path2,... exclude_paths=library1,library2,...
paths
:
exclude_paths
:
-
public/javascripts/vendor/**/*.js
# ------------ jshint options ------------
# visit http://jshint.com/ for complete documentation
# "enforce" type options (true means potentially more warnings)
adsafe
:
false
# true if ADsafe rules should be enforced. See http://www.ADsafe.org/
bitwise
:
true
# true if bitwise operators should not be allowed
newcap
:
true
# true if Initial Caps must be used with constructor functions
eqeqeq
:
false
# true if === should be required (for ALL equality comparisons)
immed
:
false
# true if immediate function invocations must be wrapped in parens
nomen
:
false
# true if initial or trailing underscore in identifiers should be forbidden
onevar
:
false
# true if only one var statement per function should be allowed
plusplus
:
false
# true if ++ and -- should not be allowed
regexp
:
false
# true if . and [^...] should not be allowed in RegExp literals
safe
:
false
# true if the safe subset rules are enforced (used by ADsafe)
strict
:
false
# true if the ES5 "use strict"; pragma is required
undef
:
true
# true if variables must be declared before used
white
:
false
# true if strict whitespace rules apply (see also 'indent' option)
# "allow" type options (false means potentially more warnings)
cap
:
false
# true if upper case HTML should be allowed
css
:
false
# true if CSS workarounds should be tolerated
debug
:
false
# true if debugger statements should be allowed (set to false before going into production)
es5
:
false
# true if ECMAScript 5 syntax should be allowed
evil
:
false
# true if eval should be allowed
forin
:
false
# true if unfiltered 'for in' statements should be allowed
fragment
:
false
# true if HTML fragments should be allowed
laxbreak
:
false
# true if statement breaks should not be checked
on
:
false
# true if HTML event handlers (e.g. onclick="...") should be allowed
sub
:
false
# true if subscript notation may be used for expressions better expressed in dot notation
# other options
maxlen
:
160
# Maximum line length
indent
:
2
# Number of spaces that should be used for indentation - used only if 'white' option is set
maxerr
:
50
# The maximum number of warnings reported (per file)
passfail
:
false
# true if the scan should stop on first error (per file)
# following are relevant only if undef = true
predef
:
'
'
# Names of predefined global variables - comma-separated string or a YAML array
browser
:
true
# true if the standard browser globals should be predefined
rhino
:
false
# true if the Rhino environment globals should be predefined
windows
:
false
# true if Windows-specific globals should be predefined
widget
:
false
# true if the Yahoo Widgets globals should be predefined
devel
:
false
# true if functions like alert, confirm, console, prompt etc. are predefined
# jshint options
loopfunc
:
true
# true if functions should be allowed to be defined within loops
asi
:
true
# true if automatic semicolon insertion should be tolerated
boss
:
true
# true if advanced usage of assignments and == should be allowed
couch
:
true
# true if CouchDB globals should be predefined
curly
:
false
# true if curly braces around blocks should be required (even in if/for/while)
noarg
:
true
# true if arguments.caller and arguments.callee should be disallowed
node
:
true
# true if the Node.js environment globals should be predefined
noempty
:
true
# true if empty blocks should be disallowed
nonew
:
true
# true if using `new` for side-effects should be disallowed
# ------------ jshint_on_rails custom lint options (switch to true to disable some annoying warnings) ------------
# ignores "missing semicolon" warning at the end of a function; this lets you write one-liners
# like: x.map(function(i) { return i + 1 }); without having to put a second semicolon inside the function
lastsemic
:
false
# allows you to use the 'new' expression as a statement (without assignment)
# so you can call e.g. new Ajax.Request(...), new Effect.Highlight(...) without assigning to a dummy variable
newstat
:
false
# ignores the "Expected an assignment or function call and instead saw an expression" warning,
# if the expression contains a proper statement and makes sense; this lets you write things like:
# element && element.show();
# valid || other || lastChance || alert('OMG!');
# selected ? show() : hide();
# although these will still cause a warning:
# element && link;
# selected ? 5 : 10;
statinexp
:
false
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