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');
* @param groups - The local groups store
* @param session - Provides access to read and update the session state
* @param settings - Application settings
*
* @return The push notification service client.
*/
// @ngInject
function
Streamer
(
$rootScope
,
annotationMapper
,
groups
,
session
,
settings
)
{
//
t
he randomly generated session UUID
//
T
he randomly generated session UUID
var
clientId
=
uuid
.
v4
();
// the singleton socket instance, only one may
// be open at a time
// The socket instance for this Streamer instance
var
socket
;
// Client configuration messages, to be sent each time a new connection is
...
...
@@ -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.
var
url
=
settings
.
websocketUrl
;
if
(
!
url
)
{
...
...
h/static/scripts/test/streamer-test.js
View file @
27b40d16
...
...
@@ -83,13 +83,11 @@ describe('streamer', function () {
it
(
'should not create a websocket connection if websocketUrl is not provided'
,
function
()
{
fakeSettings
=
{};
createDefaultStreamer
();
activeStreamer
.
connect
();
assert
.
isNull
(
fakeWebSocket
);
});
it
(
'should send a client ID'
,
function
()
{
createDefaultStreamer
();
activeStreamer
.
connect
();
assert
.
equal
(
fakeWebSocket
.
messages
.
length
,
1
);
assert
.
equal
(
fakeWebSocket
.
messages
[
0
].
messageType
,
'client_id'
);
assert
.
equal
(
fakeWebSocket
.
messages
[
0
].
value
,
activeStreamer
.
clientId
);
...
...
@@ -97,7 +95,6 @@ describe('streamer', function () {
it
(
'should close any existing socket'
,
function
()
{
createDefaultStreamer
();
activeStreamer
.
connect
();
var
oldWebSocket
=
fakeWebSocket
;
activeStreamer
.
connect
();
assert
.
ok
(
oldWebSocket
.
didClose
);
...
...
@@ -107,7 +104,6 @@ describe('streamer', function () {
describe
(
'annotation notifications'
,
function
()
{
it
(
'should load new annotations'
,
function
()
{
createDefaultStreamer
();
activeStreamer
.
connect
();
fakeWebSocket
.
notify
({
type
:
'annotation-notification'
,
options
:
{
...
...
@@ -122,7 +118,6 @@ describe('streamer', function () {
it
(
'should unload deleted annotations'
,
function
()
{
createDefaultStreamer
();
activeStreamer
.
connect
();
fakeWebSocket
.
notify
({
type
:
'annotation-notification'
,
options
:
{
...
...
@@ -139,7 +134,6 @@ describe('streamer', function () {
describe
(
'session change notifications'
,
function
()
{
it
(
'updates the session when a notification is received'
,
function
()
{
createDefaultStreamer
();
activeStreamer
.
connect
();
var
model
=
{
groups
:
[{
id
:
'new-group'
...
...
@@ -156,7 +150,6 @@ describe('streamer', function () {
describe
(
'reconnections'
,
function
()
{
it
(
'resends configuration messages when a reconnection occurs'
,
function
()
{
createDefaultStreamer
();
activeStreamer
.
connect
();
fakeWebSocket
.
messages
=
[];
fakeWebSocket
.
emit
(
'open'
);
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