Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

yield return in a Network Message???

Discussion in 'Multiplayer' started by Royall, Jul 9, 2015.

  1. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    118
    I have a network message send from the client to the server (email/password).
    Code (CSharp):
    1. void OnLoginRequest(NetworkMessage mess) {
    2.         var readmess = mess.ReadMessage<Controller.loginRequest>();
    3.         Debug.Log(readmess.email+" sended a login request...");
    4.         //WWWform to check the email and password here
    5. }
    The server checks with a WWWform if the email/password combination exists.

    Problem is with a WWWform you need to yield the www result but this is not possible with a void... I also cant change it to a IEnumerator cause it says network messages can only be void...

    What to do??
     
  2. Zephilinox

    Zephilinox

    Joined:
    Sep 15, 2014
    Posts:
    14
    Why don't you just make a coroutine for the WWWform and start it in the OnLoginRequest?
     
  3. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    118
    That's what I did atm. But it just doesn't feel right cause now I have 2 functions... Hope someone knew a workaround...