 			@messageHandler msg for msg in data.messages
 			return
 		if (data.type == 'rpc')
-			@rpcHandlers[data.id]?.callback?(data.result)
-			@parseRPCReply @rpcHandlers[data.id]?.type, data.result
+			reply = data.result
+			if (data.status != 0)
+				reply = {err: data.status}
+			console.log(data)
+			@rpcHandlers[data.id]?.callback?(reply)
+			@parseRPCReply @rpcHandlers[data.id]?.type, reply
 			delete @rpcHandlers[data.id]
 
 	parseRPCReply: (name, data)->

			maxDJs: maxDJs
		@sendRPC "room.update_options", [@roomId, options], callback


module.exports = PlugAPI

		switch name
			when 'room.join'
				@emit('roomChanged', data)
				console.log(data)
				@userId = data.user.profile.id
				console.log(@userId)
				@roomId = data.room.id
				@historyID = data.room.historyID

