Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
026e550b
Commit
026e550b
authored
Dec 15, 2014
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Streamer.onmessage now receives parsed JSON
parent
18569a70
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
controllers.coffee
h/static/scripts/controllers.coffee
+2
-1
streamer-service.coffee
h/static/scripts/streamer-service.coffee
+1
-1
streamer-service-test.coffee
tests/js/streamer-service-test.coffee
+12
-0
No files found.
h/static/scripts/controllers.coffee
View file @
026e550b
...
...
@@ -33,9 +33,10 @@ class AppController
annotator
.
deleteAnnotation
(
annotation
)
streamer
.
onmessage
=
(
msg
)
->
data
=
JSON
.
parse
(
msg
.
data
)
data
=
msg
.
data
unless
data
.
type
?
and
data
.
type
is
'annotation-notification'
return
payload
=
data
.
payload
action
=
data
.
options
.
action
...
...
h/static/scripts/streamer-service.coffee
View file @
026e550b
...
...
@@ -59,7 +59,7 @@ class Streamer
setTimeout((-> self.open()), backoff(self._failCount, 10))
this._sock.onmessage = (msg) ->
self.onmessage(
msg
)
self.onmessage(
JSON.parse(msg)
)
###
*
# @ngdoc method
...
...
tests/js/streamer-service-test.coffee
View file @
026e550b
...
...
@@ -106,3 +106,15 @@ describe 'streamer', ->
clock
.
tick
(
500
)
assert
.
calledOnce
(
WebSocket
)
it
'calls the onmessage handler when the socket recieves a message'
,
->
streamer
.
onmessage
=
sinon
.
spy
()
streamer
.
open
()
fakeSock
.
onmessage
(
JSON
.
stringify
({
animal
:
'baboon'
}))
assert
.
called
(
streamer
.
onmessage
)
it
'calls the onmessage handler with parsed JSON'
,
->
streamer
.
onmessage
=
sinon
.
spy
()
streamer
.
open
()
fakeSock
.
onmessage
(
JSON
.
stringify
({
animal
:
'baboon'
}))
assert
.
calledWith
(
streamer
.
onmessage
,
{
animal
:
'baboon'
})
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