Exemplo n.º 1
0
    /// <summary>
    /// Handler for when a request is received - should only be triggered on the tabletop client.
    /// </summary>
    /// <param name="netMsg">Net message.</param>
    public void ClientRequestReceived(NetworkMessage netMsg)
    {
        if (!isTabletopClient)
        {
            Debug.LogError("Request received by non-host client");
            return;
        }
        EventRequestMessage msg = netMsg.ReadMessage <EventRequestMessage> ();

        Debug.Log("Client received a request");

        // Temporary - send blank message back to client
        EventDataMessage response = new EventDataMessage();

        response.coordinates         = new Vector2(0f, 0f);
        response.energy              = 10f;
        response.destinationClientID = msg.sourceClientID;


        // TODO: Do stuff with this request, create a new EventDataMessage, and send it back to
        // whomever sent the request

        // TODO: Access data from our list
        // Make a response message
        // For now, just send a dummy data back
        myClient.Send(MyMessageTypes.EventDataID, response);
        Debug.Log("Table Client sent a data response to the server");

        // Send it to the client that asked for it
    }
Exemplo n.º 2
0
    /// <summary>
    /// Forwards data received from the tabletop to the client that requested it
    /// </summary>
    /// <param name="netMsg">Net message.</param>
    void ServerHandleData(NetworkMessage netMsg)
    {
        Debug.Log("Server received data");
        EventDataMessage msg = netMsg.ReadMessage <EventDataMessage> ();

        NetworkServer.SendToClient(msg.destinationClientID, MyMessageTypes.EventDataID, msg);
        Debug.Log("Server forwarded the data to the requester");
    }
Exemplo n.º 3
0
    /// <summary>
    /// Handler for when the client receives the data it requested.
    /// </summary>
    /// <param name="netMsg">Net message.</param>
    public void ClientDataReceived(NetworkMessage netMsg)
    {
        EventDataMessage msg = netMsg.ReadMessage <EventDataMessage> ();

        Debug.Log("Client received data message");

        // TODO: Parse the message and store it somewhere for use

        // FOR TESTING ONLY - immediately send a dummy result
        SendResults("Good data");
        Debug.Log("Client sent a result to the server");
    }