| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| C# open source client https://mail.black-squirrel.com/viewtopic.php?f=14&t=32128 |
Page 1 of 3 |
| Author: | jaceace01 [ Tue Aug 23, 2011 9:55 pm ] |
| Post subject: | C# open source client |
Been real busy havent stopped in much. I have been working on an gnu open source client for use with twgs server. It will be FREE and open source. Haha said open source twice! Anyway. I got it logging into the game and logging out. Got alot of the ansi working... alot to do... but getting there.... Hopefully another week or so and you will be able to check it out! |
|
| Author: | jaceace01 [ Wed Aug 24, 2011 3:41 am ] |
| Post subject: | Re: C# open source client |
Someone asked if I was using wpf... so i figured others may have same question. Here are my using statements: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; using System.Threading; Remember all code will be released later when done. But in case your wondering.... i just open a socket, read and write to the socket, and add a way to interpret the code recieved and display it to the screen... easy.... Now interpretting ansi takes some time.... This client is 100% original code. No outside code. It also is not a telnet client as if, telnet everywhere, it is made to connect to our favorite friend twgs. was thinkin of calling it An Berry - it would then be said in forums Do you connect to twgs with an berry? Haha ( stupid humor , i know ) |
|
| Author: | Micro [ Wed Aug 24, 2011 6:33 am ] |
| Post subject: | Re: C# open source client |
jaceace01 wrote: Someone asked if I was using wpf... so i figured others may have same question. Windows Presentation Foundation (WPF) is a project type. looking at your using statements, I would guess that you project type is a console application? |
|
| Author: | jaceace01 [ Wed Aug 24, 2011 2:13 pm ] |
| Post subject: | Re: C# open source client |
Ah...havent tried working with anything other than console because alot of ansi codes require moving a cursor around on the screen to display properly... I would probably expand upon what i am building once i get it working. I had to use 1252 encoder to get the proper look too.... That took a day to figure out... haha |
|
| Author: | Micro [ Wed Aug 24, 2011 5:46 pm ] |
| Post subject: | Re: C# open source client |
Well, I'm using WPF, and my display choices are a Rich Text Box (RTB), or the browser control. I chose the Rich Text box. The first problem I had was converting CP437 into unicode. I spent a lot of time trying to find the right font, but it turns that a decode method in .net was needed instead. The next problem was that ANSI color changes. Changing the default color and then adding the next span of text was so inefficient that it took 5 minutes to display a single page ANSI screen. I resolved this by created a full line of text before appending it to the RTB. As you probably know, there are no rows or columns in a RTB. So when I started coding ANSI movement I had to create an array of characters 80 x 24 in memory and then use a timer to clear the RTB and then dump the array over to the RTB. This isn't very efficient, so I am looking for a better method. |
|
| Author: | John Pritchett [ Wed Aug 24, 2011 6:08 pm ] |
| Post subject: | Re: C# open source client |
Just throwing this out there. I do direct output to a canvas using textout functions rather than work with a bloated component like an edit or richtext box. I write to an internal bitmap, then I can copy blocks to the gui canvas as needed. I've also experimented with using small graphical tiles of the character set and constructing an image of the output that way. That's how it's done in the php module ANSILove that generates ANSI images as PNG. That works pretty good. You don't have to worry about codepages, encoding or fonts that way. But I also handle output in the console for debug purposes and that's pretty fast as well. |
|
| Author: | Micro [ Wed Aug 24, 2011 6:13 pm ] |
| Post subject: | Re: C# open source client |
JP, I was already thinking in the direction you are talking about. I think it will be a lot faster than the RTB, and it would probably fix the line spacing problems I'm having. |
|
| Author: | Master Blaster [ Wed Aug 24, 2011 9:33 pm ] |
| Post subject: | Re: C# open source client |
WHOOSH! right over my head... |
|
| Author: | jaceace01 [ Thu Aug 25, 2011 3:44 am ] |
| Post subject: | Re: C# open source client |
What just went over your head? LOL |
|
| Author: | Mongoose [ Thu Aug 25, 2011 1:49 pm ] |
| Post subject: | Re: C# open source client |
How are you connecting to TWGS without implementing Telnet? When I started messing with my own helper, I found that TWGS 2.07 sends the Telnet option negotiation "IAC WILL AYT". If you don't respond to this (malformed) option, TWGS decides you're not a Telnet client and disconnects you. If I understand the Telnet RFC correctly, "IAC WILL AYT" is wrong; AYT is a command, not an option, so it should just be "IAC AYT". It satisfies the TWGS if you simply respond with "IAC DONT AYT", and that's how Telnet NVT should respond to unrecognized or unsupported options, anyway. [Edited: DONT is the correct response to an unrecognized WILL. WONT is the correct response to an unrecognized DO. I forget which it is that TWGS does. Either way, a proper Telnet client shouldn't have a problem with it.] |
|
| Author: | John Pritchett [ Thu Aug 25, 2011 2:34 pm ] |
| Post subject: | Re: C# open source client |
Funny ;) Thanks, Mongoose. I probably shouldn't fix that, though, for fear of breaking apps that have learned to live with TWGSs creative use of the Telnet protocol. I explained before that TWGS sends a set of Telnet configuration options but does not pay any attention to telnet commands after that. TWGS is not a telnet server. The initial login negotiation is meant to differentiate between Telnet and RLogin, because TWGS supports both. It should have been IAC+AYT, but whenever a bug has no observable negative effect, it's difficult to catch. Been this way since 1998 or so. |
|
| Author: | Mongoose [ Thu Aug 25, 2011 2:48 pm ] |
| Post subject: | Re: C# open source client |
Anyway, Jace: If you end up using a flex lexer for your parser, let me know so we can collaborate. I'm writing one in KFlex, which is an extension I wrote for JFlex, and JFlex has been ported to C#: https://sourceforge.net/projects/csflex/ |
|
| Author: | jaceace01 [ Thu Aug 25, 2011 2:51 pm ] |
| Post subject: | Re: C# open source client |
Here's some of the code i am writing some of the methods Code: public Boolean connect(string ipHost, int port, Boolean makeNegotiation) { this.socketHost = ipHost; this.socketPort = port; this.ipHostInfo = Dns.GetHostEntry(socketHost); this.ipAddress = ipHostInfo.AddressList[0]; this.remoteEP = new IPEndPoint(ipAddress, socketPort); Boolean results = this.connect(); if (results == true) { results = this.negotiate(); } return results; } Thats the connect method Now the negotiate method is Code: public Boolean negotiate() { if (this.connected == true) { this.Send(this.client, "IAC DO SUPPRESS_GO_AHEAD"); this.sendDone.WaitOne(); if (this.sendResults == true) { this.Receive(this.client); this.receiveDone.WaitOne(); if (this.recieveResults == true) { // All is good now this.connected = true; return this.connected; } else return this.recieveResults; } else { return this.sendResults; } } else return false; } Basicly, I connect to the server. I send IAC DO SUPPRESS_GO_AHEAD which is really a byte code as below, I get a response back from server... Which I mapped out the response. Its just a bunch of settings - Not needed for a client for twgs. So I discard all the responses. Then I am connected. Twgs does disconnect for inactivity. So i always watch for a disconnect signal. I am sure when i got the "foundation" done. Alot of people will check it out - maybe? Code: if (data == "IAC DO SUPPRESS_GO_AHEAD") { byteData = new byte[3]; byteData[0] = TelnetCodes.IAC; byteData[1] = TelnetCodes.DO; byteData[2] = TelnetCodes.SUPPRESS_GO_AHEAD; } These are some of the codes i placed in program below: public const byte NULL = 0; public const byte IAC = 255; public const byte WILL = 251; public const byte WONT = 252; public const byte DO = 253; public const byte DONT = 254; public const byte SB = 250; public const byte SE = 240; // Telnet Options public const byte ECHO = 1; public const byte SUPPRESS_GO_AHEAD = 3; public const byte STATUS = 5; public const byte TERMINAL_TYPE = 24; public const byte WINDOW_SIZE = 31; public const byte TERMINAL_SPEED = 32; public const byte REMOTE_FLOW_CONTROL = 33; public const byte LINEMODE = 34; public const byte ENVIRON = 36; public const byte NEW_ENVIRON = 39; |
|
| Author: | jaceace01 [ Thu Aug 25, 2011 2:54 pm ] |
| Post subject: | Re: C# open source client |
John Pritchett wrote: Funny I explained before that TWGS sends a set of Telnet configuration options but does not pay any attention to telnet commands after that. TWGS is not a telnet server. The initial login negotiation is meant to differentiate between Telnet and RLogin, because TWGS supports both. It should have been IAC+AYT, but whenever a bug has no observable negative effect, it's difficult to catch. Been this way since 1998 or so. Jp, dont change anything. Everything works great for making a client. All any one has to do is make a socket connection send the iac surpress go ahead and connection made. Easy. Lets not make it hard! |
|
| Author: | jaceace01 [ Thu Aug 25, 2011 2:56 pm ] |
| Post subject: | Re: C# open source client |
Mongoose wrote: Anyway, Jace: If you end up using a flex lexer for your parser, let me know so we can collaborate. I'm writing one in KFlex, which is an extension I wrote for JFlex, and JFlex has been ported to C#: https://sourceforge.net/projects/csflex/ i dont know what a flex lexer is... I write all code using Visual Studios 2008 and this client has no outside source code. Its all original code written by me. I am not using anyones code. |
|
| Page 1 of 3 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|