Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Forked from bmeck/numberarray.js
Created September 16, 2010 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/581954 to your computer and use it in GitHub Desktop.
Save jashkenas/581954 to your computer and use it in GitHub Desktop.
function Client() {
this.state = "loggedoff"
}
//attempt to say something, will attempt login every time and keep you at as far as you have gotten
Client.prototype.say = function(msg) {
switch(this.state) {
case "loggedoff":
this.queueLogin()
case "authenticated":
this.queueVoiceRequest()
case "voiced":
this.queueMessage(msg)
break
//banned etc.
default:
throw "not allowed"
}
}
class Client
constructor: ->
@state = 'loggedoff'
say: (msg) ->
switch @state
when 'loggedoff' then @queueLogin()
when 'authenticated' then @queueVoiceRequest()
when 'voiced' then @queueMessage()
else
throw 'not allowed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment