View unanswered posts | View active topics It is currently Mon May 18, 2026 3:17 pm



Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next
 C# open source client 
Author Message
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post 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!

_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Tue Aug 23, 2011 9:55 pm
Profile WWW
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post 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 )

_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Wed Aug 24, 2011 3:41 am
Profile WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2559
Location: Oklahoma City, OK 73170 US
Unread post 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?

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/zvEbArscMN


Wed Aug 24, 2011 6:33 am
Profile ICQ YIM WWW
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post 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

_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Wed Aug 24, 2011 2:13 pm
Profile WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2559
Location: Oklahoma City, OK 73170 US
Unread post 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.

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/zvEbArscMN


Wed Aug 24, 2011 5:46 pm
Profile ICQ YIM WWW
Site Admin
User avatar

Joined: Sun Dec 24, 2000 3:00 am
Posts: 3151
Location: USA
Unread post 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.

_________________
John Pritchett
EIS
---
Help fund the TradeWars websites! If you open a hosting account with A2 Hosting, the service EIS uses for all of its sites, EIS will earn credits toward its hosting bill.


Wed Aug 24, 2011 6:08 pm
Profile WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2559
Location: Oklahoma City, OK 73170 US
Unread post 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.

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/zvEbArscMN


Wed Aug 24, 2011 6:13 pm
Profile ICQ YIM WWW
Gameop
User avatar

Joined: Mon Apr 16, 2001 2:00 am
Posts: 419
Location: Denver Colorado
Unread post Re: C# open source client
WHOOSH!

right over my head...

_________________
twarbase.com:23


Wed Aug 24, 2011 9:33 pm
Profile ICQ WWW
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post Re: C# open source client
What just went over your head? LOL

_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Thu Aug 25, 2011 3:44 am
Profile WWW
Commander
User avatar

Joined: Mon Oct 29, 2001 3:00 am
Posts: 1096
Location: Tucson, AZ
Unread post 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.]

_________________
Suddenly you're Busted!


Last edited by Mongoose on Thu Aug 25, 2011 2:41 pm, edited 2 times in total.



Thu Aug 25, 2011 1:49 pm
Profile WWW
Site Admin
User avatar

Joined: Sun Dec 24, 2000 3:00 am
Posts: 3151
Location: USA
Unread post 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.

_________________
John Pritchett
EIS
---
Help fund the TradeWars websites! If you open a hosting account with A2 Hosting, the service EIS uses for all of its sites, EIS will earn credits toward its hosting bill.


Thu Aug 25, 2011 2:34 pm
Profile WWW
Commander
User avatar

Joined: Mon Oct 29, 2001 3:00 am
Posts: 1096
Location: Tucson, AZ
Unread post 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/

_________________
Suddenly you're Busted!


Thu Aug 25, 2011 2:48 pm
Profile WWW
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post 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;


_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Thu Aug 25, 2011 2:51 pm
Profile WWW
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post Re: C# open source client
John Pritchett wrote:
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.


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!

_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Thu Aug 25, 2011 2:54 pm
Profile WWW
Veteran Op
User avatar

Joined: Wed Jul 13, 2011 1:20 pm
Posts: 87
Unread post 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.

_________________
Server: jaceace.com Port 2002 Nodes: 14
Image
On Facebook: http://www.facebook.com/pages/TradeWars-Jaces-Night-Club/184408004953128
Website: http://tradewars.jaceace.com


Thu Aug 25, 2011 2:56 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 36 posts ]  Go to page 1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 50 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.