コード例 #1
0
        public void Send(AidKey key = AidKey.Enter)
        {
            List <byte> byteData = new();

            byteData.Add((byte)key);
            var cursorAddress = EncodeAddress(CursorIndex);

            byteData.AddRange(cursorAddress);

            var mdtFields = StartFields.Where(m => m.ModifiedDataTag);

            foreach (var field in mdtFields)
            {
                byteData.Add((byte)Order.SetBufferAddress);
                var fieldAddress = EncodeAddress(field.Index + 1);
                byteData.AddRange(fieldAddress);
                int index = field.Index + 1;
                while (!StartFields.Any(m => m.Index == index))
                {
                    if (index > (24 * 80))
                    {
                        break;
                    }
                    if (ScreenBuffer[index] == 0x0)
                    {
                        index++;
                        continue;
                    }
                    byteData.Add(ScreenBuffer[index++]);
                }
            }
            byteData.AddRange(new byte[] { (byte)Telnet.IAC, (byte)Telnet.EOR });
            WriteBytes(byteData.ToArray());
        }
コード例 #2
0
        public static byte[] Build(OneRowCol RowCol, AidKey AidKey)
        {
            var ba = new ByteArrayBuilder();

            ba.Append((byte)RowCol.RowNum);
            ba.Append((byte)RowCol.ColNum);
            ba.Append((byte)AidKey);

            return(ba.ToByteArray());
        }
コード例 #3
0
        private void BuildAndSendResponseDataStream(
            AidKey AidKey, ScreenContent ScreenContent, TelnetLogList LogList = null)
        {
            // send response data stream up to the server.
            {
                var ra = BuildResponseByteStream(
                    ScreenContent,
                    AidKey, ScreenContent.CaretRowCol, ScreenContent.HowRead);
                ra = ra.Append(EOR_Command.Build());

                // send response stream back to server.
                TelnetConnection.WriteToHost(LogList, ra, this.Client.GetStream());

                // blank line in the log file.
                var logItem = new LogListItem(Direction.Read, "", true);
                this.LogList.AddItem(logItem);
            }
        }
コード例 #4
0
        private byte[] BuildResponseByteStream(
            ScreenContent ScreenContent,
            AidKey AidKey, OneRowCol CaretRowCol, HowReadScreen?HowRead = null)
        {
            var ba = new ByteArrayBuilder();

            // what to read from the screen.
            HowReadScreen howRead = HowReadScreen.ReadAllInput;

            if (HowRead != null)
            {
                howRead = HowRead.Value;
            }

            {
                var buf = DataStreamHeader.Build(99, TerminalOpcode.PutGet);
                ba.Append(buf);
            }

            // location of caret on the canvas.
            {
                var rowCol = CaretRowCol.ToParentRelative(ScreenContent);
                var buf    = ResponseHeader.Build(rowCol as OneRowCol, AidKey);
                ba.Append(buf);
            }

            foreach (var dictItem in ScreenContent.FieldDict)
            {
                ContentField responseField = null;
                var          contentItem   = dictItem.Value;

                // process only ContentField.
                if (contentItem is ContentField)
                {
                    var contentField = contentItem as ContentField;
                    responseField = contentField;
                }

                // only process the first of a continued entry field.
                if ((responseField != null) && (responseField is ContinuedContentField))
                {
                    var contContentField = responseField as ContinuedContentField;
                    if (contContentField.ContinuedFieldSegmentCode != ContinuedFieldSegmentCode.First)
                    {
                        responseField = null;
                    }
                }

                if ((howRead == HowReadScreen.ReadMdt) &&
                    (responseField != null) && (responseField.GetModifiedFlag(ScreenContent) == false))
                {
                    responseField = null;
                }

                if (responseField != null)
                {
                    IRowCol rowCol = responseField.RowCol.ToOneRowCol().AdvanceRight();
                    {
                        rowCol = rowCol.ToParentRelative(ScreenContent);
                        var buf = SetBufferAddressOrder.Build(rowCol as OneRowCol);
                        ba.Append(buf);
                    }
                    {
                        var buf = TextDataOrder.Build(responseField.GetFieldShowText(ScreenContent));
                        ba.Append(buf);
                    }
                }
            }

            // update length of response data stream.
            var ra = ba.ToByteArray();

            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                Array.Copy(wk.ToByteArray(), ra, 2);
            }

            return(ra);
        }
コード例 #5
0
 public AidKeyResponseMessage(AidKey AidKey, ScreenContent ScreenContent)
 {
     this.AidKey        = AidKey;
     this.ScreenContent = ScreenContent;
 }
コード例 #6
0
 public AidKeyResponseMessage(AidKey AidKey)
 {
     this.AidKey = AidKey;
 }