Information Isn't Being Sent

Options
The Blue Lantern
edited November 2012 in Photon Server
Hello, I have two Unity applications: one for the player to use, and one administrator application that has access to the game's databases. I am trying to make it so that when the player logs in, a request to retrieve the saved data associated with the player's name is sent from the player's application to the admin application, which will retrieve the data from the database and send it back to the player. However, in my case-switch in the admin application, the load scenario is never being hit, whereas every other scenario is.

For example, this works perfectly:

[code2=csharp]//Player code

internal void SendPlayerInfo(LitePeer peer)
{
if (peer == null)
{
return;
}

Hashtable evInfo = new Hashtable();
evInfo.Add((byte)EventKey.PlayerName, this.name);

peer.OpRaiseEvent((byte)PhotonEventCodes.EventCode.PlayerInfo, evInfo, true);
}

//Admin code
case (byte)PhotonEventCodes.EventCode.PlayerInfo:
if (originatingPlayer != null)
{
originatingPlayer.SetPlayerInfo(evData);
}
else
{
this.DebugReturn("did not find player to set info: " + originatingActorNr);
}

break;[/code2]

Whereas, while this is called, the admin application doesn't seem to be picking up the case.

[code2=csharp]//Player code
internal void SendLoadRequest(LitePeer peer)
{
if (peer == null)
{
return;
}

Hashtable evInfo = new Hashtable();
evInfo.Add ((byte)EventKey.PlayerName,PlayerName);
loading = true;
peer.OpRaiseEvent((byte)PhotonEventCodes.EventCode.PL,evInfo,false);
}

//Admin code
case (byte)PhotonEventCodes.EventCode.PL:
print ("PLAYER LOADING");
string nm = (string)evData[(byte)PhotonPlayer.EventKey.PlayerName];
SendPlayerLoadInfo(originatingActorNr,DB.Instance.LoadPlayer(nm));
break;[/code2]

What might be causing my problem? Thanks in advance.

Comments

  • Tobias
    Options
    In the second code snippet you send the PlayerName instead of this.name. Did you mean that?
    Aside from this, the second snippet sends unreliable and this event could become lost (but not all the time).
    What is the value of PhotonEventCodes.EventCode.PL? Maybe it collides with something else?
  • Ah, switching it to reliable seemed to fix the problem. However, I'm getting another problem; when a second player logs in, the information from the first player is being loaded for the second player, as opposed to the second player's information. What might be causing this? I'm pretty sure it's not an issue with my database management code, because the first player's information that is loaded, regardless of which player that is, is always what it should be. In my PhotonPlayer class, I have a boolean "loading" that is set to false, initially; when the player sends a load request, that boolean is set to true. If it is true, it will pick up the event sent by the admin application containing the requested load information, and then set it back to false. I am new to working with networking in games, and I was thinking that what might have happened is that it's picking up the first load information sent by the admin (The boolean should prevent this from happening, though, so I'm guessing the second player sends the second load request, setting the bool to true, and then getting the first load request), but I'm not certain.
  • Tobias
    Options
    This is going to be instable in any case. Imagine two players logging in. Both have their "loading" flag set to true. Either player's event is going to trigger the info update.

    You can send events to single players by actorNumber. Have a look at the overloads of OpRaiseEvent. One takes a array of target players.
  • Sending events by actorNumber worked perfectly. However, there is one more problem; it seems as though, when three or more players are online, the admin Unity application will disconnect (The player applications remain connected). Would you have any suggestions to prevent this from happening?
  • Tobias
    Options
    You will need to find out what makes this happen. Any log entry in the player / Editor (when the editor is being admin)?
    Are you sending a lot of messages to that user? You could use the StatsGui component to get some info on messages/sec and used bandwidth.