UDP Client - OnResponse Event

UDP client may receive a packet from the server as a response to a command sent from the client.

A server response will contain the version and command ID that correspond sent to the server as well as the status that indicates how the operation was processed on the server (success or failure).

udp.OnResponse += OnUdpResponse;

private void OnUdpResponse(uint ver, uint cmd, uint status, byte[] payload)
{
  // Consume payload accordingly using uint ver and cmd
  switch(ver)
  {
    case MY_CUSTOM_CMD_VER1:
    HandleCustomCmdVer1(cmd, status, payload);
    default:
    // Unknown command version... :(
      break;
  }
}

private void HandleCustomCmdVer1(uint cmd, uint status, byte[] payload)
{
bool success = status == udp.STATUS_OK;

  switch(cmd)
  {
    case CMD1:
      HandleCmd1(payload);
      break;
default:
// Unknown command ID... :(
break;
  }
}