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
27b40d16
Commit
27b40d16
authored
Jul 15, 2016
by
Alice Wyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style fixes
parent
8f093474
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
13 deletions
+3
-13
streamer.js
h/static/scripts/streamer.js
+3
-6
streamer-test.js
h/static/scripts/test/streamer-test.js
+0
-7
No files found.
h/static/scripts/streamer.js
View file @
27b40d16
...
@@ -16,16 +16,13 @@ var Socket = require('./websocket');
...
@@ -16,16 +16,13 @@ var Socket = require('./websocket');
* @param groups - The local groups store
* @param groups - The local groups store
* @param session - Provides access to read and update the session state
* @param session - Provides access to read and update the session state
* @param settings - Application settings
* @param settings - Application settings
*
* @return The push notification service client.
*/
*/
// @ngInject
// @ngInject
function
Streamer
(
$rootScope
,
annotationMapper
,
groups
,
session
,
settings
)
{
function
Streamer
(
$rootScope
,
annotationMapper
,
groups
,
session
,
settings
)
{
//
t
he randomly generated session UUID
//
T
he randomly generated session UUID
var
clientId
=
uuid
.
v4
();
var
clientId
=
uuid
.
v4
();
// the singleton socket instance, only one may
// The socket instance for this Streamer instance
// be open at a time
var
socket
;
var
socket
;
// Client configuration messages, to be sent each time a new connection is
// Client configuration messages, to be sent each time a new connection is
...
@@ -86,7 +83,7 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) {
...
@@ -86,7 +83,7 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) {
}
}
}
}
var
connect
=
function
()
{
var
connect
=
function
()
{
// If we have no URL configured, don't do anything.
// If we have no URL configured, don't do anything.
var
url
=
settings
.
websocketUrl
;
var
url
=
settings
.
websocketUrl
;
if
(
!
url
)
{
if
(
!
url
)
{
...
...
h/static/scripts/test/streamer-test.js
View file @
27b40d16
...
@@ -83,13 +83,11 @@ describe('streamer', function () {
...
@@ -83,13 +83,11 @@ describe('streamer', function () {
it
(
'should not create a websocket connection if websocketUrl is not provided'
,
function
()
{
it
(
'should not create a websocket connection if websocketUrl is not provided'
,
function
()
{
fakeSettings
=
{};
fakeSettings
=
{};
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
assert
.
isNull
(
fakeWebSocket
);
assert
.
isNull
(
fakeWebSocket
);
});
});
it
(
'should send a client ID'
,
function
()
{
it
(
'should send a client ID'
,
function
()
{
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
assert
.
equal
(
fakeWebSocket
.
messages
.
length
,
1
);
assert
.
equal
(
fakeWebSocket
.
messages
.
length
,
1
);
assert
.
equal
(
fakeWebSocket
.
messages
[
0
].
messageType
,
'client_id'
);
assert
.
equal
(
fakeWebSocket
.
messages
[
0
].
messageType
,
'client_id'
);
assert
.
equal
(
fakeWebSocket
.
messages
[
0
].
value
,
activeStreamer
.
clientId
);
assert
.
equal
(
fakeWebSocket
.
messages
[
0
].
value
,
activeStreamer
.
clientId
);
...
@@ -97,7 +95,6 @@ describe('streamer', function () {
...
@@ -97,7 +95,6 @@ describe('streamer', function () {
it
(
'should close any existing socket'
,
function
()
{
it
(
'should close any existing socket'
,
function
()
{
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
var
oldWebSocket
=
fakeWebSocket
;
var
oldWebSocket
=
fakeWebSocket
;
activeStreamer
.
connect
();
activeStreamer
.
connect
();
assert
.
ok
(
oldWebSocket
.
didClose
);
assert
.
ok
(
oldWebSocket
.
didClose
);
...
@@ -107,7 +104,6 @@ describe('streamer', function () {
...
@@ -107,7 +104,6 @@ describe('streamer', function () {
describe
(
'annotation notifications'
,
function
()
{
describe
(
'annotation notifications'
,
function
()
{
it
(
'should load new annotations'
,
function
()
{
it
(
'should load new annotations'
,
function
()
{
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
fakeWebSocket
.
notify
({
fakeWebSocket
.
notify
({
type
:
'annotation-notification'
,
type
:
'annotation-notification'
,
options
:
{
options
:
{
...
@@ -122,7 +118,6 @@ describe('streamer', function () {
...
@@ -122,7 +118,6 @@ describe('streamer', function () {
it
(
'should unload deleted annotations'
,
function
()
{
it
(
'should unload deleted annotations'
,
function
()
{
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
fakeWebSocket
.
notify
({
fakeWebSocket
.
notify
({
type
:
'annotation-notification'
,
type
:
'annotation-notification'
,
options
:
{
options
:
{
...
@@ -139,7 +134,6 @@ describe('streamer', function () {
...
@@ -139,7 +134,6 @@ describe('streamer', function () {
describe
(
'session change notifications'
,
function
()
{
describe
(
'session change notifications'
,
function
()
{
it
(
'updates the session when a notification is received'
,
function
()
{
it
(
'updates the session when a notification is received'
,
function
()
{
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
var
model
=
{
var
model
=
{
groups
:
[{
groups
:
[{
id
:
'new-group'
id
:
'new-group'
...
@@ -156,7 +150,6 @@ describe('streamer', function () {
...
@@ -156,7 +150,6 @@ describe('streamer', function () {
describe
(
'reconnections'
,
function
()
{
describe
(
'reconnections'
,
function
()
{
it
(
'resends configuration messages when a reconnection occurs'
,
function
()
{
it
(
'resends configuration messages when a reconnection occurs'
,
function
()
{
createDefaultStreamer
();
createDefaultStreamer
();
activeStreamer
.
connect
();
fakeWebSocket
.
messages
=
[];
fakeWebSocket
.
messages
=
[];
fakeWebSocket
.
emit
(
'open'
);
fakeWebSocket
.
emit
(
'open'
);
assert
.
equal
(
fakeWebSocket
.
messages
.
length
,
1
);
assert
.
equal
(
fakeWebSocket
.
messages
.
length
,
1
);
...
...
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