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 - cmifwdll

Pages: 1 ... 12 13 [14] 15 16 ... 19
196
TNet 3 Support / Re: variables for ALL players
« on: September 13, 2016, 05:07:30 PM »
If it shows as -1 then it means the RFC is not being executed locally or across the network.
Are you connected to a game server? Is there a TNObject component on the gameobject?

Go through the official tutorials here to gain a better understanding. Additionally, TNet comes packaged with an example scene. Load up this scene and see how everything works first.

playerSearchNumber + 40???? What is it?

So, tno.Send("SetMyVariable", Target.AllSaved, (playerSearchNumber+40)). Breaking it down, this is a function call. The function being called is Send belonging to the class instance tno. The first parameter is a string, the second parameter is an enum, and the third parameter is an object (in this case it'll be serialized to an integer).
(playerSearchNumber + 40) is the same as writing(-1 + 40) and passes 39 as the third parameter. I only left it in because that's what Aren wrote above.

playerSearchNumber += 40 is adding 40 and then *assigning* the result back to the variable which is why it shows up on the local client. It's the same as writing (playerSearchNumber = playerSearchNumber + 40;) and variable assignments (the '=' operator) probably shouldn't be done inside function calls (tno.Send(...)).
This is all basic programming and not specific to TNet.

This code should output an appropriate message:
  1. int playerSearchNumber = -1;
  2.  
  3. void OnClick ()
  4. {
  5.         if (tno == null)
  6.         {
  7.                 Debug.LogError("Missing TNObject component on gameobject");
  8.                 return;
  9.         }
  10.         if (!TNManager.isConnected)
  11.         {
  12.                 Debug.LogError("Not connected to a game server");
  13.                 return;
  14.         }
  15.         if (!tno.isMine)
  16.         {
  17.                 Debug.LogWarning("TNObject does not belong to local player");
  18.         }
  19.         tno.Send("SetMyVariable", Target.AllSaved, (playerSearchNumber + 40));
  20.         Debug.Log("Sent RFC w/ value: " + playerSearchNumber + " (note: should be -1)");
  21. }
  22.  
  23. [RFC]
  24. protected void SetMyVariable (int val)
  25. {
  26.         Debug.Log("Received RFC w/ value: " + val + "(note: should be 39)");
  27.         playerSearchNumber = val;
  28. }
  29.  

edit: added link, fixed formatting, fixed usage of reserved keyword

197
TNet 3 Support / Re: variables for ALL players
« on: September 13, 2016, 01:17:33 PM »
Debug.Log("Value should be set to: " + value); not worked in RFC? - i dont see nothing

change all to:

    int playerSearchNumber;

    void OnClick ()
{
    tno.Send("SetMyVariable", Target.AllSaved, playerSearchNumber += 40);
    Debug.Log(playerSearchNumber);
}

    [RFC] protected void SetMyVariable (int value)
    {
        playerSearchNumber = value;
       
    }

Debug.Log show playerSearchNumber = 40 for 1 client, in other client  playerSearchNumber = 0

Firstly:
tno.Send("SetMyVariable", Target.AllSaved, playerSearchNumber += 40);
Assigning a value to a variable in a function call seems like it could lead to some unspecified behaviour (though I tested and it actually works, what is this wizardry), however, the assignment itself is redundant since it'll be assigned in the RFC anyway (which is executed on the local client immediately).

Secondly:
Add a Debug.Log("RFC Called"); in the RFC function body to make sure it's even being called.

  1. int playerSearchNumber = -1;
  2.  
  3. void OnClick ()
  4. {
  5.         tno.Send("SetMyVariable", Target.AllSaved, (playerSearchNumber + 40));
  6.         Debug.Log("Sent RFC w/ value: " + playerSearchNumber);
  7. }
  8.  
  9. [RFC]
  10. protected void SetMyVariable (int value)
  11. {
  12.         Debug.Log("Received RFC with value: " + value);
  13.         playerSearchNumber = value;
  14. }
  15.  

edit: Took my own advice ;)

198
TNet 3 Support / Re: Old TNet 2.0 Customer question about 3.0
« on: September 07, 2016, 08:49:30 PM »
Thank you for your quick answer.

