Author Topic: Channel and host data  (Read 4082 times)

xandeck

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 54
    • View Profile
Channel and host data
« on: November 06, 2015, 11:54:34 AM »
Hello everyone,

I have a doubt regarding channel and server creation.
Right now, what I am doing:
- I have a main server hosted in Amazon
- All players will connect there to handle channel creation, hosting and playing (I think it is the same way as the Aren game works)
- How can I setup the name of the channel (in channel parameters, there is only level name, no channel name... is custom data the only way?)
- How can I ping each channel when getting channel list? Right now I can only ping the server I am in... is this the only way? With this, I suppose, all players will have the same ping because they are all in the same main server?

I think I misunderstood the way channels in TNet works.
I still have my old way, which is all players creates their own server instance, so I save their server data in a private database (mySQL) and get info from there to generate my own channel list. I thought having some kind of master server and using hosting channels to provide players host and client will be easier to keep everyone playing without port forwarding.

If anyone can help me, I appreciate it.
Thanks in advance.


decerto

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: Channel and host data
« Reply #1 on: November 06, 2015, 02:32:21 PM »
Mine is different.

I have a list of different servers that hook up to the lobby server. Then a simple list showing all the different servers (not rooms). How do I go about pinging each server when not connected to it. In the list I have server name and numbers of players showing, there's no option for ping (only when connected, as done by the example menu).

Cheers

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Channel and host data
« Reply #2 on: November 07, 2015, 07:50:43 AM »
Hello everyone,

I have a doubt regarding channel and server creation.
Right now, what I am doing:
- I have a main server hosted in Amazon
- All players will connect there to handle channel creation, hosting and playing (I think it is the same way as the Aren game works)
- How can I setup the name of the channel (in channel parameters, there is only level name, no channel name... is custom data the only way?)
- How can I ping each channel when getting channel list? Right now I can only ping the server I am in... is this the only way? With this, I suppose, all players will have the same ping because they are all in the same main server?

I think I misunderstood the way channels in TNet works.
I still have my old way, which is all players creates their own server instance, so I save their server data in a private database (mySQL) and get info from there to generate my own channel list. I thought having some kind of master server and using hosting channels to provide players host and client will be easier to keep everyone playing without port forwarding.

If anyone can help me, I appreciate it.
Thanks in advance.

I explained in your other thread that players deemed a channels "host" aren't really hosting anything. The channel exists on the server. The server "hosts" the "channel", the player *operates* the channel. To reiterate: the channel is part of the server. A server can have many channels. A channel exists solely and entirely on the game server. To "join" a channel simply tells the server you're part of a specific group of clients.

You can set the name in the channel data, yes. You can then retrieve the name from the channel data.

Like I said, the channel is just a collection of data on the server. Therefore, the server ping is your ping to each and every channel on the server.

All players will *NOT* have the same ping. I think you misunderstand how networking works. I really don't know where to begin explaining that... so, let's say every networked device is connected via Ethernet (that blue cable thing - I'm sure you've seen it). If this is the case, you can picture the Internet as a huuuuuge collection of devices all connected by blue cable. One giant blue cable with devices breaking it up. So, networking, then, is determining which path to take to reach a destination. You would have to determine which device nearest to you to talk to, and that device determines the next device, and so on and so on until you reach your destination. So how many devices are between you and your destination, the distance between each device, and how fast each device determines the next device greatly effects your ping. I recommend playing around with the "tracert" program in Windows (or "traceroute" in linux / mac). Type "tracert google.com" in command prompt (or "traceroute google.com" in linux / mac terminal). Each "hop" is a device on the way to reaching google, so you can see the exact path your network resolved.



Mine is different.

I have a list of different servers that hook up to the lobby server. Then a simple list showing all the different servers (not rooms). How do I go about pinging each server when not connected to it. In the list I have server name and numbers of players showing, there's no option for ping (only when connected, as done by the example menu).

Cheers

Try TNManager.Ping(IPEndPoint udpEndPoint, GameClient.OnPing callback). You can get the EndPoint from TNLobbyClient.knownServers.list[_index_].externalAddress (or internalAddress).
If it doesn't work then at least you have a starting point :)

decerto

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: Channel and host data
« Reply #3 on: November 07, 2015, 10:25:04 AM »
I managed to get the external address for the udpEndPoint but what exactly is GameClient.OnPing callback and how do I get it? GameClient.OnPings says you need an IP and an Int. Maybe I'm getting confused.

Cheers again

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Channel and host data
« Reply #4 on: November 07, 2015, 02:18:12 PM »
  1. TNGameClient.OnPing onPingCallback;
  2.  
  3. void Start()
  4. {
  5.     onPingCallback = onPingReceived;
  6. }
  7.  
  8. void onPingReceived(IPEndPoint ip, int milliSeconds)
  9. {
  10.     Debug.Log("My ping to " + ip.ToString() + " is " + milliSeconds);
  11. }
  12.  
  13. void SomeFunctionWhereYouCallPing()
  14. {
  15.     TNManager.Ping(blahblah.externalAddress, onPingCallback);
  16. }
  17.  

Try that out. Should work but I didn't test it.
Read more about delegates in C# here: https://msdn.microsoft.com/en-us/library/ms173171.aspx

xandeck

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 54
    • View Profile
Re: Channel and host data
« Reply #5 on: November 07, 2015, 04:28:25 PM »
Hello cmifwdll

I edited my answer... are you serious about the cable explanation? I know all about that.
Short answer: I know about what you explained and you did not give an answer at all. But thank you in anyway.
It is already working the way I want to. There is no more point discussing this here and receiving this kind of answer.
By the way... TNet handles HOST or OPERATOR as "HOST" in its vars. That's why I am using HOST, I thought this was obvious.
« Last Edit: November 07, 2015, 04:36:29 PM by xandeck »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Channel and host data
« Reply #6 on: November 07, 2015, 07:16:00 PM »
Okay. It's impossible for me to know what you know and what you don't know, so I tried my best at explaining the basics just in case.

It seemed you were unclear on how channels work in TNet, so hopefully I was able to help you with that. I was going to edit my post to include code showing how to store / retrieve a name using channel data but I forgot.

Glad you got it working, though.

xandeck

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 54
    • View Profile
Re: Channel and host data
« Reply #7 on: November 08, 2015, 08:26:45 AM »
Hello cmifwdll,
I thank you for trying to explain and help. Sorry if my answer was a little bit harsh, just realized that "texts" does not show the way we want to explain most of the times rather than talking.