 						if 			code == 0
 							socket.emit 'sys', JSON.stringify {sys:{records:{build:sys.records.build, status:'done',data:data}}}
 							me.dataset.getDatasets (code,data) ->
-								if !code then me.socket.emit 'sys', JSON.stringify {sys:{dataset:{list: data }}}
+								if !code then me.serv.io.sockets.emit 'sys', JSON.stringify {sys:{dataset:{list: data }}}
 								else console.log "WARNING Error controller: " + data
 						else if code == 1  then	socket.emit 'sys', JSON.stringify {sys:{records:{build:sys.records.build, status:'running',data:data}}}
 						else socket.emit 'sys', JSON.stringify {sys:{records:{build:sys.records.build, status:'failed',out:data}}}


				# DATASET EVENTS
				if sys.dataset?.list? then me.dataset.getDatasets (code,data) ->
					if !code then me.socket.emit 'sys', JSON.stringify {sys:{dataset:{list: data }}}
					else console.log "WARNING Error controller: " + data

				if sys.dataset?.build then 	me.dataset.buildDataset sys.dataset?.build, (code,data) ->
					if 			code == 0
						socket.emit 'sys', JSON.stringify {sys:{dataset:{build:sys.dataset.build, status:'done',data:data}}}
						me.dataset.getTrainingSets (code,data) ->
							if !code then me.socket.emit 'sys', JSON.stringify {sys:{training:{list: data }}}
							else console.log "WARNING Error controller: " + data

					else if code == 1  then	socket.emit 'sys', JSON.stringify {sys:{dataset:{build:sys.dataset.build, status:'running',data:data}}}


		me.streamer 	= new (require('./streamer.js')).Streamer (state)->
			if me.socket
				me.serv.io.sockets.emit 'sys', JSON.stringify( {sys: {state:state, sample_count:me.streamer.getSampleCount()} } )

		me.classifier  = new (require('./classifier.js')).Classifier me.streamer.getSampleFile(), (code, data) ->
			if me.socket
				me.serv.io.sockets.emit 'data', data
		me.classifier.init()

		me.serv.io.on 'connection', (socket) ->
			me.socket = socket
			setTimeout (->
				me.serv.io.sockets.emit 'data', JSON.stringify(me.classifier.getConf())
				), 5000

#			me.serv.io.sockets.emit 'sys', 'test'

			socket.on 'sys', (msg) ->
				console.log 'sys event: ' + msg.toString()
