| 19 | */ |
| 20 | public final class WsEval extends WsFn { |
| 21 | @Override |
| 22 | public Str item(final QueryContext qc, final InputInfo ii) throws QueryException { |
| 23 | final IOContent query = toContent(arg(0), qc); |
| 24 | final HashMap<String, Value> bindings = toBindings(arg(1), qc); |
| 25 | final WsOptions options = toOptions(arg(2), new WsOptions(), qc); |
| 26 | |
| 27 | final JobOptions jopts = new JobOptions(); |
| 28 | jopts.set(JobOptions.BASE_URI, toBaseUri(query.url(), options, WsOptions.BASE_URI)); |
| 29 | jopts.set(JobOptions.ID, options.get(WsOptions.ID)); |
| 30 | |
| 31 | final QueryJobSpec spec = new QueryJobSpec(jopts, bindings, query); |
| 32 | final WebSocket ws = ws(qc); |
| 33 | final Consumer<QueryJobResult> notify = result -> { |
| 34 | try { |
| 35 | WsPool.send(result.value, ws.id); |
| 36 | } catch(final Exception ex) { |
| 37 | ws.error(ex); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | final QueryJob job = new QueryJob(spec, qc.context, info, notify); |
| 42 | return Str.get(job.jc().id()); |
| 43 | } |
| 44 | } |