Exemplo n.º 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());
            }
        }
Exemplo n.º 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());
            }
        }
            public void onConnectionResult(string endpointId, AndroidJavaObject connectionResolution)
            {
                int statusCode;

                using (var status = connectionResolution.Call <AndroidJavaObject>("getStatus"))
                {
                    statusCode = status.Call <int>("getStatusCode");
                }

                if (statusCode == 0) // STATUS_OK
                {
                    mResponseCallback(ConnectionResponse.Accepted(NearbyClientId, endpointId, new byte[0]));
                    return;
                }

                if (statusCode == 8002) // STATUS_ALREADY_DISCOVERING
                {
                    mResponseCallback(ConnectionResponse.AlreadyConnected(NearbyClientId, endpointId));
                    return;
                }

                mResponseCallback(ConnectionResponse.Rejected(NearbyClientId, endpointId));
            }