Get all peers in room

Options
Hi all!
I think that my question is simple, but i still not found answer after some googling time.
Question: how can i get all peers in room on Game Server? I need it for sending Operation for all peers in room when server comes in some internal state.

Best Answer

  • chvetsov
    chvetsov mod
    Answer ✓
    Options
    That is why i wrote - look like we use it. and that is it. Just find usages of this method

    in general we have AcotorsManager you may get from it ActiveActor, Inactive actors, all actors. it makes sense to send only to ActiveActors. InActive actors do not have peers attached to them

    best,
    ilya

Answers

  • chvetsov
    Options
    Hi, @kalibannez

    Count of active actors is equal to count of connected to game peers
    best,
    ilya
  • Yes, i understand this. More details...
    My game based on rooms. Each room have it own server logic unit, that must tick 20 times in second (subquestion: how implement it better? may be Photon ships some schedulers?). Logic unit may generate events (building done or something like this). My main question is: how can i send this event to all peers in him room?
  • chvetsov
    Options
    there is few overloads for PublishEvent method.
    you may find examples of usages right in our code

    and there is no built in schedulre in our code, except fibers scheduler. during game creation you may schedule on interval some method and it will be called every N miliseconds. but this method is not really precise. it might be executed slightly later. depending on amount of tasks in fiber

    best,
    ilya
  • PublishEvent is what i looking for, thank you! But all of overloaded PublishEvent methods in Room.cs requires Actors whose will recive event. And i still don't understand the right way to get all peers (Actors) in room...
  • chvetsov
    chvetsov mod
    Answer ✓
    Options
    That is why i wrote - look like we use it. and that is it. Just find usages of this method

    in general we have AcotorsManager you may get from it ActiveActor, Inactive actors, all actors. it makes sense to send only to ActiveActors. InActive actors do not have peers attached to them

    best,
    ilya
  • Thank you, Ilya, now i understand. I can get all peers from room like (HiveGame^)this->RoomReference->Room->Actors, and then i can SendEvent for each of them!