Creat a peer

Options
mad_sir1
mad_sir1 ✭✭
edited July 2013 in Photon Server
Hey! :) trouble is everywhere.
I find a problem ,can I creat a peer when the photon server start, so I just add some codes in the masterapplication.cs setup(), but I failed ,anyone can solve this problem ? maybe some example is good ,thanks :P

Comments

  • chvetsov
    Options
    You should not create peer on server in setup.
    There is only two places and only two situations when you create peers on server:
    - either client or other server connects to server, then Application.CreatePeer is used
    - connection to another server established then CreateServerPeer is called.
  • mad_sir1
    Options
    thanks chvetsov for your soon reply ,as you said ,can't creat a peer in the setup(), but I want to creat some rooms when the photon server start , so I think maybe I can creat a peer ,and then call the HandleCreatGame() method ,but I find it can't, so do you have some advice that how can I creat rooms when the photon server start ? or it must be trigged but the client operation?? any advice can help me ,thanks
  • A peer is a server-side representation of a connected client, so you can not (and should not) create a peer object without a real client connection. The best practice is to create a room when the client calls that operation.

    If you want to have a fixed list of rooms which are always available, you can "fake" that on the client side:
    - keep a list of "special" room names that should always be available
    - when you get the list of open rooms from the server, always add your "special" room names
    - if the room does not exist on the server, let the client create it - otherwise, join.

    In most cases, that's the easiest way.
  • mad_sir1
    Options
    Hi Nicole !thanks
    you make sense to that ,from you opinion ,I can summary these :
    1: I can't creat rooms without client operation when the photon server start
    2: if I want to keep a list of fixed rooms ,I should keep a list of special room names ,and when the client click the room button ,it sends the room name to the server side ,and join the room,right??
    3: we know that the room will dispose when the last player leave ,so if I want to keep the room ,I should save the roomcache to the database ,when a player join the room ,I will pass the roomcache to him ,right ??
  • Yes, correct.