Search Unity

Shared queue?

Discussion in 'Multiplayer' started by kigm, Jul 20, 2016.

  1. kigm

    kigm

    Joined:
    May 13, 2016
    Posts:
    29
    There aren't a way for share a queue between clients and server? I need that clients going to a queue and server can check this queue and do something with the users that are waiting, in order to a queue (FIFO).

    I am using a Cmd function to call to server and put this user into the queue, but each client has his own queue... typical in Uunity. And server has another queue too, empty, obviously.

    How can I share a queue between all clients and the server?

    Thanks.
     
  2. kigm

    kigm

    Joined:
    May 13, 2016
    Posts:
    29
    I tried that using a Cmd and a Rpc method and a queue. But or I don't understand yet how UNET works talking about server side and client side, or Unity is very very limited in this face.

    If I have a queue for each client and enqueue something in the queue and later I make a Rpc call where copy the queue of the user who called Cmd method. All users must copy this queue in his own queue, right? Well, this isn't happen like this. In fact in Unity editor the software closes unexpectedly (I did tell to support team) and in standalone nothing happens.

    Anybody can explain me why?

    This is the code:

    Code (CSharp):
    1.  
    2. [Command]
    3.     public void CmdrequestTurn(){
    4.         print("Request made");
    5.  
    6.         //player adds to its own queue for request turn
    7.         Transform player = connectionToClient.playerControllers [0].gameObject.transform;
    8.         queueForTurn.Enqueue (player);
    9.         print ("Size of queue when requested: "+queueForTurn.Count);
    10.  
    11.         RpcUpdateQueueOnClients (queueForTurn);
    12.     }
    13.  
    14. [ClientRpc]
    15.     public void RpcUpdateQueueOnClients(Queue<Transform> queue){
    16.         queueForTurn = queue;
    17.  
    18.         print ("Size of queue updated to: "+queueForTurn.Count);
    19.  
    20.     }