BASIC

Author Topic: Lobby Network Test 1  (Read 4199 times)

MrTAToad

  • Guest
Lobby Network Test 1
« on: 2011-Mar-04 »
Here is the first part of the testing process to allow Spots to be played over a network.  This first test is just a test of my brand new Lobby code, and as such wont do anything much after a "game" is started... 

Its a 14Mb file (as its intergrated into Spots), and can be downloaded from http://www.zshare.net/download/8734785986604a09/

I've included the host and client screenshots if you haven't seen them already, although they are slightly old...

What I'm hoping to find out is whether there are any problems with the code, aside from the following :

  • XP machines wont connect to Windows 7 (I have had this problem with commercial games, so I'm not too worried about it), and vice-versa
  • Wi-fi computer will connect to a cabled host computer, but not the other way around.  I dont know whether this is to do with the fact that the wireless computer uses DNS for the IP address or whether its all the extra protection given to wifi connections

Both normal and abnormal disconnections should be detected promptly, chat messages should go to the right people and generally things should be good :)

If you think any features could be added, let me know - its possible that a direct connection (as well as one done via the broadcast system) should be included - it could get around the above mentioned problems.


[attachment deleted by admin]

MrTAToad

  • Guest
Re: Lobby Network Test 1
« Reply #1 on: 2011-Mar-04 »
And now onto the code...

Code: GLBasic [Select]
CONSTANT MAX_PLATFORMLENGTH%                                    =       12
CONSTANT FONT_DEFAULT%                                                  =       0
CONSTANT SOUND_INVALID%                                                 =       -1
CONSTANT NO_DATA$                                                               =       "NO_DATA"
CONSTANT NO_PLATFORM$                                                   =       "N/A"
CONSTANT NO_COUNTRY$                                                    =       "N/A"
CONSTANT INVALID_DATA%                                                  =       -1      // So it can be used with file handles, sprites etc
CONSTANT CLICKED$                                                               =       "CLICKED"
CONSTANT SLECTED$                                                               =       "SELECT"
CONSTANT TEXT$                                                                  =       "TEXT"
CONSTANT HANDLE_LEFT%                                                   =       -1
CONSTANT HANDLE_TOP%                                                    =       -1
CONSTANT HANDLE_MIDDLE%                                                 =       0
CONSTANT HANDLE_RIGHT%                                                  =       1
CONSTANT HANDLE_BOTTOM%                                                 =       1
CONSTANT SEPERATOR$                                                             =       "/"

Code: GLBasic [Select]
                MENU_PREVIOUSMENU%              =       0
        MENU_CREATENETWORKGAME% =       1
        MENU_JOINNETWORKGAME%   =       2


                gameMode%=self.chooseNetworkType()
                SELECT gameMode%
                        CASE    self.MENU_CREATENETWORKGAME%    // Create a game
                                                                                                        self.lobby.CreateNetworkGame(self.setup,TRUE)

                        CASE    self.MENU_JOINNETWORKGAME%              // Join a game
                                                                                                        self.lobby.CreateNetworkGame(self.setup,FALSE)
                ENDSELECT

        FUNCTION chooseNetworkType%:
        LOCAL windowWidth%,windowHeight%,buttonSize%,buttonHeight%=32

                self.setup.createAWindow("What Would You Like To Do ?",windowWidth%,windowHeight%,140)

                DDgui_widget("a","Please Select A Network Mode",0,0)
                DDgui_set("a","ALIGN",0)

                DDgui_button("hostGame","Host A Network Game",windowWidth%-8,buttonHeight%)
                DDgui_button("joinGame","Join A Network Game",windowWidth%-8,buttonHeight%)
                DDgui_button("back","Previous Menu",windowWidth%-8,buttonHeight%)

                WHILE TRUE
                        ALPHAMODE 0.0
                        SMOOTHSHADING FALSE
                        DDgui_show(FALSE)
                        SHOWSCREEN
                        HIBERNATE

                        IF DDgui_get("hostGame",CLICKED$)
                                DDgui_popdialog()
                                RETURN self.MENU_CREATENETWORKGAME%
                        ELSEIF DDgui_get("joinGame",CLICKED$)
                                DDgui_popdialog()
                                RETURN self.MENU_JOINNETWORKGAME%
                        ELSEIF DDgui_get("back",CLICKED$)
                                DDgui_popdialog()
                                RETURN self.MENU_PREVIOUSMENU%
                        ENDIF
                WEND
        ENDFUNCTION

and the included files should be all thats needed :)

The routine just uses UDP data, with mostly reliable messaging.  Whilst it may seem an over-kill, its needed for broadcasting and proper detection of disconnections.

Let me know if anything is missing or could be improved :)  The code should be put in an extended type, dont forget!

[attachment deleted by admin]
« Last Edit: 2011-Mar-04 by MrTAToad »

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: Lobby Network Test 1
« Reply #2 on: 2011-Mar-06 »
I don't know what's going on but I've tried to download the app from zshare three times now, two yesterday, and it has failed each time. It starts downloading like normal but shows incredibly slow speed, then gets to 277Kb and stops completely. Could you re-up somewhere else?

MrTAToad

  • Guest
Re: Lobby Network Test 1
« Reply #3 on: 2011-Mar-06 »
Yes, it does seem to be having problems  :rant:

Can you try this : http://cid-99ee8a23e2fc4a0f.office.live.com/browse.aspx/Files

Offline Moebius

  • Dr. Type
  • ****
  • Posts: 315
    • View Profile
Re: Lobby Network Test 1
« Reply #4 on: 2011-Mar-06 »
Spots is looking very nice!  Obviously you haven't fully 'integrated' networking (I can't seem to find the option from the main menu), but there are a few issues I've found:

