﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace SPAD.neXt.Interfaces.ServiceContract
{

    public sealed class RemoteServiceResponse
    {
        public bool HasError { get; set; }
        public string Error { get; set; }
        public double Value { get; set; }
    }

    [ServiceContract]
    [ServiceKnownType(typeof(RemoteServiceResponse))]
    public interface IRemoteService
    {
        [OperationContract]
        RemoteServiceResponse GetValue(string variableName);

        [OperationContract]
        RemoteServiceResponse SetValue(string variableName, double newValue);

        [OperationContract]
        RemoteServiceResponse EmulateEvent(string eventTarget, string eventName, string eventParameter);
    }
}

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace SPAD.neXt.Interfaces.ServiceContract
{
    public static class RemoteServiceContract
    {
        public static readonly Uri ServiceUrl  = new Uri("net.pipe://localhost/SPAD.neXt");
        public static readonly string ServiceEndpoint = "RemoteService";
    }

    public sealed class RemoteServiceResponse
    {
        public bool HasError { get; set; }
        public string Error { get; set; }
        public double Value { get; set; }
    }

    public sealed class RemoteEventTarget
    {
        public string Name { get; set; }
        public HashSet<string> EventNames { get; set; }
    }

    [ServiceContract( Namespace = Constants.Namespace , CallbackContract = typeof(IRemoteServiceCallback))]
    [ServiceKnownType(typeof(RemoteServiceResponse))]
    [ServiceKnownType(typeof(RemoteEventTarget))]
    public interface IRemoteService
    {
        [OperationContract]
        RemoteServiceResponse GetValue(string variableName);

        [OperationContract]
        RemoteServiceResponse SetValue(string variableName, double newValue);

        [OperationContract]
        RemoteServiceResponse EmulateEvent(string eventTarget, string eventName, string eventParameter);

        [OperationContract]
        List<RemoteEventTarget> GetEventTargets();

        [OperationContract]
        string GetVersion();
    }

    public interface IRemoteServiceCallback
    {
        [OperationContract(IsOneWay = true)]
        void RemoteEvent(string eventName);
    }
}

Make RemoteService a Duplex Service
Make RemoteService a Duplex Service
