Make MODE a class constant

This commit is contained in:
Arlo Breault 2019-05-08 13:24:37 -04:00
parent 6b002c5f22
commit 9df66b15b1
4 changed files with 20 additions and 19 deletions

View file

@ -14,11 +14,18 @@ class Snowflake
relayAddr: null
proxyPairs: []
rateLimit: null
state: MODE.INIT
retries: 0
# Janky state machine
@MODE =
INIT: 0
WEBRTC_CONNECTING: 1
WEBRTC_READY: 2
# Prepare the Snowflake with a Broker (to find clients) and optional UI.
constructor: (@broker, @ui) ->
@state = Snowflake.MODE.INIT
rateLimitBytes = undefined
if 'off' != query['ratelimit']
rateLimitBytes = Params.getByteCount(query, 'ratelimit',
@ -41,7 +48,7 @@ class Snowflake
# Initialize WebRTC PeerConnection, which requires beginning the signalling
# process. |pollBroker| automatically arranges signalling.
beginWebRTC: ->
@state = MODE.WEBRTC_CONNECTING
@state = Snowflake.MODE.WEBRTC_CONNECTING
for i in [1..CONNECTIONS_PER_CLIENT]
@makeProxyPair @relayAddr
log 'ProxyPair Slots: ' + @proxyPairs.length