Commit 91d7a00b authored by Nick Stenning's avatar Nick Stenning

socket: Unexport clientID

This isn't used anywhere else, so simplify the interface of Socket by
inlining a call to get the client ID.
parent ceb9d4b2
clientID = -> getClientId = ->
# Generate client ID # Generate client ID
buffer = (new Array(16)) buffer = (new Array(16))
uuid.v4 null, buffer, 0 uuid.v4 null, buffer, 0
uuid.unparse buffer uuid.unparse buffer
run = ['clientID', (clientID) -> socket = ['documentHelpers', (documentHelpers) ->
$.ajaxSetup -> new Socket("#{documentHelpers.baseURI}__streamer__")
headers:
"X-Client-Id": clientID
]
socket = ['documentHelpers', 'clientID', (documentHelpers, clientID) ->
-> new Socket(clientID, "#{documentHelpers.baseURI}__streamer__")
] ]
class Socket extends SockJS class Socket extends SockJS
constructor: (clientID, args...)-> constructor: ->
SockJS.apply(this, args) SockJS.apply(this, arguments)
send = this.send send = this.send
this.send = (data) => this.send = (data) =>
clientId = getClientId()
$.ajaxSetup
headers:
"X-Client-Id": clientId
# Set the client ID before the first message. # Set the client ID before the first message.
cid = JSON.stringify cid = JSON.stringify
messageType: 'client_id' messageType: 'client_id'
value: clientID value: clientId
# Send the messages. # Send the messages.
send.call(this, cid) send.call(this, cid)
...@@ -36,6 +36,4 @@ class Socket extends SockJS ...@@ -36,6 +36,4 @@ class Socket extends SockJS
angular.module('h') angular.module('h')
.factory('clientID', clientID)
.factory('socket', socket) .factory('socket', socket)
.run(run)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment