示例#1
0
 public ASRequest(AppServiceRequest internalRequest, AppServiceDeferral internalRequestDeferral,
                  ASConnection connection)
 {
     _connection              = connection;
     _internalRequest         = internalRequest;
     _internalRequestDeferral = internalRequestDeferral;
     Message = _connection._serializer.DeserializeFromValueSet(internalRequest.Message);
 }
示例#2
0
 public ASConnectionConnectResult(
     AppServiceConnectionStatus connectionStatus,
     AppServiceHandshakeStatus handshakeStatus,
     ASConnection connection)
 {
     ConnectionStatus = connectionStatus;
     HandshakeStatus  = handshakeStatus;
     Connection       = connection;
 }
        private static async Task <ASConnectionConnectResult> ConnectInternalAsync(string appServiceName,
                                                                                   string packageFamilyName, RemoteSystem remoteSystem, IObjectSerializer serializer)
        {
            var connection = new AppServiceConnection
            {
                AppServiceName    = appServiceName,
                PackageFamilyName = packageFamilyName
            };

            var isRemoteSystemConnection = (remoteSystem != null);

            var connectStatus = isRemoteSystemConnection
                ? await connection.OpenRemoteAsync(new RemoteSystemConnectionRequest(remoteSystem))
                : await connection.OpenAsync();

            if (connectStatus != AppServiceConnectionStatus.Success)
            {
                return(new ASConnectionConnectResult(connectStatus, AppServiceHandshakeStatus.Unknown, null));
            }

            // Send connection request, receive connection response
            var request  = new ConnectionRequestMessage();
            var response = await connection.SendMessageAsync(request, RequestOptions.Default, serializer);

            var success =
                response.Status == RequestStatus.Success &&
                response.Response is ConnectionResponseMessage responseObject &&
                responseObject.IsSuccessful;

            if (!success)
            {
                return(new ASConnectionConnectResult(
                           AppServiceConnectionStatus.Success, AppServiceHandshakeStatus.ConnectionRequestFailure, null));
            }

            var asConnection = new ASConnection(
                ((ConnectionResponseMessage)response.Response).ConnectionId,
                connection, null, isRemoteSystemConnection, serializer);

            return(new ASConnectionConnectResult(
                       AppServiceConnectionStatus.Success,
                       AppServiceHandshakeStatus.Success,
                       asConnection));
        }