Photon -- Client Connection Handling Client Connection Processing

Source: Internet
Author: User
Tags unity network

 

Client Connection Handling Client Connection processing client side, photon is built to give you as much control as possible. this makes sure it integrates well with your game loop. it also requires some attention to avoid inexplicable disconnects (See also "connections and timeouts" in   Basic Concepts   ). The following info shocould enable you to avoid them. Client, photon gives you more control. This ensures that it is well integrated with your game loop. It also needs to be concerned to avoid some abnormal disconnections. The following information helps you avoid them. Keep calling service keeps calling services to include photon in your client's game loop, you basically just have to call service regularly. regularly means between 10 to 50 times per second (depending on your game/network usage ). if your game client contains photon, you only need to call the service regularly. It is about 10 to 50 times per second. Service covers two tasks:
    • Inclued events and data are executed. this is done when you can handle the updates. as a sequence order is always kept intact, everything that the client has ES is queued and ordered. service CILS dispatchincomingcommands for this task.
    • Outgoing data of your client is sent to the server. this operation des acknowledgements (created in the background) which are important to keep connection to the server. service internally callsendoutgoingcommands to do this task. controlling the frequency of sendoutgoingcommands callcontrols the number of packages you use to send a client's produced data.
The service includes two tasks:
    • Receives the executed events and data and processes the updates. As an ordered sequence, it is always intact. Everything received by the client is sorted and queued. The service calls dispatchincomingcommands to complete this task.
    • Your client sends outgoing data to the server. This includes confirming that the server connection is maintained. The service internally calls sendoutgoingcommands to complete this task. Control the frequency of calling sendoutgoingcommands to control the number of data packets generated by the sending client
Profiling Service cballs Profiling Service call To detect if you called Service regularly, we added a statistics module to the client APIs. If you call the service regularly for detection, we add a module to the client API. If you encounter disconnects, check these values first: the photonpeer. trafficstatsgamelevel track how often you call dispatchincomingcommands and sendoutgoingcommands when you turn the stats on (photonpeer. trafficstatsenabled = true ). check the values of longestdeltabetweensending and longestdeltabetweendispatching. if a disconnection occurs, first check these values: When you enable statistics, trafficstatsgamelevel tracks dispatchincomingcommands and sendoutg The call of oingcommands checks the values of longestdeltabetweensending and longestdeltabetweendispatching. This feature is implemented in C # based libraries and Android currently. more platforms will get this soon. pun has a GUI component for this: photonstatsgui. this feature is implemented using the C # base library and Android. More platforms will soon be able to achieve this. Pun has a GUI Component: photonstatsgui. Platform specific Info Platform-specific information Unity3d and Pun The photon unity networking package implements the service cballs for you: photonhandler. update callservice in intervals. however, unity won't call update while it's loading scenes (or maybe even any assets ). photon unity network communication package is used to call your service: photonhandler. update regularly calls the service. However, Unity does not call updates when loading scenarios. To keep the connection while loading scenes, you should set photonnetwork. ismessagequeuerunning = false. To maintain the connection during loading, you must set photonnetwork. ismessagequeuerunning to false.

Pausing the message queue has two effects:

    • A background thread will be used to call sendoutgoingcommands while update is not called. this keeps the connection alive, sending acknowledgements only but no events or operations (rpcs or sync updates ). incoming data is not executed by this thread.
    • All incoming updates are queued. Neither rpcs are called, nor are observed objects updated. While you change the level, this avoids calling rpcs in the previous one.
Message Queue suspension has two effects:
    • When the background thread is used to call sendoutgoingcommands, the update is not called. This ensures connection, send confirmation, but there are no events or operations. Incoming data is not executed in this thread.
    • All incoming updates are queued. Rpcs are called. It is not to view object updates. When you change the level, this avoids calling rpcs in the previous one.
Unity3d If you use the "plain" from our unity client sdks, you implemented service most likely in some monobehaviour update method. to make sure photon's sendoutgoingcommands is called while you load scenes, implement a background thread. this thread shoshould pause 100 or 200 MS between each loop, so it does not take away all performance. if you use plain in the Unity client SDK package, you can implement the service in some monobehaviour update methods. Make sure that the sendoutgoingcommands of photon is called when you load the scenario. A real background thread. This thread suspends 100 or 200 milliseconds between loops, so it does not affect performance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.