Commit 6cf091ef by liulongfei

项目搭建

parent 70f03df4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Connection
{
/// <summary>
/// 包装终结点管理器
/// </summary>
public interface ITVPEndpointManager
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Connection;
namespace VIZ.TVP.Connection
{
/// <summary>
/// Viz连接
/// </summary>
public class VizConnection
{
/// <summary>
/// 终结点管理器集合
/// </summary>
private Dictionary<string, VizEndpointManager> endpointManagers = new Dictionary<string, VizEndpointManager>();
/// <summary>
/// 获取VIZ终结点管理器
/// </summary>
/// <param name="key">终结点管理器键</param>
/// <returns>终结点管理器</returns>
public VizEndpointManager GetEndpointManager(string key)
{
this.endpointManagers.TryGetValue(key, out VizEndpointManager manager);
return manager;
}
/// <summary>
/// 添加VIZ终结点管理器
/// </summary>
/// <param name="manager">终结点管理器</param>
public void AddEndpointManager(VizEndpointManager manager)
{
manager.VizConnection = this;
lock (this.endpointManagers)
{
this.endpointManagers.Add(manager.Key, manager);
}
}
/// <summary>
/// 移除UDP终结点管理器
/// </summary>
/// <param name="key">终结点管理器键</param>
public void RemoveEndpointManager(string key)
{
lock (this.endpointManagers)
{
if (this.endpointManagers.ContainsKey(key))
{
this.endpointManagers.Remove(key);
}
}
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
lock (this.endpointManagers)
{
foreach (VizEndpointManager manager in this.endpointManagers.Values)
{
manager.Dispose();
}
this.endpointManagers.Clear();
}
}
}
}
\ No newline at end of file
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Connection;
using VizConnectC;
using VIZ.Framework.Core;
using System.Web.WebSockets;
namespace VIZ.TVP.Connection
{
/// <summary>
/// Viz终结点管理器
/// </summary>
public class VizEndpointManager : ITVPEndpointManager, IDisposable
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(VizEndpointManager));
/// <summary>
/// VIZ总结点管理器
/// </summary>
/// <param name="key">键</param>
public VizEndpointManager(string key)
{
this.Key = key;
this.vizEnginePool = new VizEnginePool();
this.vizEnginePool.Connected += VizEnginePool_Connected;
this.vizEnginePool.Disconnected += VizEnginePool_Disconnected;
}
/// <summary>
/// 键
/// </summary>
public string Key { get; private set; }
/// <summary>
/// 远端IP
/// </summary>
public string RemoteIP { get; private set; }
/// <summary>
/// 远端端口
/// </summary>
public int RemotePort { get; private set; }
/// <summary>
/// 是否处于连接状态
/// </summary>
public bool IsConnected { get; private set; }
/// <summary>
/// 连接状态改变事件参数
/// </summary>
public event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged;
/// <summary>
/// VIZ连接
/// </summary>
public VizConnection VizConnection { get; internal set; }
/// <summary>
/// 引擎连接池
/// </summary>
private VizEnginePool vizEnginePool;
/// <summary>
/// 连接
/// </summary>
/// <param name="remoteIP">远程IP</param>
/// <param name="remotePort">远程端口</param>
public void Connect(string remoteIP, int remotePort)
{
this.RemoteIP = remoteIP;
this.RemotePort = remotePort;
this.vizEnginePool.AddRenderer(remoteIP, remotePort);
this.vizEnginePool.Connect();
}
/// <summary>
/// 断开连接
/// </summary>
public void Disconnect()
{
this.vizEnginePool.Disconnect();
}
/// <summary>
/// 发送消息
/// </summary>
/// <param name="message">消息</param>
public void Send(string message)
{
this.vizEnginePool.Send(message);
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
this.vizEnginePool?.Disconnect();
this.vizEnginePool?.Dispose();
this.vizEnginePool = null;
}
/// <summary>
/// 断开连接时触发
/// </summary>
private void VizEnginePool_Disconnected(object sender, VizEnginePool.ConnectionEventArgs e)
{
this.IsConnected = false;
this.ConnectionStateChanged?.Invoke(this, new ConnectionStateChangedEventArgs(this, false));
}
/// <summary>
/// 连接时触发
/// </summary>
private void VizEnginePool_Connected(object sender, VizEnginePool.ConnectionEventArgs e)
{
this.IsConnected = true;
this.ConnectionStateChanged?.Invoke(this, new ConnectionStateChangedEventArgs(this, true));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Connection
{
/// <summary>
/// 包装连接管理器
/// </summary>
public static class TVPConnectionManager
{
}
}
...@@ -47,9 +47,17 @@ ...@@ -47,9 +47,17 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="VizConnectC, Version=0.8.0.2123, Culture=neutral, PublicKeyToken=f599d6c637d08eed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\VizConnectC.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Protocol\ITVPEndpointManager.cs" />
<Compile Include="Protocol\VIZ\VizConnection.cs" />
<Compile Include="Protocol\VIZ\VizEndpointManager.cs" />
<Compile Include="TVPConnectionManager.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj"> <ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj">
......
...@@ -138,6 +138,8 @@ ...@@ -138,6 +138,8 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="VizRender\Controller\VizController\IVizSupport.cs" />
<Compile Include="VizRender\Controller\VizController\VizController.cs" />
<Compile Include="VizRender\ViewModel\VizRenderViewModel.cs" /> <Compile Include="VizRender\ViewModel\VizRenderViewModel.cs" />
<Compile Include="VizRender\VizRenderPluginLifeCycle.cs" /> <Compile Include="VizRender\VizRenderPluginLifeCycle.cs" />
<Compile Include="VizResource\Controller\VizResourceFile\IVizResourceFileSupport.cs" /> <Compile Include="VizResource\Controller\VizResourceFile\IVizResourceFileSupport.cs" />
...@@ -221,6 +223,7 @@ ...@@ -221,6 +223,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Connection\" />
<Folder Include="Login\Service\" /> <Folder Include="Login\Service\" />
<Folder Include="Setup\" /> <Folder Include="Setup\" />
</ItemGroup> </ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Module
{
internal class IVizSupport
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Module
{
/// <summary>
/// VIZ控制器
/// </summary>
public class VizController
{
}
}
...@@ -78,5 +78,9 @@ ...@@ -78,5 +78,9 @@
<Name>VIZ.TVP.Storage</Name> <Name>VIZ.TVP.Storage</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="VIZ\Implementation\" />
<Folder Include="VIZ\Interface\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment