private async Task Interpret(IEsotericInterpreter interp, LocalIOWrapper wrapper, string src) { try { interp.Interpret(wrapper, new[] { src }); } catch (Exception ex) { await wrapper.Write(ex.ToString()); } }
public async Task Process() { LocalIOWrapper wrapper = new LocalIOWrapper(Channel, LocalToken); var bundle = await GetLanguageAndSource(wrapper); var processor = LocateProcessor(bundle.Language); await Interpret(processor, wrapper, bundle.Source); await Channel.CloseAsync(WebSocketCloseStatus.NormalClosure, "Execution complete", LocalToken.Token); }
private async Task <SourceBundle> GetLanguageAndSource(LocalIOWrapper wrapper) { var src = await wrapper.Receive(false); // TODO: Assert var end = src.IndexOf(src.First(), 1); return(new SourceBundle { Language = src.Substring(1, end - 1), Source = src.Substring(end + 1) }); }