Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by OP_toss · Oct 22, 2013 at 05:30 PM · iosnetworkingrpcpauseonapplicationpause

Send a Pause RPC on OnApplicationPause

I have a real-time multiplayer game for iOS. I'm trying to pause the game for all players when any player multitasks out of the app (OnApplicationPause).

I have a RequestPauseGame method that sends an RPC to the server, which sends one to all the players, which pauses their games. This all works.

 protected void OnApplicationPause( bool paused )
 {
     //pause game when applicaiton is paused (enters background)
     if (isGameRunning && paused)
     {
         RequestPauseGame();
     }
 }

My problem is, after OnApplicationPause fires, the game thread is slept, so my RPC method doesn't actually send. Then when I return to the app, the RPC goes through and the game is paused network-wide.

The only solution I can think of is to constantly send RPCs to the server from each client, so the server knows they're still there. Then if I don't hear back from a client after a specific timeout, I know they're paused. If they stay paused for too long, my server automatically assumes they disconnected.

I want to avoid sending tons of RPCs though, as I'm trying to decrease network usage as is. Anyone have alternative suggestions on how to get around the thread sleeping of OnApplicationPause?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OP_toss · Oct 22, 2013 at 09:28 PM 0
Share

bump. Looks like no one knows how to fix this?

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by KelNishi · Oct 24, 2013 at 09:22 AM

I haven't figured out how to do this with the built-in Unity networking, but with Photon, you can add the following line after your RPC call:

 PhotonNetwork.networkingPeer.SendOutgoingCommands();
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OP_toss · Oct 28, 2013 at 05:57 PM 0
Share

Interesting... I'm using uLink, which has roughly the same API as Unity Networking, so hopefully there's an equivalent of that. I'll post here if I find something. Thanks!

avatar image OP_toss · Oct 29, 2013 at 12:24 AM 0
Share

Couldn't find an equivalent with uLink. I assumed RPCs were sent immediately upon calling them... I'm having issues even rendering 1 more frame in order to cover up my puzzle game so users can't cheat. This HAS to be possible! No one with this problem gets answers on all the forums I've checked :(

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 5.0.2 iOS IL2CPP Networking RPC Issues 1 Answer

iOS IL2CPP Networking Issues Unity 5.0.x 3 Answers

Keep network connection from interrupting on iOS multitasking switch 1 Answer

iOS / Android OnApplicationPause: incoming calls vs home button 1 Answer

Is there a way to pause the game before it goes to the background? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges