/// <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 }
public PSEventRequestMessage(EventRequestMessage requestMessage) { Content = new PSEventContent(requestMessage?.Content); Headers = requestMessage?.Headers; Method = requestMessage?.Method; RequestUri = requestMessage?.RequestUri; Version = requestMessage?.Version; }
//------------------------SERVER SIDE FUNCTIONS------------------------------- /// <summary> /// Forwards a request for data made by the client to the tabletop /// </summary> /// <param name="netMsg">Net message.</param> void ServerHandleRequest(NetworkMessage netMsg) { Debug.Log("Server received request"); EventRequestMessage msg = netMsg.ReadMessage <EventRequestMessage> (); msg.sourceClientID = netMsg.conn.connectionId; // Send this to host NetworkServer.SendToClient(tableTopID, MyMessageTypes.EventRequestID, msg); }
/// <summary> /// UNUSED - Sends event data to the server. /// Should only be called from the tabletop, but is unused since the tabletop only sends data /// in response to a request (see ClientRequestReceived) /// </summary> /// <param name="coordinates">Coordinates.</param> /// <param name="energy">Energy.</param> /// <param name="source">Source.</param> /*public void SendData(Vector2 coordinates, float energy, string source) { * * if (!isTabletopClient) { * Debug.LogError ("SendData was called from Oculus client - did you mean to use SendResults to send the results of a discovery?"); * } * * EventDataMessage msg = new EventDataMessage (); * msg.energy = energy; * msg.coordinates = coordinates; * msg.destinationClientID = -1; * * myClient.Send (MyMessageTypes.EventDataID, msg); * * //NetworkServer.SendToClient (clientID, MyMessageTypes.EventDataID, msg); * }*/ /// <summary> /// Sends a request for data to the tabletop - ONLY Oculus clients should call this! /// </summary> /// <param name="name">Name of the data requested (placeholder param - in case we want to specify an event name/type/location)</param> public void SendRequest() { if (isTabletopClient) { Debug.LogWarning("You're the tabletop, you can't send requests because you already have all of the data!"); return; } EventRequestMessage msg = new EventRequestMessage(); msg.sourceClientID = -1; Debug.Log("Client sent the request to the server"); myClient.Send(MyMessageTypes.EventRequestID, msg); }