Repository navigation
本地 UDP 服务器接入通用通道 - #236
Merged
Merged
本地 UDP 服务器接入通用通道#236
Conversation
新增通道名 udp-server:
- 收到数据时通过 SendChannelsReceived 转给 lua(带 from 和 data)
- lua 用 apiSend("udp-server", data) 发回时,回给最近一次发数据的地址
和 tcp-server 的用法保持一致。
Closes chenxuuu#162
Owner
|
能不能加个对应的demo?加到现有的通道例子脚本里 |
- channel-demo.lua 末尾加 udp-server 段:收到的数据带 from/data, apiSend 回给最近一次发数据的地址,也演示了用 table.from 指定目标 - LuaApi.md 新增「通用通道一览」表,把 uart/mqtt/tcp-server/socket-client/ netlab/winusb/udp-server 七个通道对应的选项卡、回调结构和发送写法列清楚 - udp-server 发送侧支持 table 里的 from("ip:port" / "[ipv6]:port")指定目标, 不填则沿用最近一次收到数据的地址
Collaborator
Author
|
两个都补了,在同一个 commit 里(80a3b25):
我这边是 Linux,WPF 项目编不了,所以只按代码逐行核过( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #162
你在 #162 里说「udp 的发和收是独立的两个页面,发的话有本地 socket 通道,收还没加,有空加上」,这个 PR 就是补本地 UDP 监听页的通用通道,通道名
udp-server,和tcp-server对齐:LuaApis.SendChannelsReceived("udp-server", new { from, data }),和tcp-server一样是{ from, data }的表,from是ip:port字符串apiSend("udp-server", data)会回给最近一次发数据的地址(服务器本身没有固定对端,先按「回给上一个发数据的」实现,如果更希望做成广播或指定地址,我再改)说明:本机是 Linux,WPF 老式 csproj 编不了,这个改动没法本地编译验证,麻烦你过一眼。