Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: Elmo loves cookies on September 04, 2016, 05:12:54 PM

Title: Tnet 3.0 info about need update
Post by: Elmo loves cookies on September 04, 2016, 05:12:54 PM
I try to use

  1. override protected void OnConnect(bool result, string message)
  2.     {
  3.         if (result)
  4.         {
  5.             goToGame();
  6.         }
  7.         else
  8.         {
  9.             showUpdateMenu();
  10.         }
  11.     }

but showUpdateMenu(); - never work, because Player.version (on server != on player)

How I can show massage to player for Need Update the Game (if Player.version different)?
Title: Re: Tnet 3.0 info about need update
Post by: devomage on September 05, 2016, 02:01:10 AM
TNPlayer.cs - line #73
public const int version = 20160207;

change to:
public const int version = 20160904;//force version error




  1. using UnityEngine;
  2. using TNet;
  3.  
  4. public class versiondemo : TNBehaviour
  5. {
  6.     private static versiondemo instance = null;
  7.  
  8.     public string address = "192.168.1.107";
  9.     public int port = 10420;
  10.  
  11.     protected override void OnEnable()
  12.     {
  13.         base.OnEnable();
  14.  
  15.         //subscribe to events
  16.         //both will provide version error
  17.         TNManager.onConnect += OnConnect;
  18.         TNManager.onError += OnError;
  19.     }
  20.    
  21.     private void OnDisable()
  22.     {
  23.         TNManager.onConnect -= OnConnect;
  24.         TNManager.onError -= OnError;
  25.     }
  26.  
  27.     private void Awake()
  28.     {
  29.         instance = this;
  30.     }
  31.  
  32.     [ContextMenu("Connect")]
  33.     private void Connect()
  34.     {
  35.         if (instance == null) return;
  36.  
  37.         TNManager.Connect(instance.address, instance.port);
  38.     }
  39.  
  40.     private void OnError(string msg)
  41.     {
  42.         Debug.Log("OnError: " + msg);
  43.  
  44.         //result:
  45.         //OnError: Version mismatch! Server is running a different protocol version!
  46.     }
  47.    
  48.     private void OnConnect(bool success, string message)
  49.     {
  50.         Debug.Log(string.Format("OnConnect: success={0} message={1}", success, message));
  51.  
  52.         //result:
  53.         //OnConnect: success=False message=Version mismatch! Server is running a different protocol version!
  54.  
  55.         //if (!success && message == "...") dothis();
  56.         //else dothat();
  57.     }
  58. }
  59.  
Title: Re: Tnet 3.0 info about need update
Post by: ArenMook on September 05, 2016, 08:09:08 AM
The current TNet's player version is actually 20160822. Both server and client need to be running the same version.
Title: Re: Tnet 3.0 info about need update
Post by: devomage on September 06, 2016, 05:34:40 AM
20160822 (client) is definitely not backwards compatible with 20160207 (server)... which makes my example useless.  In this case, onConnect and onError do not fire when trying to connect.
Title: Re: Tnet 3.0 info about need update
Post by: ArenMook on September 06, 2016, 10:23:58 AM
I recompile the server every time I put up a new update. Did you update your server's executable?