{"id":19771381,"url":"https://github.com/yswenli/saea","last_synced_at":"2025-05-15T15:06:27.934Z","repository":{"id":43108133,"uuid":"125656655","full_name":"yswenli/SAEA","owner":"yswenli","description":"SAEA.Socket is a high-performance IOCP framework TCP based on dotnet standard 2.0; Src contains its application test scenarios, such as websocket,rpc, redis driver, MVC WebAPI, lightweight message server, ultra large file transmission, etc. SAEA.Socket是一个高性能IOCP框架的 TCP，基于dotnet standard 2.0；Src中含有其应用测试场景，例如websocket、rpc、redis驱动、MVC WebAPI、轻量级消息服务器、超大文件传输等","archived":false,"fork":false,"pushed_at":"2025-02-19T08:54:19.000Z","size":61304,"stargazers_count":421,"open_issues_count":5,"forks_count":128,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-05-08T00:51:19.531Z","etag":null,"topics":["chat","high-performance","iocp","mqtt","mvc","mvc-webapi","mvcwebapi","queue","redis","redisclient","rediscluster","redisdrive","rpc","socket","tcp","webapi","webserver","websocket-client","websocketclient","websockets"],"latest_commit_sha":null,"homepage":"http://www.cnblogs.com/yswenli/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yswenli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-17T18:12:49.000Z","updated_at":"2025-05-07T04:00:18.000Z","dependencies_parsed_at":"2024-05-31T04:03:10.571Z","dependency_job_id":null,"html_url":"https://github.com/yswenli/SAEA","commit_stats":{"total_commits":708,"total_committers":3,"mean_commits":236.0,"dds":"0.40254237288135597","last_synced_commit":"d9ef1eabba7755f3cb3d816dd1a8f309545734c5"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yswenli%2FSAEA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yswenli%2FSAEA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yswenli%2FSAEA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yswenli%2FSAEA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yswenli","download_url":"https://codeload.github.com/yswenli/SAEA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat","high-performance","iocp","mqtt","mvc","mvc-webapi","mvcwebapi","queue","redis","redisclient","rediscluster","redisdrive","rpc","socket","tcp","webapi","webserver","websocket-client","websocketclient","websockets"],"created_at":"2024-11-12T05:01:23.822Z","updated_at":"2025-05-15T15:06:22.924Z","avatar_url":"https://github.com/yswenli.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Logo](/logo.jpg) SAEA.Socket\n\n[![NuGet version (SAEA)](https://img.shields.io/nuget/v/SAEA.Sockets.svg?style=flat-square)](https://www.nuget.org/packages?q=saea)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\n\nSAEA.Socket Is an IOCP high-performance sockets network framework, based on dotnet standard 2.0; SRC contains its use scenarios, such as large file transfer, websocket client and server, high-performance message queue, RPC, redis driver, httpserver, mqtt, MVC, DNS, message server, etc \u003cbr/\u003e\n\nSAEA.Socket是一个IOCP高性能sockets网络框架，基于dotnet standard 2.0；Src中含有其使用场景，例如大文件传输、websocket client and server、高性能消息队列、rpc、redis驱动、httpserver、MQTT、Mvc、DNS、消息服务器等\u003cbr/\u003e\n\nQQ群：788260487\n\n- [√] IOCP\n- [√] FileTransfer\n- [√] FTP\n- [√] MessageSocket\n- [√] QueueSocket\n- [√] MVC\n- [√] RPC\n- [√] Websocket\n- [√] RedisDrive\n- [√] MQTT\n- [√] DNS\n\n## Reference component\n\n引用组件，可以在nuget中搜索saea，或者直接输入命令 \n```\nInstall-Package SAEA.Sockets -Version 6.0.0.2\n```\nnuget url: https://www.nuget.org/packages?q=saea\n\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/saea.nuget.png?raw=true\" /\u003e\n\n------\n\n# Example\n\n## SAEA.Sockets for custom protocol\n\n### JT808 protocol\n\nThe test project is SAEA. Sockets Test, which demonstrates how to extend IContext, IUnpacker decoding and encoding to access SAEA. Sockets by using tripartite protocol (JT808).\n测试项目为SAEA.SocketsTest，其中演示了使用三方协议（JT808）来如何扩展IContext、IUnpacker解码、编码的方式接入SAEA.Sockets\n\n## FileTransfer\n\n### saea.filesocket usage\n\n```csharp\nvar fileTransfer = new FileTransfer(filePath);\nfileTransfer.OnReceiveEnd += _fileTransfer_OnReceiveEnd;\nfileTransfer.OnDisplay += _fileTransfer_OnDisplay;\nfileTransfer.Start();\n//send file\nfileTransfer.SendFile(string fileName, string ip)\n```\n\n## FTP\n\n### saea.ftp usage\n\n#### saea.ftpclient\n\n```csharp\nvar client = new FTPClient(ip, port, username, pwd);\nclient.Ondisconnected += _client_Ondisconnected;\nclient.Connect();\nvar path = client.CurrentDir();\nclient.Upload(filePath, (o, c) =\u003e\n{\n\tsize = c;\n\t_loadingUserControl.Message = $\"正在上传文件:{fileName},{(o * 100 / c)}%\";\n});\nclient.Download(fileName, Path.Combine(filePath, fileName), (o, c) =\u003e\n{\n\t_loadingUserControl.Message = $\"正在下载文件:{fileName}，{(o * 100 / c)}%\";\n});\n```\n#### saea.ftpserver\n\n```csharp\n\n_serverConfig.IP = ip;\n_serverConfig.Port = port;\nFTPServerConfigManager.Save();\n\nvar ftpServer = new FTPServer(_serverConfig.IP, _serverConfig.Port, _serverConfig.BufferSize);\nftpServer.OnLog += _ftpServer_OnLog;\nftpServer.Start();\n\n```\n\n## QueueTest\n\n### saea.queue server usage\n\n```csharp\nvar server = new QServer();\nserver.Start();\n```\n### saea.queue producer usage\n\n```csharp\nvar ipPort = \"127.0.0.1:39654\";\nQClient producer = new QClient(\"productor_\" + Guid.NewGuid().ToString(\"N\"), ipPort);\nproducer.OnError += Producer_OnError;\nproducer.OnDisconnected += Client_OnDisconnected;\nproducer.Connect();\nproducer.Publish(topic, msg);\n```\n\n### saea.queue consumer usage\n\n```csharp\nvar ipPort = \"127.0.0.1:39654\";\nQClient consumer = new QClient(\"subscriber_\" + Guid.NewGuid().ToString(\"N\"), ipPort);\nconsumer.OnMessage += Subscriber_OnMessage;\nconsumer.OnDisconnected += Client_OnDisconnected;\nconsumer.Connect();\nconsumer.Subscribe(topic);\n```\n\n## WebSocket\n### wsserver usage\n\n```csharp\nWSServer server = new WSServer();\nserver.OnMessage += Server_OnMessage;\nserver.Start();\n\nprivate static void Server_OnMessage(string id, WSProtocal data)\n{\n    Console.WriteLine(\"WSServer 收到{0}的消息：{1}\", ConsoleColor.Green, id, Encoding.UTF8.GetString(data.Content));\n    server.Reply(id, data);\n}\n```\n### wsclient usage\n\n```csharp\nWSClient client = new WSClient();\nclient.OnPong += Client_OnPong;\nclient.OnMessage += Client_OnMessage;\nclient.OnError += Client_OnError;\nclient.OnDisconnected += Client_OnDisconnected;\nclient.Connect();\nclient.Send(\"hello world!\");\nclient.Ping();\nclient.Close();\n```\n\n## RedisTest\n\n\u003ca href=\"https://github.com/yswenli/WebRedisManager\" target=\"_blank\"\u003ehttps://github.com/yswenli/WebRedisManager\u003c/a\u003e\n\n### saea.redis usage\n\n```csharp\n var cnnStr = \"server=127.0.0.1:6379;passwords=yswenli\";\n RedisClient redisClient = new RedisClient(cnnStr);\n redisClient.Connect();\n redisClient.GetDataBase(1).Set(\"key\", \"val\");\n var val = redisClient.GetDataBase().Get(\"key\");\n```\n\n## SAEA.MVC\n\n\u003ca href=\"https://github.com/yswenli/SAEA.Rested\" target=\"_blank\"\u003ehttps://github.com/yswenli/SAEA.Rested\u003c/a\u003e\n\n### saea.mvc init usage\n\n```csharp\n\nvar mvcConfig = SAEAMvcApplicationConfigBuilder.Read();\nSAEAMvcApplication mvcApplication = new SAEAMvcApplication(mvcConfig);\n//设置默认控制器\nmvcApplication.SetDefault(\"home\", \"index\");\nmvcApplication.SetDefault(\"index.html\");\n//限制\nmvcApplication.SetForbiddenAccessList(\"/content/\");\nmvcApplication.SetForbiddenAccessList(\".jpg\");\n\nmvcApplication.Start();\n```\n\n### saea.mvc controller usage\n\n```csharp\n[LogAtrribute]\npublic class HomeController : Controller\n{          \n\t[Log2Atrribute]\n\t[HttpGet]\n\t[HttpPost]\n\tpublic ActionResult Index()\n\t{\n\t\treturn Content(\"Hello,I'm SAEA.MVC！你好！\");\n\t}\n\t\n\tpublic ActionResult Show()\n\t{\n\t\tvar response = HttpContext.Response;\n\t\tresponse.ContentType = \"text/html; charset=utf-8\";\n\t\tresponse.Write(\"\u003ch3\u003e测试一下那个response对象使用情况！\u003c/h3\u003e参考消息网4月12日报道外媒称，法国一架“幻影-2000”战机意外地对本国一家工厂投下了炸弹。据俄罗斯卫星网4月12日援引法国蓝色电视台报道，事故于当地时间10日发生在卢瓦尔省，当时两架法国空军的飞机飞过韦尔尼松河畔诺让市镇上空，一枚炸弹从其中一架飞机上掉了下来，直接掉在了佛吉亚公司的工厂里。与此同时，有两人受伤。一名目击者称，“起初是两架战机飞过，然后我们都听到了物体撞击的声音，声音相当响，甚至盖过了飞过的飞机的噪音。”法国空军代表称，掉在工厂里的炸弹是演习用的，里面没有装炸药，本来是要将它投到离兰斯市不远的靶场。这名代表称事件“非常非常罕见”，目前正进行调查。\");\n\t\tresponse.End();\n\t\treturn Empty();\n\t}\n\t\n\tpublic ActionResult GetModels(string version, BasePamars basePamars, PagedPamars pagedPamars)\n\t{\n\t\treturn Content($\"version:{version}  basePamars:{Serialize(basePamars)}  pagedPamars:{Serialize(pagedPamars)}\");\n\t}\t\n\t\n\tpublic ActionResult Download()\n\t{\n\t\treturn File(HttpContext.Server.MapPath(\"/Content/Image/c984b2fb80aeca7b15eda8c004f2e0d4.jpg\"));\n\t}\n\n\t[HttpPost]\n\tpublic ActionResult Upload(string name)\n\t{\n\t\tvar postFiles = HttpContext.Request.PostFiles;\n\t\treturn Content($\"ok！name：{name}\");\n\t}\n}\n```\n\n## SAEA.RPC\n### saea.rpc service usage\n\n```csharp\nvar sp = new ServiceProvider();\nsp.OnErr += Sp_OnErr;\nsp.Start();\n\n[RPCService]\npublic class HelloService\n{\n\tpublic string Hello()\n\t{\n\t\treturn \"saea.rpc hello!\"\n\t}\n}\n```\n\n### saea.rpc client usage\n\n```csharp\nvar url = \"rpc://127.0.0.1:39654\";\nRPCServiceProxy cp = new RPCServiceProxy(url);\ncp.OnErr += Cp_OnErr;\ncp.HelloService.Hello();\n```\n\n## SAEA.Message\n\n### saea.message server usage\n\n```csharp\nMessageServer server = new MessageServer(1024, 1000 * 1000, 30 * 60 * 1000);\n\nserver.OnDisconnected += Server_OnDisconnected;\n\nserver.Start();\n```\n\n### saea.message client usage\n\n```csharp\nvar cc1 = new MessageClient();\ncc1.OnPrivateMessage += Client_OnPrivateMessage;\ncc1.Connect();\n\n//私信\ncc1.SendPrivateMsg(cc2.UserToken.ID, \"你好呀,cc2！\");\n\n//订阅\ncc1.Subscribe(channelName);\n\n//发送频道消息\ncc1.SendChannelMsg(channelName, \"hello!\");\n\n//创建群组\ncc1.SendCreateGroup(groupName);\n\n//加入群组\ncc2.SendAddMember(groupName);\n\n\n//发送群消息\ncc1.SendGroupMessage(groupName, \"群主广播了！\");\n\n//退群\ncc2.SendRemoveGroup(groupName);\n\n```\n\n## SAEA.MQTT\n\n### saea.mqtt server usage\n\n```csharp\nvar serverOptions = new MqttServerOptionsBuilder().Build();\n\nserver.ApplicationMessageReceived += Server_ApplicationMessageReceived;\n\nawait server.StartAsync(serverOptions)\n\nprivate static void Server_ApplicationMessageReceived(object sender, MQTT.Event.MqttMessageReceivedEventArgs e)\n{\n    Console.ForegroundColor = ConsoleColor.DarkGreen;\n\n    Console.WriteLine($\"Server收到消息，ClientId:{e.ClientId}，{Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}\");\n}\n```\n### saea.mqtt client usage\n\n```csharp\nvar client = factory.CreateMqttClient();\n\nvar clientOptions = new MqttClientOptionsBuilder().WithTcpServer(\"127.0.0.1\").Build();\n\nclient.ApplicationMessageReceived += Client_ApplicationMessageReceived;\n\nawait client.ConnectAsync(clientOptions);\n\nclient.SubscribeAsync(\"test/topic\").GetAwaiter().GetResult();\n\nclient.PublishAsync(\"test/topic\", \"hello\").GetAwaiter().GetResult();\n\n\nprivate static void Client_ApplicationMessageReceived(object sender, MQTT.Event.MqttMessageReceivedEventArgs e)\n{\n    Console.ForegroundColor = ConsoleColor.Red;\n\t\n    Console.WriteLine($\"client:{e.ClientId}收到消息:{Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}\");\n}\n\n```\n\n## Instance screenshot\n\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/FileSocketTest.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/QueueSocketTest.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/SAEA.MVC.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/SAEA.MVCTest.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/SAEA.RedisTest.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/SAEA.WebAPITest.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/WebsocketTest.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/redis%20cluster%20test.png?raw=true\" /\u003e\u003cbr/\u003e\n\u003cimg src=\"https://github.com/yswenli/SAEA/blob/master/rpc.png?raw=true\" /\u003e\u003cbr/\u003e\n\n## More\n\nWebRedisManager也是基于此的一款redis管理工具，具体可参见：https://www.cnblogs.com/yswenli/p/9460527.html git源码：https://github.com/yswenli/WebRedisManager\n\nGFF一款仿QQ通信程序同样基于此，具体可参见:https://github.com/yswenli/GFF \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyswenli%2Fsaea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyswenli%2Fsaea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyswenli%2Fsaea/lists"}