never ask for our savior,he's busier than you.
nafos是一个轻量的网络通讯协程框架。它能同时支持HTTP,WEBSOCKET,TCP通信,并以非常友好的方式连接到大家的业务代码,无需tomcat等服务器,直接一个jar包就能简单启动。
哦~对了,他还是协程处理大家写的业务代码。让在IO密集处理的业务代码中,省下更多的上下文切换消耗和系统内存,在高并发冲击下变的更加可靠和快速。
而且,它很轻哦,启动十分快速的它,却能无缝兼容springboot,以及嵌入到其他任何系统中。
Nafos is a lightweight network communication protocol framework. It can support HTTP, websocket and TCP communication at the same time, and connect to your business code in a very friendly way,no need Tomcat and other servers, you can simply start a jar package directly.
oh ~ by the way, he ucoupled the code written by you with Coroutine . in the io intensive business code, it saves more context switching consumption and system memory, and becomes more reliable and fast under the impact of high concurrency.
Moreover, it's very light, very fast to start, but it can be seamlessly compatible with spring boot, as well as embedded in any other system.
@ComponentScan(value = ["com", "nafos"])
class HttpRun
fun main() {
httpServer().start(HttpRun::class.java)
socketServer().start(SocketRun::class.java)
}
/**
* HTTP模式的controller
*/
@Controller("/test")
class TestController {
@Get("/hello")
fun hello(map: Map<String, String>, nsRequest: NsRequest, nsRespone: NsRespone): Any {
println(map)
println(nsRequest.uri)
println(nsRespone)
return map
}
}
/**
* TCP或WEBSOCKET模式的controller
*/
@Controller
class TestSocketController {
@Handle(code = 500)
fun login(channel: Channel, map: Map<String, String>, clientCode: Int) {
println(map)
val token = "唯一字符串"
initChannel(channel, token, "北京一区", User("小明", "123"))
channel.writeAndFlush("$clientCode|{}")
}
@Handle(code = 501)
fun hello(client: Client, map: Map<String, String>, clientCode: Int) {
println(map)
client.joinRoom("123456")
client.sendMsg(clientCode, map)
}
}
Contributions are welcome! Open a pull request to fix a bug, or open an Issue to discuss a new feature or change.
欢迎参与项目贡献!比如提交PR修复一个bug,或者新建 Issue 讨论新特性或者变更。
This product is open source and free, and will continue to provide free community technical support. Individual or enterprise users are free to access and use.
产品开源免费,并且将持续提供免费的社区技术支持。个人或企业内部可自由的接入和使用。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。