Why Pun demo dont use Service funcion

Options
coco
coco
hi all, We Alwalys Use Service function to connect the Host.
like this:
  void Update()
{
   if(peer!=null)
      peer.Service();
}
But Where is the "service" function in Pun demo.
THANK YOU!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @coco,

    Thank you for choosing Photon!

    Good question.
    PUN uses a special advanced Service internally. Take a look at PhotonHandler.Update().
  • coco
    Options
    @JohnTube it's so kind of you!
  • coco
    Options
    @JohnTube I'll trouble you again,Which way is better?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2017
    Options
    PUN's PhotonHandler is more advanced and can be customized.
    In any case both ways use the same thing internally: sending outgoing messages and processing incoming ones.
    We usually recommend calling Service 10 to 20 times a second. Doing so in Update will result in a call per frame which may be 30 or 60 or more per second which can eat more CPU or drain more battery on mobile.
    More info about Service:
    • Service() internally calls DispatchIncomingCommands() until it returns false to dispatch all received incoming messages into your game logic.
    • Calling Service() also processes SendOutgoingCommands which actually sends operations that your client called since the last SendOutgoingCommands.
    • Finally Service() triggers the callbacks OnEvent, OnOperationResponse, etc.