master
Harald Wolff 2019-09-16 20:25:46 +02:00
parent a250671b73
commit a25ff49a69
6 changed files with 3003 additions and 24 deletions

View File

@ -73,6 +73,9 @@
<None Include="www\vue.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="www\vue-router.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -103,7 +103,16 @@ namespace ln.application.service
{
Monitor.PulseAll(ServiceThread);
}
ServiceThread.Join(TimeOut);
ServiceThread.Join(TimeOut>>1);
if (ServiceThread.ThreadState == ThreadState.WaitSleepJoin)
{
ServiceThread.Interrupt();
}
ServiceThread.Join(TimeOut >> 1);
if (IsAlive && force)
{
Logging.Log(LogLevel.INFO, "Service did not shutdown, enforcing {0}",ServiceName);

View File

@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ln.logging;
namespace ln.application.service
{
public class ServiceContainer : IEnumerable<ServiceDefinition>
@ -80,6 +81,20 @@ namespace ln.application.service
throw new NotSupportedException("ServiceDefinition not known to ServiceContainer");
ServiceDefinition sd = this[serviceDefinition.AssemblyName, serviceDefinition.ServiceClassName];
foreach (ServiceDefinition service in serviceDefinitions)
{
if (service.IsAlive)
{
if (service.ServiceBase.DependingServiceTypes.Contains(sd.ServiceType))
{
Logging.Log(LogLevel.INFO, "Stopping depending Service: {0}", service.ServiceClassName);
Stop(service);
}
}
}
sd.Stop();
}
public void Load(ServiceDefinition serviceDefinition)

View File

@ -16,6 +16,8 @@ namespace ln.application.service
public bool IsLoaded => ServiceBase != null;
public bool IsAlive => IsLoaded && ServiceBase.IsAlive;
public Type ServiceType => serviceType;
Assembly serviceAssembly;
Type serviceType;

View File

@ -3,7 +3,7 @@
var defaultOptions = {
url: null,
wsUpdate: null,
};
class LNInterface {
@ -20,15 +20,25 @@
this.rpcCallbacks = [];
this.rpcNextID = 1;
}
connect(){
var self = this;
this.close();
this.websocket = new WebSocket(this.options.url);
this.websocket.onclose = function(e){
self.options.wsClose && self.options.wsClose(e);
}
this.websocket.onerror = function(e){
alert("WebSocket caught error: " + e.date);
self.options.wsError && self.options.wsError(e);
}
this.websocket.onmessage = function(e){
try{
var j = JSON.parse(e.data);
if (j.state){
updateState(j.state);
self.options.wsUpdate && self.options.wsUpdate(j.state);
} else if (j.id)
{
for (var n=0;n<self.rpcCallbacks.length;n++)
@ -48,39 +58,89 @@
} catch(exc){
console.log(exc);
console.log("websocket malformed message: " + (e.data));
$("<textarea></textarea>").text(e.data).appendTo($(body));
}
}
return this;
}
rpc(module,method,parameters,cbfn){
var rpcCall = {
module: module,
method: method,
parameters: parameters,
id: this.rpcNextID++,
};
if (this.websocket.readyState != 1)
{
setTimeout(function(){
LN().rpc(module,method,parameters,cbfn);
},250);
if (!cbfn){
var p = new Promise(function(resolve,reject){
self.rpc(module,method,parameters, function(r,e){
if (e){
reject(e);
} else {
resolve(r);
}
});
});
return p;
} else {
this.rpcCallbacks.push( { id: rpcCall.id, cbfn: cbfn } );
this.websocket.send(
JSON.stringify(rpcCall)
);
var rpcCall = {
module: module,
method: method,
parameters: parameters,
id: this.rpcNextID++,
};
if (this.websocket.readyState != 1)
{
setTimeout(function(){
LN().rpc(module,method,parameters,cbfn);
},250);
} else {
this.rpcCallbacks.push( { id: rpcCall.id, cbfn: cbfn } );
this.websocket.send(
JSON.stringify(rpcCall)
);
}
}
}
close(){
this.websocket.close();
load(url, cb){
var self = this;
var x = new XMLHttpRequest();
if (!cb)
{
var p = new Promise(function(resolve,reject){
self.load(url, function(r,e){
if (e){
reject(e);
} else {
resolve(r);
}
});
});
return p;
} else {
x.onload = () => cb(x.responseText,null);
x.onerror = () => cb(null, { status: x.status, statusText: x.statusText });
x.open("GET", url);
x.send();
}
}
close(){
try {
this.websocket && this.websocket.close();
} catch (e){
}
this.websocket = null;
}
option(optname,optvalue){
if (arguments.length == 1)
{
return this.options[optname];
} else {
this.options[optname] = optvalue;
return this;
}
}
constructURL(){

2890
www/vue-router.js 100644

File diff suppressed because it is too large Load Diff