The first player who joins, has the authority to kick and ban other player?
If it's so, i need to connect a dummy player after the server is created, to be safe.

//EDIT: Solved!

No, only authorized players are able to kick and ban. I'm a little out of it right now, but if I'm thinking straight I believe the host has no implicit power. You decide what the host has power over.

To expand, a list is kept on the server (SteamIDs, passwords, whatever you decide to use), and players must supply a correct value via TNManager.SetAdmin(string pass) in order to kick or ban others. The host doesn't have access to this list unless the host is also running the server (can we please rename "host" to "channel operator" :P)

As Aren said, TNet isn't p2p, but it's important to note that the game server acts as a "smart relay". It has no concept of the game, the world, the physics, etc. It simply relays packets. That's not to detract from the genius of TNet, though. There is no "one size fits all" server-authoritative solution. A lot of TNet's worth, in my opinion, comes from how well-written and extensible it is. If you want your server to be authoritative, you can make it so with surprising ease.

199
TNet 3 Support / Re: Ping a Game Server doesnt work?!
« on: September 07, 2016, 08:29:49 PM »
That error message is peculiar. Maybe something new to TNet3? TNet2 uses UDP for the TNManager.Ping function, so no connection necessary. Are you initializing UDP? I believe you need to add this somewhere:
  1. TNManager.StartUDP(Random.Range(10000, 50000));
  2.  

200
TNet 3 Support / Re: What do you guys think about a Chat like Slack, Jabbr?
« on: September 07, 2016, 08:06:30 PM »
I think this forum is just fine. From what I've seen, questions are usually answered within 72 hours. Often times within 24 hours.

Probably an unpopular opinion, but I think services like that are a gimmick. Of course, I thought git was a gimmick too, and then I used it and fell in love, so take my opinion with a grain of salt :P

201
TNet 3 Support / Re: Target.OthersSaved
« on: August 30, 2016, 09:01:22 PM »
Hardly any overhead at all:
  1. for (int i = 0; i < rfcs.size; ++i)
  2. {
  3.         RFC r = rfcs[i];
  4.  
  5.         if (r.uid == inID && r.functionName == funcName)
  6.         {
  7.                 if (r.buffer != null) r.buffer.Recycle();
  8.                 r.buffer = b;
  9.                 return;
  10.         }
  11. }
  12.  

As someone that often optimizes *too* much, I wouldn't bother limiting OthersSaved usage. The utility it provides is extremely valuable, and its cost is practically nil.

203
TNet 3 Support / Re: Target.OthersSaved
« on: August 28, 2016, 08:48:14 PM »
When an RFC is sent a UID is generated for that RFC. This is a combination of the sending TNObject's ID (which itself is unique) and the RFC ID (or function name).
Serverside, when a forwarded packet that's designated to be saved is received, it iterates the channel's saved RFCs searching for the UID. If the UID is found then the value is updated, if it's not then a new saved RFC is created.

In short, the value will be updated if the RFC has been seen before. So, no redundant messages or big lists :)

204
TNet 3 Support / Re: Can a Lobby be dynamic?
« on: August 18, 2016, 12:33:53 AM »
LAN broadcasts still work fine in TNet 3 -- they are used for LAN discovery. It's the tno.Send broadcasts that no longer work the same as they are no longer needed with the multiple channel support.

Ah, I was only guessing. One of these days I'll make the upgrade, I swear :)

@Groad, disregard everything in my post then, Aren gave the correct solution.

205
TNet 3 Support / Re: Can a Lobby be dynamic?
« on: August 17, 2016, 05:40:16 PM »
We have an application that is creating a local server, and another application for devices to connect to that server over a network with no internet access.

I don't understand this, can you clarify? Are you saying one application is the dedicated server, and the other application is your game? Further, are you saying that each user can at any point be running both the dedicated server application and the game application?

Reading ahead, in your given scenario, how does Computer B know that the lobby server is currently hosted on Computer A?

I believe LAN broadcast packets were removed in TNet3, but this seems to be the perfect case for them ;)

