Exemple #1
0
 void HandlePlayerOffline(Message msg)
 {
     if (msg.TryGetValue("initByActor", out object playerIdObj) &&
         int.TryParse(playerIdObj.ToString(), out int playerId))
     {
         var player = Room.GetPlayer(playerId);
         if (player == null)
         {
             Logger.Error("No player id: {0} when player is offline");
             return;
         }
         player.IsActive = false;
         OnPlayerActivityChanged?.Invoke(player);
     }
     else
     {
         Logger.Error("Handle player offline error: {0}", msg.ToJson());
     }
 }
Exemple #2
0
 void HandlePlayerOnline(Message msg)
 {
     if (msg.TryGetValue("member", out object memberObj))
     {
         var member = memberObj as Dictionary <string, object>;
         if (member.TryGetValue("actorId", out object playerIdObj) &&
             int.TryParse(playerIdObj.ToString(), out int playerId))
         {
             var player = Player.NewFromDictionary(member);
             player.Client = this;
             OnPlayerActivityChanged?.Invoke(player);
         }
         else
         {
             Logger.Error("Handle player online error: {0}", msg.ToJson());
         }
     }
     else
     {
         Logger.Error("Handle player online error: {0}", msg.ToJson());
     }
 }