Author Topic: Virtual Server Error  (Read 555 times)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Virtual Server Error
« on: May 26, 2017, 07:31:09 PM »
2 more virtual server errors.  Error #1 I can repro.  Error #2 is likely something to do with TNManager.SetPlayerSave.

Note:
- I have deleted server.dat - before, during, between and after.
- all code works fine as a standalone. zero error's.

These error's happen when you connect/disconnect and then try to re-connect.

Error #1 Repro
----------------------
- Create a new project
- Import TNet and NGUI
- Import the attached "TNet Repro.unitypackage"
- Apply the following mod's

TNPacket.cs:
  1. //add these
  2. Request_TestPacket = 129,
  3. Response_TestPacket = 130,

TNGameServer.cs:
  1. #if STANDALONE
  2.                 Tools.Log("Admins: " + mAdmin.size);
  3.                 Tools.Log("Bans: " + mBan.size);
  4.                 Tools.Print("Game server started on port " + tcpPort + " using protocol version " + Player.version);
  5. #endif
  6.  
  7. Repro_Start();//line #297 insert this

TNGameServer.cs: (insert at line #2694 -- after "public bool Load(string fileName)")
  1. #region repro
  2.  
  3. private void Repro_Start()
  4. {
  5.         onCustomPacket += Repro_OnCustomPacket;
  6. }
  7.  
  8. private void Repro_OnCustomPacket(TcpPlayer player, Buffer buffer, BinaryReader reader, Packet request, bool reliable)
  9. {
  10.         switch (request)
  11.         {
  12.                 case Packet.Request_TestPacket:
  13.                         {
  14.                                 string message = reader.ReadString();
  15.                                
  16.                                 BinaryWriter writer2 = BeginSend(Packet.Response_TestPacket);
  17.                                 writer2.Write("message: " + message);
  18.                                 EndSend(true, player);
  19.  
  20.                                 break;
  21.                         }
  22.                 default:
  23.  
  24.                         Tools.Log("OnCustomPacket: " + string.Format("[{0}] name: {1}   request: {2}", player.id, player.name, request));
  25.  
  26.                         break;
  27.         }
  28. }
  29.  
  30. #endregion




Error #2
----------------------
Couple notes on error #2. 

- If I connect/disconnect -- delete server.dat -- reconnect -- Error #2 does not happen, but the code stops executing and halts progress.  This is why i believe the error is related to TNManager.SetPlayerSave.

- I did a ton of debugging and the packet that is being processed is the SetPlayerSave packet.




devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Virtual Server Error
« Reply #1 on: May 26, 2017, 07:45:57 PM »
solved the problem seconds after posting.

added:  onCustomPacket -= Repro_OnCustomPacket; in the Stop() method to fix the issue.

of course stand-alone never stops and the error never happens.