Author Topic: Trying to retriew channels, but crashes sometimes  (Read 3658 times)

addebooi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Trying to retriew channels, but crashes sometimes
« 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! :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Trying to retriew channels, but crashes sometimes
« Reply #1 on: November 09, 2013, 08:07:46 AM »

addebooi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Trying to retriew channels, but crashes sometimes
« Reply #2 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 ^^".

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Trying to retriew channels, but crashes sometimes
« Reply #3 on: November 09, 2013, 10:29:05 AM »
BeginSend(Packet.RequestSetChannelData).Write("My data");
EndSend();

addebooi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Trying to retriew channels, but crashes sometimes
« Reply #4 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?
« Last Edit: November 09, 2013, 05:54:08 PM by addebooi »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Trying to retriew channels, but crashes sometimes
« Reply #5 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.