Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - EdLan

Pages: [1]
1
TNet 3 Support / Re: IP address of iPhone in network
« on: May 29, 2013, 03:07:17 PM »
For all where need a cross platform solution I suggest to use some code mentioned below because of platform specific problems. iOS has problems with Dns.GetHostEntry(Dns.GetHostName()) solution and Android devices have problems with the NetworkInterface.GetAllNetworkInterfaces() solution. So this should work on all platforms:

  1. #if UNITY_IPHONE
  2. using System;
  3. using System.Net.NetworkInformation;
  4. using System.Linq;
  5. #endif

.
.
.

  1.         static public IPAddress localAddress {
  2.        
  3.         get {
  4.                                
  5.             if (mLocalAddress == null) {
  6.  
  7. #if UNITY_IPHONE       
  8.                                        
  9.                 NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
  10.  
  11.                 foreach (NetworkInterface ni in nis) {
  12.                                                
  13.                     IPInterfaceProperties IPInterfaceProperties = ni.GetIPProperties();
  14.                     UnicastIPAddressInformationCollection UnicastIPAddressInformationCollection = IPInterfaceProperties.UnicastAddresses;
  15.  
  16.                     foreach (UnicastIPAddressInformation UnicastIPAddressInformation in UnicastIPAddressInformationCollection) {
  17.                                                        
  18.                         if (UnicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork) {
  19.                                                                
  20.                             mLocalAddress = UnicastIPAddressInformation.Address;
  21.                             break;
  22.                                                                
  23.                         }
  24.                                                        
  25.                     }
  26.                                                
  27.                 }
  28.  
  29. #else
  30.                                        
  31.                                 mLocalAddress = IPAddress.Loopback;
  32.  
  33.                                 try
  34.                                 {
  35.                                         IPHostEntry ent = Dns.GetHostEntry(Dns.GetHostName());
  36.  
  37.                                         foreach (IPAddress ip in ent.AddressList)
  38.                                         {
  39.                                                 if (IsValidAddress(ip))
  40.                                                 {
  41.                                                         mLocalAddress = ip;
  42.                                                         break;
  43.                                                 }
  44.                                         }
  45.                                 }
  46.         #if DEBUG
  47.                                 catch (System.Exception ex)
  48.                                 {
  49.                                         System.Console.WriteLine("TNTools.LocalAddress: " + ex.Message);
  50.                                 }
  51.         #else
  52.                                 catch (System.Exception) {}
  53.         #endif
  54.        
  55. #endif
  56.                                        
  57.             }
  58.        
  59.             return mLocalAddress;
  60.                                
  61.         }
  62.                
  63.         }

2
TNet 3 Support / Re: IP address of iPhone in network
« on: May 29, 2013, 09:23:36 AM »
You may have to do something like the following code. Of course you have to refine that stuff, because there can be more that one NIC with a IPv4 Address attached to (or inside of) a particular device and for that you may have to take care:

  1.         static public IPAddress localAddress {
  2.        
  3.                 get {
  4.        
  5.                     List<IPAddress> addressList = new List<IPAddress>();
  6.  
  7.                     NetworkInterface[] NetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
  8.  
  9.                     foreach (NetworkInterface NetworkIntf in NetworkInterfaces) {
  10.  
  11.                         IPInterfaceProperties IPInterfaceProperties = NetworkIntf.GetIPProperties();
  12.                         UnicastIPAddressInformationCollection UnicastIPAddressInformationCollection = IPInterfaceProperties.UnicastAddresses;
  13.  
  14.                         foreach (UnicastIPAddressInformation UnicastIPAddressInformation in UnicastIPAddressInformationCollection) {
  15.  
  16.                             if (UnicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork) {
  17.  
  18.                                 //Console.WriteLine(UnicastIPAddressInformation.Address);
  19.  
  20.                                 addressList.Add(UnicastIPAddressInformation.Address);
  21.                                                         mLocalAddress = UnicastIPAddressInformation.Address;
  22.                             }
  23.                         }
  24.                     }
  25.                         //return addressList;
  26.                         return mLocalAddress;  
  27.                 }
  28.                
  29. }

I hope this helps you a little bit to fix that annoying bug.

Cheers, EdLan

