Merge branch 'feature/server-project-bootstrap' of https://github.com/chkr1011/MQTTnet into feature/server-project-bootstrap

This commit is contained in:
Kiarash
2019-03-10 16:02:45 +01:00
5 changed files with 31 additions and 18 deletions
+4 -4
View File
@@ -36,13 +36,13 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\app\app.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\app\app.js.map">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
@@ -76,7 +76,7 @@
<ItemGroup>
<TypeScriptCompile Include="wwwroot\app\app.ts">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</TypeScriptCompile>
</ItemGroup>
@@ -30,7 +30,6 @@ namespace MQTTnet.Server.Mqtt
public MqttServerService(
Configuration.SettingsModel settings,
CustomMqttFactory mqttFactory,
MqttWebSocketServerAdapter webSocketServerAdapter,
MqttClientConnectedHandler mqttClientConnectedHandler,
MqttClientDisconnectedHandler mqttClientDisconnectedHandler,
MqttClientSubscribedTopicHandler mqttClientSubscribedTopicHandler,
@@ -52,15 +51,19 @@ namespace MQTTnet.Server.Mqtt
_pythonScriptHostService = pythonScriptHostService ?? throw new ArgumentNullException(nameof(pythonScriptHostService));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
WebSocketServerAdapter = new MqttWebSocketServerAdapter(mqttFactory.Logger.CreateChildLogger());
var adapters = new List<IMqttServerAdapter>
{
new MqttTcpServerAdapter(mqttFactory.Logger.CreateChildLogger(nameof(MqttTcpServerAdapter))),
webSocketServerAdapter
new MqttTcpServerAdapter(mqttFactory.Logger.CreateChildLogger()),
WebSocketServerAdapter
};
_mqttServer = mqttFactory.CreateMqttServer(adapters);
}
public MqttWebSocketServerAdapter WebSocketServerAdapter { get; }
public void Configure()
{
_pythonScriptHostService.RegisterProxyObject("publish", new Action<PythonDictionary>(Publish));
+2 -7
View File
@@ -1,11 +1,9 @@
using System;
using System.Net.WebSockets;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MQTTnet.AspNetCore;
using MQTTnet.Server.Logging;
using MQTTnet.Server.Mqtt;
using MQTTnet.Server.Scripting;
@@ -31,8 +29,7 @@ namespace MQTTnet.Server
IHostingEnvironment environment,
MqttServerService mqttServerService,
PythonScriptHostService pythonScriptHostService,
DataSharingService dataSharingService,
MqttWebSocketServerAdapter mqttWebSocketServerAdapter)
DataSharingService dataSharingService)
{
if (environment.IsDevelopment())
{
@@ -64,8 +61,7 @@ namespace MQTTnet.Server
{
using (var webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false))
{
await mqttWebSocketServerAdapter.RunWebSocketConnectionAsync(webSocket,
$"{context.Connection.RemoteIpAddress}:{context.Connection.RemotePort}").ConfigureAwait(false);
await mqttServerService.WebSocketServerAdapter.RunWebSocketConnectionAsync(webSocket, context).ConfigureAwait(false);
}
}
else
@@ -99,7 +95,6 @@ namespace MQTTnet.Server
services.AddSingleton<DataSharingService>();
services.AddSingleton<MqttNetLoggerWrapper>();
services.AddSingleton<MqttWebSocketServerAdapter>();
services.AddSingleton<CustomMqttFactory>();
services.AddSingleton<MqttServerService>();