Skip to content

Instantly share code, notes, and snippets.

@ffissore
Created March 7, 2012 14:00
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 ffissore/1993310 to your computer and use it in GitHub Desktop.
Save ffissore/1993310 to your computer and use it in GitHub Desktop.
Shutdown.coffee
parser = require("../connection/parser")
OperationTypes = require("./operation_types")
class Shutdown
read: (data, callback) ->
status = data.readUInt8(0)
if status
callback(data)
return
callback()
return
write: (socket, sessionId, data, callback) ->
#operation type
socket.write(parser.writeByte(OperationTypes.SHUTDOWN, true))
#invoke callback imidiately when the operation is sent to the server
callback()
#session ID
socket.write(parser.writeInt(sessionId, true))
#user name
socket.write(parser.writeString(data.user_name))
#user password
socket.write(parser.writeString(data.user_password))
return
module.exports = Shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment