mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-19 15:16:20 +00:00
add first api core library and implement socket.io communication
This commit is contained in:
36
ElectronNET.API/App.cs
Normal file
36
ElectronNET.API/App.cs
Normal 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));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
11
ElectronNET.API/ElectronNET.API.csproj
Normal file
11
ElectronNET.API/ElectronNET.API.csproj
Normal 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>
|
||||
9
ElectronNET.API/Entities/BrowserWindowOptions.cs
Normal file
9
ElectronNET.API/Entities/BrowserWindowOptions.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user