 
                     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"

                    socket.id = uuid.v4()
                    misc_node.enable_mesg(socket)
                    @dbg("tcp_server", "unlocked socket -- id=#{socket.id}")

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

                    disconnect = () =>
                        @dbg("socket (id=#{socket.id})", "disconnect")
                        socket.removeAllListeners()
