How to remove data from telnet stream in Winforms Control

0 votes
asked Apr 15, 2016 by jkemp (120 points)

We are currently evaluating the Terminal WinForms Control and so far it has met our needs. However there is one feature I don't see that is a deal-breaker.

My particular situation requires that I be able to sanitize the data coming from the server before it renders. For instance, the server may send ©ABC®. I need to be able to strip the two delimiters and everything between them before they render to the terminal.

I see the DataReceived event but it's after the fact. I also didn't know if I could use the Terminal Emulator in conjunction with the WinForms control to do something like this but I assume the WinForms control is using behind the scene anyway. I haven't really seen anything else in the API.

Any help is greatly appreciated. This is our last hurdle using this product. We can move forward if we can get it working.

Thanks,
John

commented Apr 18, 2016 by Pavel Matyska (13,440 points)
Hello, I am working on the sample code that should help you with stripping incoming data before they are rendered. Please be patient to tomorrow since it is not as simple as it sounds. "What if the starting delimiter is received in a packet and the ending is (probably) received in the next packet and after some time period due to some network lag" is one example for all, what can make an issue.
commented Apr 18, 2016 by jkemp (120 points)
Thank you so much. I look forward to your example.  I understand what you're saying about the packet separation. I've had to deal with those kinds of coding issues as well so I can appreciate the difficulty.

Just to provide more clarity into what's going on, the case I mentioned above is when our system indicates something should be printed to paper but not the screen.

Example)
Item 1 ©Item 1 10®

"Item 1" should print to screen but we redirect "Item 1 10" to the printer.

Thanks again. Just out of curiosity, can you briefly tell me which part of the API (classes or events) you're utilizing to make this happen? If you don't have time I'll just wait until tomorrow.  :)

Thanks!
commented Apr 19, 2016 by Pavel Matyska (13,440 points)
I am enhancing Telnet class implementation of  IShellChannelFactory.CreateShellChannel method, which will be called in Terminal.Bind(IShellChannelFactory) and it will return a wrapper around a ShellChannel which will do the stripping. With your additional information, you'll need not to strip the data, but to fork them. I'll complete the stripping sample, which I believe show you the way to go :)

1 Answer

0 votes
answered Apr 19, 2016 by Pavel Matyska (13,440 points)

Hello, here is a sample code that should help you with stripping data.

Since the code is too long to post it here, you can download a .cs file with the code on our page: http://www.rebex.net/getfile/c72445a757b747e9876dc9060bf4cfef/StrippingTelnet.cs

Please modify it to actually 'fork' the data to the printer and to the screen as you would need. Also, this code do not solve the case if the delimiters are multi-byte characters. It only shows how to parse incoming data before they are processed and rendered to the terminal screen.
The use of these classes is simple as using base Telnet class. I used other characters as delimiters, but the point is the same.

StrippingTelnet client = new StrippingTelnet(server);
client.StartingStripDelimiter = (byte)'#';
client.EndingStripDelimiter = (byte)'*';

// terminal is an TerminalControl or VirtualTerminal instance
terminal.Bind(client);

Please let me know whether you are able to make it work in your scenario.

commented Apr 19, 2016 by jkemp (120 points)
Paval,

Thank you so much for your help. Unfortunately the file does not seem to contain any code. When I try to download it the file is empty. Is there any way you can upload it again?

Thank you
commented Apr 19, 2016 by Pavel Matyska (13,440 points)
Hello, I zipped the file and upload it here:
http://www.rebex.net/getfile/464b3a30b4914b35a636ea26eadb924e/StrippingTelnet.zip

Kind regards
Pavel
commented Apr 19, 2016 by jkemp (120 points)
Pavel,

Thanks. I've received the file successfully. I'll let you know how it goes.

Thanks
...