 
                     socket.on 'mesg', (type, mesg) =>
                         if type == 'json'
-                            @handle_mesg(mesg)
+                            @dbg("mesg", misc.trunc(misc.to_json(mesg),200))
+                            @emit("mesg_#{mesg.event}", mesg)
+                        else
+                            @dbg("mesg", "mesg of unknown type #{type} ignored")
 
                     reconnect = () =>
                         socket.removeAllListeners()

misc_node = require('misc_node')
message   = require('message')
uuid      = require('node-uuid')
{defaults, required} = misc

if not process.env.SALVUS_TOKENS?
    throw "Update and source salvus-env"

        else
            opts.cb?(undefined)


start_server = () ->
    winston.debug("start_server")
    new Server
        token_file : program.token
        port       : program.port


#############################################
# Process command line arguments -- copy something based
