                 header: header
                 content: content
 
-        @signedSend message, @shellSocket
+        @shellSocket.send new jmp.Message message
 
         @shellSocket.close()
         @ioSocket.close()

                stream: 'error'
            }

    parseMessage: (msg) ->
        i = 0
        while msg[i].toString('utf8') != '<IDS|MSG>'
            i++

        msgObject =
            prefix: msg[0].toString('utf8')
            header: JSON.parse msg[i+2].toString('utf8')
            parent_header: JSON.parse msg[i+3].toString('utf8')
            metadata: JSON.parse msg[i+4].toString('utf8')
            contents: JSON.parse msg[i+5].toString('utf8')

        msgObject.type = msgObject.header.msg_type
        return msgObject

    destroy: ->
        console.log "sending shutdown"


        if message.type == 'pyout' or
           message.type == 'display_data' or
           message.type == 'execute_result'
            if message.content.data['text/html']?
                return {
                    data: message.content.data['text/html']
                    type: 'text/html'
                    stream: 'pyout'
                }
            if message.content.data['image/svg+xml']?
                return {
                    data: message.content.data['image/svg+xml']
                    type: 'image/svg+xml'
                    stream: 'pyout'
                }

            imageKeys = _.filter _.keys(message.content.data), (key) ->
                return key.startsWith('image')
            imageKey = imageKeys[0]

            if imageKey?
                return {
                    data: message.content.data[imageKey]
                    type: imageKey
                    stream: 'pyout'
                }
            else
                return {
                    data: message.content.data['text/plain']
                    type: 'text'
                    stream: 'pyout'
                }
        else if message.type == 'stdout' or
                message.prefix == 'stdout' or
                message.prefix == 'stream.stdout' or
                message.content.name == 'stdout'
            return {
                data: message.content.text ? message.content.data
                type: 'text'
                stream: 'stdout'
            }
        else if message.type == 'pyerr' or message.type == 'error'
            stack = message.content.traceback
            stack = _.map stack, (item) -> item.trim()
            stack = stack.join('\n')
            return {