P.S. Tested on OS X 10.8, iOS 6. On Android 4.2.x this version seems to make problems (I didn't had a deeper look at that right now). So may you have to implement both (refined) versions with precompiler conditions, or something like that.

BTW the mentioned version which seems to work on iOS uses:

using System;
using System.Net.NetworkInformation;
using System.Linq;

3
TNet 3 Support / Re: IP address of iPhone in network
« on: May 29, 2013, 07:57:53 AM »
Nope... Now it crashes.

With you mentioned solution we get the following error message when trying to addd a new server to the lobby server:

  1. Internal_GetPlayer  can only be called from the main thread.
  2. Constructors and field initializers will be executed from the loading thread when loading a scene.
  3. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

4
TNet 3 Support / Re: IP address of iPhone in network
« on: May 28, 2013, 04:38:56 PM »
I have same issue... Could it be related to that problem they mention here? :

http://wiki.etc.cmu.edu/unity3d/index.php/Network_issue_on_iOS


5
TNet 3 Support / Re: Feature request: Server ID in Serverlist
« on: May 28, 2013, 03:25:35 PM »
Well... I guess that's not a very professional solution. As more changes are done in your code as more changes I have to incorporate when an updated comes (like the 1.7.0 some days ago with some bug fixes).

 

6
TNet 3 Support / Re: Feature request: Server ID in Serverlist
« on: May 28, 2013, 02:51:02 PM »
In my case nope...

I have a custom package with additional server informations which is handled by my (custom) derived lobby server. No when a user selects a server from the known server list an some additional information about that specific server could be requested from the lobby server.

And it definitely would be easier and more elegant to make this by a server id instead of two combined IPEndpoint variables.

Cheers, EdLan

7
TNet 3 Support / Feature request: Server ID in Serverlist
« on: May 28, 2013, 02:08:01 PM »
Hi ArenMook

Is there a reason, that Gameserver ID is not available in the Serverlist and Entry object ? This ID would it make easier to identify Gameservers instead of using a combination of the internal and external IPEndPoints as unique key. Or did I miss something?

Cheers, EdLan

8
TNet 3 Support / TNServerInstance.MakePrivate();
« on: May 28, 2013, 08:16:33 AM »
Hi @all

How can a game server which is marked as private with TNServerInstance.MakePrivate being marked as public again?

Cheers, EdLan

9
Hi @all

Currently I want to add in my server list (where the clients get from a centralized lobby server) an individual ping value which shows the ping value between client to another remote host.

Imagine following scenario:

- One centralized lobby server which is located for example in the USA
- One player which starts a game server to initiate a multiplayer game. This host will announce itself to the lobby server mentioned before. This player is located for example in Europe.
- Another player, which is also located in Europe goes trough the server list lobby and wants to pick a server with a low latency time.

In this situation it's very likely, that the two players which are both located in Europe will have a low ping latency.

But how do I get this ping value without connecting each server from the lobby server list separately with a TNManager.Connect(abc),  TNManager.ping and then last but not least disconnect with TNManager.Disconnect()?

Isn't there a more elegant way? I was considering a sum of the ping value from player A to the lobby server and summarize it with the ping value of player B to the lobby server. But this solution would definitely not reflect the "real world" situation when we look at the scenario mentioned before, because the latency between both players located in Europe would probably be much smaller when they would connect directly compared to the sum of both ping values (ping from player A to lobby server summarized with player B to the lobby server...

Has anyone a nice solution for that without connecting to each game host separately?

Cheers, EdLan

10
NGUI 3 Support / Re: Strage UIGrid / UIDraggablePanel behave
« on: May 11, 2013, 05:48:12 PM »
Ok... Got it! The layer was not set to the NGUI layer...  ::)

11
NGUI 3 Support / Strage UIGrid / UIDraggablePanel behave [SOLVED]
« on: May 11, 2013, 05:33:29 PM »
Hi @all

Currently I have a strange behave, when I try to add prefabs with a UIDrag Panel Content Object attached per script to a UIGrid. Here is my code to add a prefab to the grid:

  1.                         GameObject item = NGUITools.AddChild(ListGrid.gameObject, prefabEntry);
  2.                        
  3.                         item.GetComponent<UIDragPanelContents>().draggablePanel = DraggablePanel;
  4.                        
  5.                         UILabel label = item.transform.FindChild("Label").GetComponent<UILabel>();
  6.  
  7.  

When I run this code on runtime, then the items of the grid are not movable. They don't react on mouse events when I try to scroll the grid content up and down.

When I add the same prefab(s) to the grid in the Editor, then it works without any problem. Has anyone an idea what I forgot? Currently I use NGUI 2.6.1e

Cheers, EdLan

12
Hi Aren

Thanks for your feedback. This seems to work fine and I'm currently at the implementation of my new TCP lobby packages.

One further question: What's the best way to create custom events / delegates when the TNTcpLobbyLink gets a TCP package from the lobby server. I want to fire en event / define a delegate, which can be handled in our main class, when use TNTcpLobbyLink gets a package.

Is there something built in which I can use / extend?

Cheers, EdLan

13
Hi ArenMook

Thanks for your reply. The idea is that I have also some dynamic data inside of an SQL DB (like for example user verification data, game informations, and so on). The "Master Data Server" should connect to that SQL DB and responds to requests from each game client. So the load / save data seems not to be the an elegant way to handle this...

Thanks a lot, EdLan

14
Dear Cummunity

I would like to realize a game with the following server / client concept:

- A Master Lobby Server (TNet Lobby Server Client)
- A Master Data Server (TNet Server / Client ) (for Login evaluation, centralized profile storage, etc.) This server should be connected from every game client directly to load / save profile data (for example). This server has a connection to a database with user and group data.
- And last but not least a Game Server (TNet Server / Client ) which is local. This should handle the normal game object sync.

Currently I have a centralized lobby server and the "local" game server which handles the object syncing, and so on. But I'm not sure what's the best way to realize the centralised Master Data Server. Should I create a second TNet Instance which communicates to the master server? This may could be fine because of the RFC event system. Or should I implement an own TCP handler to communicate to the master server, but

The reason for the "Master Data Server" is, that I don't want, that the game clients directly access the main database.

The reason for the "local" Game clients is simple the performance and the bandwidth saving, so that only the game result, login, and so on has to be sent to the Master Data Server.

Has anyone experience what the best and most robust solution for this scenario would / could be?

Or is there another simpler solution for that? Maybe I don't see the most obvious solution for that, because I was studying around the concept too long...
 
Another question is the related to custom packages: Is there an elegant way to realize custom packages without messing around ever and ever again when a new version of TNet is released and I would keep my code up to date?

Thanks in advance, EdLan

Pages: [1]