- If you click 'join' when there are no servers listed, the app crashes (accessing non-existent array index?)

- Clicking the back button when hosted causes the game to close - I'm not sure if this is a crash, or if it's intentional.

- The 'back' button when in the joining lobby does nothing.

- When joining or hosting and there are no servers/players listed, the text 'Chat List' overlaps the input box for chat and is a bit too close to 'List of Servers' and 'List of Players'.

- It seems that a client can't find a server hosted on the same machine.  This isn't really a 'problem' I guess - not many people (aka me) would contemplate connecting to your own computer from your own computer when you have multiplayer already in the game...

- While waiting in the lobby it seems to be VERY CPU intensive!  Continuously using up 15% of Core 2 Quad while doing nothing!

- The host app doesn't seem to update the GUI when clients join or when chat occurs.  I can chat, and it comes up on the client, but the host's GUI doesn't update.

- After I leave a game I joined in 'Join' mode, the 'Ready' button doesn't change back to a 'Join' button, so I can't join other games...


Some aren't that serious and are probably things you haven't done yet, others are quite serious, and I'm not sure why they're occuring...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

MrTAToad

  • Guest
Re: Lobby Network Test 1
« Reply #5 on: 2011-Mar-06 »
Quote
If you click 'join' when there are no servers listed, the app crashes (accessing non-existent array index?)
Yes, it does unfortunately.  Need to look at that

Clicking BACK does nothing at the moment, as I haven't decided where it should go back to yet

Quote
When joining or hosting and there are no servers/players listed, the text 'Chat List' overlaps the input box for chat and is a bit too close to 'List of Servers' and 'List of Players'.
It sounds like you are using a resolution greater than 320 x 200 - which I haven't checked the layout yet.

Quote
It seems that a client can't find a server hosted on the same machine
It causes so many problems, I dont support it :)  Plus,it slows the computer down so much...

Quote
While waiting in the lobby it seems to be VERY CPU intensive!  Continuously using up 15% of Core 2 Quad while doing nothing!
Its actually doing a lot (continually checking for network messages, for example).  Unfortunately the program cant hibernate.  However, the continual screen updates may not be needed and could solve that problem...

Quote
The host app doesn't seem to update the GUI when clients join or when chat occurs.  I can chat, and it comes up on the client, but the host's GUI doesn't update.
Did you select a player (a player was highlighted) before sending the chat message ?  If so, that sends a message to that specific person.

Quote
After I leave a game I joined in 'Join' mode, the 'Ready' button doesn't change back to a 'Join' button, so I can't join other games.
Will have to look at that!

Thanks for trying the program. Hopfully test 2 will have solved those problems:)

Offline Moebius

  • Dr. Type
  • ****
  • Posts: 315
    • View Profile
Re: Lobby Network Test 1
« Reply #6 on: 2011-Mar-06 »
Quote
It sounds like you are using a resolution greater than 320 x 200 - which I haven't checked the layout yet.
Yes - I was using something closer to 1000 x something.  Fair enough anyway - making it work with multiple resolutions can be done once the more important stuff is in place.

Quote
It causes so many problems, I dont support it   Plus,it slows the computer down so much...
Fair enough - considering you have multiplayer within the app there is absolutely no reason to support this anyway!  Do you filter out broadcasted messages from your own IP address or something similar?

Quote
Its actually doing a lot (continually checking for network messages, for example).  Unfortunately the program cant hibernate.  However, the continual screen updates may not be needed and could solve that problem...
I know, but maybe a sleep or something is possible?  I don't know exactly what's going on behind the scenes and how much messaging is leading to the CPU usage, but checking for other devices, say, 10 times a second should be enough right?

Quote
Did you select a player (a player was highlighted) before sending the chat message ?  If so, that sends a message to that specific person.
I'm not sure - neat feature BTW - and unfortunately I can't really test again for a while.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

MrTAToad

  • Guest
Re: Lobby Network Test 1
« Reply #7 on: 2011-Mar-06 »
Quote
Do you filter out broadcasted messages from your own IP address or something similar?
Yes, broadcast messages are filtered so that the sender will ignore them.

Quote
I know, but maybe a sleep or something is possible?
Its certainly something to look into...

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: Lobby Network Test 1
« Reply #8 on: 2011-Mar-08 »
Nothing to add to what Serpent said since I saw some of the same things. However, when you wrote...

Quote
Wi-fi computer will connect to a cabled host computer, but not the other way around.  I dont know whether this is to do with the fact that the wireless computer uses DNS for the IP address or whether its all the extra protection given to wifi connections

...well I found that I could host or join regardless of whether I was connecting to or from a wi-fi computer to a cable computer, so there are exceptions to the above.

Been a while since I played Spots. I like how far its come along. Last time I played there wasn't an arcade mode for instance. That's a lot of fun.

MrTAToad

  • Guest
Re: Lobby Network Test 1
« Reply #9 on: 2011-Mar-08 »
Quote
...well I found that I could host or join regardless of whether I was connecting to or from a wi-fi computer to a cable computer, so there are exceptions to the above
Probably my router then :)

And the game is coming along very well.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1774
    • View Profile
    • Homepage
Re: Lobby Network Test 1
« Reply #10 on: 2011-Mar-08 »
The problem about not being able to connect over wifi is a wifi security thing on your router, wifi is not allowed to talk to the rest of the network because of hacking issues.

MrTAToad

  • Guest
Re: Lobby Network Test 1
« Reply #11 on: 2011-Mar-09 »
Yes, I could really do with a new one :) 

The next part I'm working on is seperation of host setup GUI from the program loop (so the user can modify some settings whilst the lobby part is running).

The host display layout hasn't really changed as such - it just now displays a bit more data :)
« Last Edit: 2011-Mar-09 by MrTAToad »