add first api core library and implement socket.io communication

This commit is contained in:
Gregor Biswanger
2017-10-03 03:28:56 +02:00
parent 606629c9a2
commit 852d3c170d
10 changed files with 359 additions and 5 deletions

36
ElectronNET.API/App.cs Normal file
View File

@@ -0,0 +1,36 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using Quobject.SocketIoClientDotNet.Client;
using System;
namespace ElectronNET.API
{
public class App
{
private readonly Socket _socket;
private readonly JsonSerializer _jsonSerializer;
public App(int width, int height)
{
_jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
var socket = IO.Socket("http://localhost:3000");
socket.On(Socket.EVENT_CONNECT, () =>
{
Console.WriteLine("Verbunden!");
var browserWindowOptions = new BrowserWindowOptions() {
Height = height,
Width = width
};
socket.Emit("createBrowserWindow", JObject.FromObject(browserWindowOptions, _jsonSerializer));
});
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SocketIoClientDotNet" Version="1.0.3" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
namespace ElectronNET.API.Entities
{
public class BrowserWindowOptions
{
public int Width { get; set; }
public int Height { get; set; }
public bool Show { get; set; }
}
}