예제 #1
0
 private async Task Interpret(IEsotericInterpreter interp, LocalIOWrapper wrapper, string src)
 {
     try {
         interp.Interpret(wrapper, new[] { src });
     }
     catch (Exception ex) {
         await wrapper.Write(ex.ToString());
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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)
            });
        }