Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Update (#27)
Browse files Browse the repository at this point in the history
* Package Update to v1.4.1-Beta

* Package Update to v1.5.0-Beta
  • Loading branch information
timi137137 authored Aug 30, 2021
1 parent 07369da commit 30c0390
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
6 changes: 3 additions & 3 deletions AuroraNative/AuroraNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<SignAssembly>false</SignAssembly>
<DelaySign>false</DelaySign>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AssemblyVersion>1.4.1.0715</AssemblyVersion>
<FileVersion>1.4.1.0715</FileVersion>
<AssemblyVersion>1.5.0.0830</AssemblyVersion>
<FileVersion>1.5.0.0830</FileVersion>
<PackageIcon>Icon.png</PackageIcon>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<AssemblyName>AuroraNative</AssemblyName>
<RootNamespace>AuroraNative</RootNamespace>
<Version>1.4.1-Beta</Version>
<Version>1.5.0-Beta</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
Expand Down
15 changes: 15 additions & 0 deletions AuroraNative/AuroraNative.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions AuroraNative/Utils/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using AuroraNative.WebSockets;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;

namespace AuroraNative
{
Expand Down Expand Up @@ -242,13 +243,20 @@ public void RouterNotify(JObject Json)
internal static async void CheckVersion()
{
Logger.Debug("开始检查 go-cqhttp 版本是否符合最低版本...");
if ((await API.CurrentApi.GetVersionInfo()).TryGetValue("AppVersion", out object Version) && new Version(Version.ToString().Substring(1, Version.ToString().IndexOf('-') - 1)) < WebSocket.DependencyVersion)
Dictionary<string, object> Versions = (await API.CurrentApi.GetVersionInfo());
if (Versions["AppVersion"].ToString().Contains("devel"))
{
Logger.Warning($"框架最低依赖版本与 go-cqhttp 不符!请检查是否为最新的框架或符合的 go-cqhttp\ngo-cqhttp版本:{Version}\n框架最低依赖版本:v{WebSocket.DependencyVersion}");
Logger.Debug("go-cqhttp 版本为开发版,跳过检测");
}
else
{
Logger.Debug("go-cqhttp 版本符合最低版本!");
else {
if (Versions.TryGetValue("AppVersion", out object Version) && new Version(Version.ToString().Substring(1, Version.ToString().IndexOf('-') - 1)) < WebSocket.DependencyVersion)
{
Logger.Warning($"框架最低依赖版本与 go-cqhttp 不符!请检查是否为最新的框架或符合的 go-cqhttp\ngo-cqhttp版本:{Version}\n框架最低依赖版本:v{WebSocket.DependencyVersion}");
}
else
{
Logger.Debug("go-cqhttp 版本符合最低版本!");
}
}
WebSocket.IsCheckVersion = true;
}
Expand Down
8 changes: 8 additions & 0 deletions AuroraNative/WebSockets/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ public override void Create()
Logger.Error("连接到 go-cqhttp 服务器失败!请检查IP是否正确(需要携带端口号)或确认服务器是否启动和初始化完毕!", $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}");
}

/// <summary>
/// 创建并连接到WebSocket服务器
/// </summary>
public override void Create(string Host = "")
{
Create();
}

/// <summary>
/// 立刻中断并释放连接<para>注意!断开后需要重新Create</para>
/// </summary>
Expand Down
12 changes: 10 additions & 2 deletions AuroraNative/WebSockets/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public int port
/// <summary>
/// 创建WebSocket服务器并监听端口
/// </summary>
public override void Create()
public override void Create(string Host = "localhost")
{
try
{
Logger.Debug("反向WebSocket已创建,准备监听...", $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}");
Listener = new HttpListener();
Listener.Prefixes.Add("http://*:" + Port.ToString() + "/");
Listener.Prefixes.Add("http://" + Host + ":" + Port.ToString() + "/");
Listener.Start();
Logger.Info("开始监听来自 go-cqhttp 客户端的连接...");
Task.Run(Feedback);
Expand All @@ -67,6 +67,14 @@ public override void Create()
}
}

/// <summary>
/// 创建WebSocket服务器并监听端口
/// </summary>
public override void Create()
{
Create();
}

/// <summary>
/// 立刻中断并释放连接<para>注意!断开后需要重新Create</para>
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions AuroraNative/WebSockets/WebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public abstract class WebSocket
/// </summary>
public abstract void Create();
/// <summary>
/// 服务端创建 抽象方法
/// </summary>
public abstract void Create(string Host = "localhost");
/// <summary>
/// 客户端销毁 抽象方法
/// </summary>
public abstract void Dispose();
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<img src="https://img.shields.io/badge/OneBot-v11-blue?style=flat-square">
</a>
<a href="https://github.com/Mrs4s/go-cqhttp/releases">
<img src="https://img.shields.io/badge/go--cqhttp-v1.0.0--beta4-blueviolet?style=flat-square">
<img src="https://img.shields.io/badge/go--cqhttp-v1.0.0--beta6-blueviolet?style=flat-square">
</a>
<img src="https://img.shields.io/github/license/timi137137/AuroraNative?style=flat-square">
<img src="https://img.shields.io/github/workflow/status/timi137137/AuroraNative/BuildPackages/master?style=flat-square">
Expand Down Expand Up @@ -76,7 +76,7 @@

感谢以下大佬对本框架开发的帮助

[Jie2GG](https://github.com/Jie2GG) | [Yukari316](https://github.com/Yukari316) | [bleatingsheep](https://github.com/b11p)
[Jie2GG](https://github.com/Jie2GG) | [bleatingsheep](https://github.com/b11p)

### 使用到的开源库

Expand Down

0 comments on commit 30c0390

Please sign in to comment.