예제 #1
0
        internal ConnectionResponse AsResponse(long localClientId)
        {
            switch (ResponseCode())
            {
            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ACCEPTED:
                return(ConnectionResponse.Accepted(localClientId, RemoteEndpointId(), Payload()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ERROR_ENDPOINT_ALREADY_CONNECTED:
                return(ConnectionResponse.AlreadyConnected(localClientId, RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.REJECTED:
                return(ConnectionResponse.Rejected(localClientId, RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ERROR_ENDPOINT_NOT_CONNECTED:
                return(ConnectionResponse.EndpointNotConnected(localClientId, RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ERROR_NETWORK_NOT_CONNECTED:
                return(ConnectionResponse.NetworkNotConnected(localClientId, RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ERROR_INTERNAL:
                return(ConnectionResponse.InternalError(localClientId, RemoteEndpointId()));

            default:
                throw new InvalidOperationException("Found connection response of unknown type: " + ResponseCode());
            }
        }
예제 #2
0
        internal ConnectionResponse AsResponse(long localClientId)
        {
            switch (this.ResponseCode() + 4)
            {
            case ~NearbyConnectionTypes.ConnectionResponse_ResponseCode.ERROR_INTERNAL:
                return(ConnectionResponse.EndpointNotConnected(localClientId, this.RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ACCEPTED:
                return(ConnectionResponse.AlreadyConnected(localClientId, this.RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.REJECTED:
                return(ConnectionResponse.NetworkNotConnected(localClientId, this.RemoteEndpointId()));

            case NearbyConnectionTypes.ConnectionResponse_ResponseCode.ACCEPTED | NearbyConnectionTypes.ConnectionResponse_ResponseCode.REJECTED:
                return(ConnectionResponse.InternalError(localClientId, this.RemoteEndpointId()));

            case (NearbyConnectionTypes.ConnectionResponse_ResponseCode) 5:
                return(ConnectionResponse.Accepted(localClientId, this.RemoteEndpointId(), this.Payload()));

            case (NearbyConnectionTypes.ConnectionResponse_ResponseCode) 6:
                return(ConnectionResponse.Rejected(localClientId, this.RemoteEndpointId()));

            default:
                throw new InvalidOperationException("Found connection response of unknown type: " + (object)this.ResponseCode());
            }
        }