-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Spratley
committed
Dec 1, 2014
1 parent
365ca4f
commit 5de9bd3
Showing
4 changed files
with
362 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
###* | ||
# @ngdoc service | ||
# @name angularCmsApp.cmsSocketService | ||
# @description | ||
# # cmsSocketService | ||
# Service in the angularCmsApp. | ||
### | ||
angular.module('angularCmsApp').service 'cmsSocketService', -> | ||
# AngularJS will instantiate a singleton by calling "new" on this function | ||
WebSocketClient = (options) -> | ||
_ws = undefined | ||
_ws = new WebSocket(options.endpoint, options.protocol) | ||
_ws.onmessage = (e) -> | ||
console.log e.data | ||
|
||
_ws.onerror = (e) -> | ||
console.log e | ||
|
||
_ws.onclose = (e) -> | ||
console.log e | ||
|
||
_ws.onopen = (e) -> | ||
_ws.send "update" | ||
return | ||
instance: _ws | ||
close: -> | ||
_ws.close() | ||
|
||
send: (obj) -> | ||
try | ||
_ws.send obj | ||
catch err | ||
throw err | ||
return | ||
|
||
return WebSocketClient |
Oops, something went wrong.