예제 #1
0
        /*private void SendBreakpoint(string eventType, Breakpoint bp)
         * {
         *  var bpMsg = new DAPBreakpointEvent
         *  {
         *      reason = eventType,
         *      breakpoint = bp.ToDAP()
         *  };
         *  Stream.SendEvent("breakpoint", bpMsg);
         * }*/

        public void SendOutput(string category, string output)
        {
            var outputMsg = new DAPOutputMessage
            {
                category = category,
                output   = output
            };

            Stream.SendEvent("output", outputMsg);
        }
예제 #2
0
파일: DAPStream.cs 프로젝트: Norbyte/bg3se
        private void ProcessPayload(char[] payload)
        {
            if (LogStream != null)
            {
                using (var writer = new StreamWriter(LogStream, Encoding.UTF8, 0x1000, true))
                {
                    writer.Write(" DAP >>> ");
                    writer.Write(payload);
                    writer.Write("\r\n");
                }
            }

            DAPMessage message = null;

            try
            {
                message = DAPMessageSerializer.Unserialize(payload);
            }
            catch (DAPUnknownMessageException e)
            {
                if (LogStream != null)
                {
                    using (var writer = new StreamWriter(LogStream, Encoding.UTF8, 0x1000, true))
                    {
                        writer.WriteLine(" DAP !!! Could not decode DAP message: " + e.Message);
                    }
                }

                if (e.Type == "request")
                {
                    SendErrorReply(e.Seq, e.MessageType, e.Message);
                }

                IncomingSeq++;
                return;
            }
            catch (Exception e)
            {
                if (LogStream != null)
                {
                    using (var writer = new StreamWriter(LogStream, Encoding.UTF8, 0x1000, true))
                    {
                        writer.WriteLine(" DAP !!! Internal decoding error: " + e.ToString());
                    }
                }

                var outputMsg = new DAPOutputMessage
                {
                    category = "stderr",
                    output   = e.ToString()
                };
                SendEvent("output", outputMsg);

                IncomingSeq++;
                return;
            }

            if (message.seq != IncomingSeq)
            {
                throw new InvalidDataException($"DAP sequence number mismatch; got {message.seq} expected {IncomingSeq}");
            }

            IncomingSeq++;
            MessageReceived(message);
        }