2018-01-24 12:34:32 +01:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
2018-01-24 12:34:32 +01:00
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-02-08 13:32:48 +01:00
|
|
|
|
using System;
|
2018-03-15 14:32:07 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Communication.Proxies;
|
2018-02-08 13:32:48 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
2018-01-24 12:34:32 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Communication.Proxies
|
2018-01-24 12:34:32 +01:00
|
|
|
|
{
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Default implementation of the <see cref="IServiceProxy"/>, to be used for communication with the service application component.
|
|
|
|
|
/// </summary>
|
2018-01-24 12:34:32 +01:00
|
|
|
|
public class ServiceProxy : BaseProxy, IServiceProxy
|
|
|
|
|
{
|
2018-01-25 09:50:46 +01:00
|
|
|
|
public bool Ignore { private get; set; }
|
|
|
|
|
|
2018-03-15 09:55:04 +01:00
|
|
|
|
public ServiceProxy(string address, IProxyObjectFactory factory, ILogger logger) : base(address, factory, logger)
|
2018-01-24 12:34:32 +01:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-15 09:55:04 +01:00
|
|
|
|
public override bool Connect(Guid? token = null, bool autoPing = true)
|
2018-01-24 12:34:32 +01:00
|
|
|
|
{
|
2018-02-08 13:32:48 +01:00
|
|
|
|
if (IgnoreOperation(nameof(Connect)))
|
2018-01-25 09:50:46 +01:00
|
|
|
|
{
|
2018-02-08 13:32:48 +01:00
|
|
|
|
return false;
|
2018-01-25 09:50:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-15 09:55:04 +01:00
|
|
|
|
return base.Connect(autoPing: autoPing);
|
2018-01-24 12:34:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-14 15:26:05 +01:00
|
|
|
|
public override bool Disconnect()
|
2018-01-24 12:34:32 +01:00
|
|
|
|
{
|
2018-02-08 13:32:48 +01:00
|
|
|
|
if (IgnoreOperation(nameof(Disconnect)))
|
2018-01-25 09:50:46 +01:00
|
|
|
|
{
|
2018-08-10 13:23:24 +02:00
|
|
|
|
return false;
|
2018-02-08 13:32:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-14 15:26:05 +01:00
|
|
|
|
return base.Disconnect();
|
2018-02-08 13:32:48 +01:00
|
|
|
|
}
|
2018-01-25 09:50:46 +01:00
|
|
|
|
|
2018-08-10 13:23:24 +02:00
|
|
|
|
public CommunicationResult StartSession(Guid sessionId, Settings settings)
|
2018-02-08 13:32:48 +01:00
|
|
|
|
{
|
|
|
|
|
if (IgnoreOperation(nameof(StartSession)))
|
|
|
|
|
{
|
2018-08-10 13:23:24 +02:00
|
|
|
|
return new CommunicationResult(true);
|
2018-01-25 09:50:46 +01:00
|
|
|
|
}
|
2018-02-08 13:32:48 +01:00
|
|
|
|
|
2018-10-03 15:42:50 +02:00
|
|
|
|
// Implement service communication...
|
2018-02-28 09:45:29 +01:00
|
|
|
|
// Send(new StartSessionMessage { Id = sessionId, Settings = settings });
|
2018-08-10 13:23:24 +02:00
|
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
2018-02-08 13:32:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-10 13:23:24 +02:00
|
|
|
|
public CommunicationResult StopSession(Guid sessionId)
|
2018-02-08 13:32:48 +01:00
|
|
|
|
{
|
|
|
|
|
if (IgnoreOperation(nameof(StopSession)))
|
|
|
|
|
{
|
2018-08-10 13:23:24 +02:00
|
|
|
|
return new CommunicationResult(true);
|
2018-02-08 13:32:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-03 15:42:50 +02:00
|
|
|
|
// Implement service communication...
|
2018-02-28 09:45:29 +01:00
|
|
|
|
// Send(new StopSessionMessage { SessionId = sessionId });
|
2018-08-10 13:23:24 +02:00
|
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
2018-01-25 09:50:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IgnoreOperation(string operationName)
|
|
|
|
|
{
|
|
|
|
|
if (Ignore)
|
|
|
|
|
{
|
2018-10-12 11:16:59 +02:00
|
|
|
|
Logger.Debug($"Skipping '{operationName}' operation because the ignore flag is set.");
|
2018-01-25 09:50:46 +01:00
|
|
|
|
}
|
2018-01-24 12:34:32 +01:00
|
|
|
|
|
2018-01-25 09:50:46 +01:00
|
|
|
|
return Ignore;
|
2018-01-24 12:34:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|