Friday 8 January 2010

Globe Authentication and Networking

This is my 2nd blog post and although not much progress has happened over the last couple of days due to me having some kind of flu, there has been progress since my last post, so heres the story so far.

The initial design for the login system was ready, it consisted of plans to create a Visual Studio 2008 solution containing a client XNA project, a data layer project for communication with SQL, a database relevant to user login, and a web service project for the XNA client to authenicate with.

The first problem I hit which I hadn't considered, was that although I have created some branding design and screen wireframes, I had assumed XNA would contain some kind of standard UI elements. I seemed to remember a long time ago using DirectX libraries for something and was sure that had UI elements built in. XNA does not.

So, first stop we need to create a UI system to enable users to enter text and all the other usual windows things like buttons.

I created a new class library project called TheGlobe.UI, this project contains an interface called IXnaControl which defines a base control that all other controls inherit. In the root namespace there is a class called UIManager which is responsible for rendering and overall control of all UI elements. I then created XnaTextbox and XnaButton classes which inherit from IXnaControl.

The result was a very nice object orientated self contained UI library, which works very well and is very easy to implement in XNA projects.

Ok, so with that huge show stopper out of the way I created a basic login screen in the client XNA project. The screen just shows the logo in the top left and has a sliding glowing panel at the bottom which moves up and down when clicked and contains some textboxes and a button for logging in.

I created the database and the login relevant tables, the data layer methods i needed for the login process and the authentication web service.

Then I hit big problem number 2.
An XNA project cannot reference web services.

The path I chose around this problem, was to scrap the web service, and create a custom multi-threaded TCP server. I decided to implement most of the functionality in a seperate class library, so that it can be consumed easily by a console application or windows service. So I added TheGlobe.LoginServer class library and TheGlobe.LoginServer.Console host application.

We are now up to present time.

My next steps are going to be implementing some basic client socket code into the XNA project, so it can communicate with the new TCP login server. Then test connectivity.

The overall goal of this stage is to keep everything as simple as possible, whilst allowing the user to login to the world. Then I can move onto actually loading terrain and skyboxes etc.

Please leave your comments and thoughts.

Developer Monkey.

2 comments:

  1. I'm not sure what your thoughts are on OpenGL, but there's a belief out there that it's better, faster and more powerful than DirectX.. Also - completely platform independent :)

    Here's a really nice article, and a lot of related info in the comments about it :)
    http://blog.wolfire.com/2010/01/Why-you-should-use-OpenGL-and-not-DirectX

    ReplyDelete
  2. Hey Artiom, thats a great article. There seems to be a heated argument raging over DirectX versus OpenGL.

    Having taken some of those points into consideration and the turnaround time of a conversion to OpenGL at this stage, I am going to have to stick to XNA.

    The article brings up some interesting points.

    ReplyDelete