Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptma committed Sep 14, 2024
2 parents 857f0ef + 0b3f6df commit 4f70f88
Show file tree
Hide file tree
Showing 84 changed files with 8,594 additions and 8,106 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--
![JDK](https://img.shields.io/badge/JDK-17-blue.svg)
![Apache 2.0](https://img.shields.io/badge/Apache-2.0-blue.svg)
![Release](https://img.shields.io/badge/Release-1.1.1-blue.svg)
![Release](https://img.shields.io/badge/Release-1.1.2-blue.svg)

MqttInsight is an open source cross platform MQTT desktop client.

Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--
![JDK](https://img.shields.io/badge/JDK-17-blue.svg)
![Apache 2.0](https://img.shields.io/badge/Apache-2.0-blue.svg)
![Release](https://img.shields.io/badge/Release-1.1.1-blue.svg)
![Release](https://img.shields.io/badge/Release-1.1.2-blue.svg)

MqttInsight 是开源跨平台的 MQTT 图形客户端.

Expand Down
11 changes: 9 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ val organization: String = "ptma@163.com"
val copyright: String = "Copyright 2023 ptma@163.com"
val supportUrl: String = "https://github.com/ptma/mqtt-insight"

val flatlafVersion = "3.3"
val javetVersion = "2.2.2"
val flatlafVersion = "3.4"
val javetVersion = "3.0.4"
val fatJar = false

val requireModules = listOf(
Expand Down Expand Up @@ -109,6 +109,7 @@ dependencies {
exclude(group = "net.minidev", module = "json-smart")
}

implementation("commons-codec:commons-codec:1.15")
implementation("com.google.protobuf:protobuf-java:3.25.1")
implementation("org.msgpack:jackson-dataformat-msgpack:0.9.6")
implementation("org.apache.avro:avro:1.11.3") {
Expand Down Expand Up @@ -181,6 +182,12 @@ configure<PackagePluginExtension> {
customizedJre(true)
modules(requireModules)
jreDirectoryName("jre")
vmArgs(
listOf(
"-Xms256M",
"-Xmx2048M"
)
)
}

var taskPlatform = Platform.windows
Expand Down
17 changes: 17 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changelog
--
## 1.1.2 (2024-09-14)

* **新增 ✨**
* 发布消息支持随机变量
* 单条消息可指定背景色
* 增加消息大小的显示
* **优化 🙌**
* 窗口位置记忆支持多显示器
* 优化脚本引擎的关闭释放
* 清除消息后主动释放内存
* Base64 区分编码和解码
* 其他优化
* **修复 🐛**
* JSON 序列化可能存在的问题
* 消息内容格式化时可能出错的异常兼容
* 关闭订阅时未移除事件监听
* 修复基础可能报错的问题

## 1.1.1 (2024-01-18)

* **优化 🙌**
Expand Down
141 changes: 73 additions & 68 deletions doc/CodecScript.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,73 @@
编解码器脚本
--
MqttInsight 允许使用 JavaScript 来编写编解码器。

## 脚本加载

MqttInsight 会在启动时扫描**用户目录** `codecs` 文件夹下的 .js
文件,并自动加载到脚本引擎。在编解码器脚本中注册的编解码器的是全局可用的(在所有连接标签页中均可用),因此解码方法仅传入
payload 参数。
> **用户目录**:
> * Windows:MqttInsight.exe 所在目录;
> * Linux 和 MacOS:${user.home}/MqttInsight
## 可用内置模块
* codec - 编解码器注册器
* toast - 提示框工具
* logger - 日志工具
参考: [脚本内置模块](Modules.md)

## 示例
### 示例1
注册动态编解码器
```js
const fs = require("fs");
const protobuf = require('protocol-buffers');
var messages;
// Register a dynamic codec
codec.register("ProtoDynamicSample",
(payload) => { // decoder function
let buffer = Buffer.from(payload);
var obj = messages.SampleMessage.decode(buffer);
return JSON.stringify(obj);
},
(text) => { // encoder function
return messages.SampleMessage.encode(JSON.parse(text))
},
(file) => {// schema loader function
// load the specified .proto file
messages = protobuf(fs.readFileSync(file));
},
{
dynamic: true,
format: "json",
schemaExts: "proto"
}
);
```

### 示例2
注册静态解码器
```js
const fs = require("fs");
const protobuf = require('protocol-buffers');
var messages = protobuf(fs.readFileSync(file));
// Register a static decoder
codec.register("ProtoStaticSample",
(payload) => { // decoder function
let buffer = Buffer.from(payload);
var obj = messages.SampleMessage.decode(buffer);
return JSON.stringify(obj);
},
null,
{
dynamic: false,
format: "json"
}
);
```
编解码器脚本
--
MqttInsight 允许使用 JavaScript 来编写编解码器。

## 脚本加载和注册

MqttInsight 会在启动时扫描**用户目录** `codecs` 文件夹下的 .js
文件,并自动加载到脚本引擎。在编解码器脚本中注册的编解码器的是全局可用的(在所有连接标签页中均可用)。
> **用户目录**:
> * Windows:MqttInsight.exe 所在目录;
> * Linux 和 MacOS:${user.home}/MqttInsight
## 可用内置模块

* codec - 编解码器注册器
* toast - 提示框工具
* logger - 日志工具
参考: [脚本内置模块](Modules.md)

## 示例

### 注册动态编解码器

动态编解码器由于需要用户额外通过 UI 界面来指定模式文件(Schema),因此需要实现 `schemaLoader`
方法来处理用户选择的模式文件。并且,动态编解码器注册成功以后,并不会直接出现消息格式的可选列表中, 需要在"文件->
编解码设置"中新建编解码器并绑定模式文件。

```js
const fs = require("fs");
const protobuf = require('protocol-buffers');
var messages;
// Register a dynamic codec
codec.register("ProtoDynamicSample",
(topic, payload) => { // decoder function
let buffer = Buffer.from(payload);
var obj = messages.SampleMessage.decode(buffer);
return JSON.stringify(obj);
},
(topic, text) => { // encoder function
return messages.SampleMessage.encode(JSON.parse(text))
},
(file) => {// schema loader function
// load the specified .proto file
messages = protobuf(fs.readFileSync(file));
},
{
dynamic: true, // 动态编解码器
format: "json",
schemaExts: "proto" // 模式文件扩展名
}
);
```

### 注册静态解码器

```js
const fs = require("fs");
const protobuf = require('protocol-buffers');
var messages = protobuf(fs.readFileSync(file));
// Register a static decoder
codec.register("ProtoStaticSample",
(topic, payload) => { // decoder function
let buffer = Buffer.from(payload);
var obj = messages.SampleMessage.decode(buffer);
return JSON.stringify(obj);
},
null,
{
dynamic: false, // 静态解码器
format: "json"
}
);
```
Loading

0 comments on commit 4f70f88

Please sign in to comment.