206
TNet 3 Support / Re: Testing IPv6 on iOS
« on: July 30, 2016, 09:29:08 PM »
I can connect but it seems the connection is severed immediately.

I placed a Debug.Log in TcpProtocol::OnConnect and checked wireshark. The handshake completes w/ the ack packet, then the TNet connection takes place:
0000   0c 00 00 00 03 0c 00 00 00 05 47 75 65 73 74 00  ..........Guest.
Which your server responds to with:
0000   05 00 00 00 09 00 00 00 00                       .........

Then severs the connection with FIN/ACK.
This could be because of a version mismatch. My Player.version is 12. Yours is probably different, so when you receive my Packet.RequestID the server closes the connection.
Packet ID 9 is RequestSetPlayerLimit for me though, dunno what's up with that.

Maybe the TNet console will provide more information.

edit: if you do post the contents of the console, please redact my IP :P

207
TNet 3 Support / Re: Testing IPv6 on iOS
« on: July 28, 2016, 08:04:42 PM »
Yeah, definitely a parsing error. Probably because of the double colons out of nowhere. IPv6 still doesn't make sense to me :(

I don't know where TNet3 does its parsing, so I can't help further. Hopefully Aren will see this and help you out more. In the meantime, if you want, you can try finding the parsing error. I'd start with the TNManager.Connect function and its overloads. You'll want to extract the port, then pass the leftover string to IPAddress.TryParse. From there, it might make sense to verify the IPAddress is valid. It seems the Uri.CheckHostName function can do that for you.

208
TNet 3 Support / Re: Testing IPv6 on iOS
« on: July 28, 2016, 05:22:02 AM »
Looks like a parsing error now.

Can you open up TNTcpProtocol.cs and navigate to the ConnectToTcpEndPoint() function. In that function, there should be a line similar to:
IAsyncResult result = mSocket.BeginConnect(tcpEndPoint, OnConnectResult, mSocket);
Can you add a
UnityEngine.Debug.LogWarning("Connecting to: " + tcpEndPoint + " with socket address family (" + mSocket.AddressFamily + ")");
directly above that?



209
TNet 3 Support / Re: Testing IPv6 on iOS
« on: July 27, 2016, 04:53:18 PM »
Yes, because Unity is running an earlier version of mono, TNet can't make use of dual mode sockets. Because of this, ipv4 servers can only accept ipv4 clients, and ipv6 servers can only accept ipv6 clients. Likewise for clients connecting to servers, but that's based more on the IP you enter rather than the public IP you've been assigned (as most ISPs are dual-stack now).

Back on topic: if you want to connect to an ipv6 server, you must address it using its ipv6 address. Looking at the server console output, it doesn't look like your server has been assigned a public ipv6 address? That's very strange. I don't know enough about ipv6 to recognize if those local IPs are accessible over the WAN. I know the fe80:: addresses are link-only, but the 2002: one looks strange as well.

Regardless, the line that outputs the external IP should return ipv6 if you have a public ipv6. I suppose it's possible the WebClient is using the wrong interface? Still, then, one of the outputted ipv6 local addresses should be publicly accessible.

TL;DR I don't think your host gave you an ipv6 address. Double check that. If you do have a public ipv6 address and still can't connect to it, there's a bug in TNet.

edit: On your server, try going to http://ipv6.icanhazip.com and see what it returns (it's not a fancy webpage, only a single string should pop up).

210
TNet 3 Support / Re: Testing IPv6 on iOS
« on: July 27, 2016, 03:38:00 PM »
Well, first step would be replacing that ipv4 address with an ipv6 one :P

You probably just forgot, but you typed the server's ipv4 address here: https://dl.dropboxusercontent.com/u/78828827/Screen%20Shot%202016-07-27%20at%207.40.15%20AM.png and that's likely why you're unable to connect ;)
I don't know exactly how Aren implemented it, but here's how I instantiate the client socket:
File TNTcpProtocol.cs, function ConnectToTcpEndPoint():
mSocket = new Socket(tcpEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

In this case, tcpEndPoint is the parsed IPEndPoint from the box you type in. So its address family would be ipv4, and the socket would be ipv4.

Pages: 1 ... 12 13 [14] 15 16 ... 19