AccepToken error
SPF
✭
in Photon Bolt
I'm trying to get the token in Connected on client, and it raised the following error:
The code works on the server client, but on non-server client it has this error. What should I do? Thank you!
On server, the prints are: mark 1, mark 3, which is correct.
On client, it should be mark 1, mark 2, but it has nothing but the errors.
Codes:
IndexOutOfRangeException: Index was outside the bounds of the array. UdpKit.UdpPacket.InternalReadByte (System.Int32 bits) (at <3b70186b2acf40be8ab61e759b585166>:0) UdpKit.UdpPacket.ReadUShort (System.Int32 bits) (at <3b70186b2acf40be8ab61e759b585166>:0) UdpKit.UdpPacket.ReadUShort () (at <3b70186b2acf40be8ab61e759b585166>:0) UdpKit.UdpPacket.ReadString (System.Text.Encoding encoding) (at <3b70186b2acf40be8ab61e759b585166>:0) UdpKit.UdpPacket.ReadString () (at <3b70186b2acf40be8ab61e759b585166>:0) ConnectAcceptToken.Read (UdpKit.UdpPacket packet) (at Assets/_Scripts/Tokens/ConnectAcceptToken.cs:15) Bolt.ProtocolTokenUtils.ToToken (System.Byte[] bytes) (at <ed5388b742a94b18b9b7f386d8d06b96>:0) BoltInternal.BoltCore.Udp_Connected (UdpKit.UdpConnection udp) (at <ed5388b742a94b18b9b7f386d8d06b96>:0) BoltInternal.BoltCore.PollNetwork () (at <ed5388b742a94b18b9b7f386d8d06b96>:0) BoltInternal.BoltCore.Poll () (at <ed5388b742a94b18b9b7f386d8d06b96>:0) BoltPoll.FixedUpdate () (at <ed5388b742a94b18b9b7f386d8d06b96>:0)
The code works on the server client, but on non-server client it has this error. What should I do? Thank you!
On server, the prints are: mark 1, mark 3, which is correct.
On client, it should be mark 1, mark 2, but it has nothing but the errors.
Codes:
public override void Connected(BoltConnection connection) { var t = connection.AcceptToken as ConnectAcceptToken; print("mark 1"); if (t.userID == GameMgr.Instance.userIDself) // check userID if it's server { print("mark 2"); GameMgr.Instance.actorIDself = t.actorID; } else { print("mark 3"); } }
public class ConnectAcceptToken : IProtocolToken { public byte actorID; public string userID; public void Read(UdpPacket packet) { actorID = packet.ReadByte(); userID = packet.ReadString(); } public void Write(UdpPacket packet) { packet.WriteByte(actorID); packet.WriteString(userID); } }
0
Comments
-
Hello @SPF ,
Make sure you are registering the Token on all peers, no only on the Server.
So, you need to check if your logic calls "BoltNetwork.RegisterTokenClass<ConnectAcceptToken>();" on all your clients too.
Take a look here for more info: https://doc.photonengine.com/en-us/bolt/current/in-depth/protocol-tokens
--
Ramon Melo
Photon Bolt Team1