                         stream: 'status'
                     }
 
-            else if message.contents.status == 'error'
-                errorString = message.contents.ename
-                if message.contents.evalue.length > 0
-                    errorString = errorString + "\n" + message.contents.evalue
+            else if message.content.status == 'error'
+                errorString = message.content.ename
+                if message.content.evalue.length > 0
+                    errorString = errorString + "\n" + message.content.evalue
                 callback {
                     data: errorString
                     type: 'text'

    interrupt: ->
        console.log "sending SIGINT"
        @kernelProcess.kill('SIGINT')

    # send a signed Jupyter message (adapted from github.com/n-riesco/jmp)
    signedSend: (message, socket) ->
        encodedMessage =
            idents:        message.idents or []
            signature:     ''
            header:        JSON.stringify message.header
            parent_header: JSON.stringify (message.parent_header or {})
            metadata:      JSON.stringify (message.metadata or {})
            content:       JSON.stringify (message.content or {})

        if (@config.key)
            hmac = crypto.createHmac @config.signature_scheme.slice(5),
                @config.key
            toBuffer = (str) -> new Buffer str, "utf8"
            hmac.update toBuffer encodedMessage.header
            hmac.update toBuffer encodedMessage.parent_header
            hmac.update toBuffer encodedMessage.metadata
            hmac.update toBuffer encodedMessage.content
            encodedMessage.signature = hmac.digest "hex"

        console.log "signedMessage:", encodedMessage

        socket.send encodedMessage.idents.concat [
            '<IDS|MSG>'
            encodedMessage.signature
            encodedMessage.header
            encodedMessage.parent_header
            encodedMessage.metadata
            encodedMessage.content
        ]

    # onResults is a callback that may be called multiple times
    # as results come in from the kernel

                }


    onIOMessage: (message) ->
        message.type = message.header.msg_type

        console.log "IO message:", message

        if message.type == 'error'
            #TODO; produces to much warning & errors, maybe filter?
            @stderr message.content.evalue, message.content.ename

        if message.type == 'status'
            status = message.content.execution_state
            @statusView.setStatus(status)

            if status == 'idle' and _.has(message, ['parent_header', 'msg_id'])
