I ended opting for a Web API which let me "call" functions from the server trough the HTTP protocole. the URL is the "name" of the function and the data are either serialized in body or in the URL. Really simple and flexible, it should work out of the box on any framework that can use HTTP or i might be able to find a library that lets me do it.
My Test code looks like this :
Client:
private async Task SubmitJob()
{
JobModel job = new JobModel { ID = 42, name = "HelloJob", completion = 100.0f };
try
{
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.PostAsJsonAsync<JobModel>("http://localhost:53122/Jobs/Submit", job);
if (response.IsSuccessStatusCode)
lblSuccess.Text = "Success!";
else
lblSuccess.Text = "Failure!";
}
catch (Exception ex)
{
string s = ex.ToString();
}
}
private async Task GetJobs()
{
try
{
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("http://localhost:53122/Jobs/Info");
if (response.IsSuccessStatusCode)
{
List<JobModel> jobList = await response.Content.ReadAsAsync<List<JobModel>>();
txtConsole.Text = "";
foreach(var job in jobList)
{
string line = "ID: " + job.ID + " Name: " + job.name + " completion: " + job.completion + "\r\n";
txtConsole.Text += line;
}
}
else
{
txtConsole.Text = "Failure!";
}
}
catch (Exception ex)
{
string s = ex.ToString();
}
}
Server:
public async Task<IHttpActionResult> GetJobInfo(int jobId)
{
try
{
JobModel a = new JobModel { name = "jobA", ID = 102, completion = 100.0f };
JobModel b = new JobModel { name = "jobB", ID = 104, completion = 42.0f };
JobModel c = new JobModel { name = "jobC", ID = 106, completion = 0.0f };
List<JobModel> result = new List<JobModel> { a, b, c };
return Ok(result);
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
public async Task<IHttpActionResult> SubmitJob([FromBody] JobModel submitedJob)
{
return Ok();
}