Author Topic: lobby server not working  (Read 3768 times)

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
lobby server not working
« on: June 20, 2014, 02:59:16 AM »
hi!

is anybody using the current version lobby server?

because i got an unhandled exception.

i tried on linux, and in my own computer, and nothing.

i spent a few hours and found where the error is, but i have no idea why it happens.


in the file TNTcpLobbyServer.cs
at the beggining of the  ThreadFunction () function

  1. void ThreadFunction ()
  2.         {
  3.                 for (; ; )
  4.                 {
  5.                         mTime = DateTime.Now.Ticks / 10000;
  6.  
  7.                         // Accept incoming connections
  8.                         while (mListener != null && mListener.Pending())
  9.                         {
  10.                                 TcpProtocol tc = new TcpProtocol();
  11.                                 tc.data = (long)(-1);                                 /* this is supposed to initialize field data to -1 and it works ok */
  12.                 Console.Write(tc.data);                                              /*  prints -1 which is ok */
  13.                                 tc.StartReceiving(mListener.AcceptSocket()); /* something happens here *************/
  14.                 Console.Write(tc.data);                                             /* doesnt print anything, but no exception is thrown */
  15.                                 mTcp.Add(tc);
  16.                         }
  17.  


later on, in the same function,  when the mTcp[n] data is going to be accessed you get a null reference exception.


  1.                         if (mTcp.size > instantUpdatesClientLimit) mInstantUpdates = false;
  2.  
  3.                         // Send the server list to all connected clients
  4.                         for (int i = 0; i < mTcp.size; ++i)
  5.                         {
  6.  
  7.                 Console.Write(mTcp[0].data);        /* doesnt print anything, but no exception is thrown*/
  8.                 Console.Write(i);                         /* prints 0*/
  9.                                 TcpProtocol tc = mTcp[i];
  10.  
  11.                 Console.Write(tc.data);              /* doesnt print anything, but no exception is thrown*/
  12.    
  13.                                 long customTimestamp = (long)tc.data;   /* ***************** null reference exception .... */
  14.  
  15.  

well...

im out of ideas

any help please?



ps. i am using this code in the client:

         TNServerInstance.serverName = "My test Server";
         TNServerInstance.Start(5127, 0, null, TNServerInstance.Type.Tcp, Tools.ResolveEndPoint("myserver.com:5129"));


yes yes... 2 days and i have only 2 lines of code... and they dont work!

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: lobby server not working
« Reply #1 on: June 20, 2014, 03:59:15 AM »
i think its fair to say, that i managed to make it work using udpLobby instead of tcp.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lobby server not working
« Reply #2 on: June 21, 2014, 05:30:33 PM »
What are you trying to do there? You won't get anything after "tc.StartReceiving(mListener.AcceptSocket())" because it sits there, waiting to actually accept the socket. This is why this is in a separate thread. The code execution will not continue until a connection request arrives.

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: lobby server not working
« Reply #3 on: June 22, 2014, 02:06:55 AM »
well, i thought i had explained myself, but as i allways i didnt :D

yes, i know, and as long as no connection is received the program run just fine.

it is when i start the program in unity, that tries the connection that it hangs.


i deleted the code i had for this because im using the udp version now, which is working fine.

but im pretty sure it was just the connect lines from the tutorial (im talking about unity here).


have you tried running the program and connecting?
im i the only one with the problem??...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lobby server not working
« Reply #4 on: June 22, 2014, 09:35:24 PM »
The example that comes with TNet uses a UDP lobby, and everything connects fine. Changing it to use a TCP lobby would involve spinning an instance of a lobby somewhere and then connecting to it using the TNTcpLobbyClient instead of the TNUdpLobbyClient used by the example. What steps did you take to this regard?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lobby server not working
« Reply #5 on: June 22, 2014, 09:48:19 PM »
Wait, I think I know what you're talking about... C# doesn't like the conversion from null to long, and it occurs because newly connected player sets the player data value, overwriting the server-set value. Change line 188 of TNTcpLobbyServer.cs to:
  1. long customTimestamp = (tc.data == null) ? (long)-1 : (long)tc.data;
That's an issue with the last update that I will have to patch.

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: lobby server not working
« Reply #6 on: June 23, 2014, 12:04:42 AM »
well, i changed it, and tested it and it passed the mentioned point.

the loop executed about 10 times, then ended up giving the same exception in the same point.

it is a progress but there is something that is still wrong.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lobby server not working
« Reply #7 on: June 24, 2014, 05:04:38 AM »
I uploaded 1.9.5c that evening. Did you give that a try?

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: lobby server not working
« Reply #8 on: June 25, 2014, 02:00:18 AM »
i updated and now im back to the TypeLoadException error

this time the try /catch is not working

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: lobby server not working
« Reply #9 on: June 25, 2014, 02:31:49 AM »
ok
solved the typeloadexception issue.

now back to this:

yes!!! it works fine now!!

thanks!!!