Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: addebooi on November 09, 2013, 05:41:39 AM

Title: Trying to retriew channels, but crashes sometimes
Post by: addebooi on November 09, 2013, 05:41:39 AM
So what ive done is that ive looked on previusly forums and tried to make some kind off menu off it:
  1. TNManager.BeginSend(Packet.RequestChannelList);
  2. TNManager.client.packetHandlers[(byte)Packet.ResponseChannelList] = OnChannelList;
  3. TNManager.EndSend();
  4.  
This is the code i run to retriew my "list" that would say
  1. listOfCurrentlyLobby = new List<menuJoinChanelClass>();
  2.                 int count = reader.ReadInt32();
  3.                 int channelIDD = 0;
  4.                 int playerCount = 0;
  5.                 bool hasPassword = false;
  6.                 bool isPersistent = false;
  7.                 string levelName = "";
  8.                
  9.                 for(int i = 0; i<count;i++){
  10.                        
  11.                         channelIDD = reader.ReadInt32();
  12.                         playerCount = reader.ReadInt32();
  13.                         hasPassword = reader.ReadBoolean();
  14.                         isPersistent = reader.ReadBoolean();
  15.                         levelName = reader.ReadString();
  16.                         listOfCurrentlyLobby.Add(new menuJoinChanelClass(channelIDD,playerCount,hasPassword,isPersistent,levelName));
  17.                 }
  18.  

And that's pretty much all code ive written to retriew a list for the client, sometimes it pretty much works, the client retriews a channel with id's and such, but mostly both keeps getting dced and i don't onestly know why, it ain't coming up and errorss in unity, But in tnServeri keep getting: "Timed out". Any help would be appriciated, don't really know what ive done wrong! :)
Title: Re: Trying to retriew channels, but crashes sometimes
Post by: ArenMook on November 09, 2013, 08:07:46 AM
You are missing some parameters.

http://www.tasharen.com/forum/index.php?topic=6538.msg30866#msg30866
Title: Re: Trying to retriew channels, but crashes sometimes
Post by: addebooi on November 09, 2013, 09:12:45 AM
Thanks you so much Aren! It works perfectly fine now, just one last question: Where do i put the "data" for the channel, can it be "set" somewhere?

And i also found the main reason for the net crash.. It wasn't on "Run in background ^^".
Title: Re: Trying to retriew channels, but crashes sometimes
Post by: ArenMook on November 09, 2013, 10:29:05 AM
BeginSend(Packet.RequestSetChannelData).Write("My data");
EndSend();
Title: Re: Trying to retriew channels, but crashes sometimes
Post by: addebooi on November 09, 2013, 11:17:06 AM
Thanks alot, worked like a charm! :),
Somehow this code doesn't work
  1. Debug.Log(TNManager.playerID);
  2. tno.Send(10,Target.All, TNManager.playerID);
  3.  
  4.  
It does log the playerID, but it doesn't seem to send the message through the net
  1. [RFC(10)]
  2. public void sendInformationToChannel(int playerID){
  3.         Debug.Log("ading player!");
  4.         listOfPlayerInLobby.Add(TNManager.GetPlayer(playerID));
  5. }
  6.  
But it dosn't log the "adding player" part doens't log... It's the same object with a TNobject script attached to it, and there's no other RFC function in that script




Edit: I also tried to make a new script here that would kick all users from the current channel:
  1. tno.Send(11,Target.All);
  2.  
  3. [RFC(11)]
  4.         public void kickPlayer(){
  5.                 TNManager.LeaveChannel();
  6.         }
  7.  

And that code doesn't work aswell... SOmething must be wrong here, no errors att all... It just wont work ^^

apparently i got this working by setting the "menu" objects id to something else than 0, why is that?
Title: Re: Trying to retriew channels, but crashes sometimes
Post by: ArenMook on November 10, 2013, 07:15:17 AM
Why are you doing that? All players already get notified when a player joins the channel -- OnNetworkPlayerJoin.