{"id":31524597,"url":"https://github.com/marcos8154/socketappserver","last_synced_at":"2025-10-03T17:32:13.988Z","repository":{"id":38142158,"uuid":"199875362","full_name":"marcos8154/SocketAppServer","owner":"marcos8154","description":"A simple, lightweight and fast MVC-like Socket server","archived":false,"fork":false,"pushed_at":"2025-05-16T04:11:31.000Z","size":3306,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T19:37:14.393Z","etag":null,"topics":["appserver","mvc","nuget","overview","server","socket-server"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcos8154.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}},"created_at":"2019-07-31T14:45:13.000Z","updated_at":"2025-05-16T04:11:34.000Z","dependencies_parsed_at":"2023-01-19T14:15:58.865Z","dependency_job_id":null,"html_url":"https://github.com/marcos8154/SocketAppServer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marcos8154/SocketAppServer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos8154%2FSocketAppServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos8154%2FSocketAppServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos8154%2FSocketAppServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos8154%2FSocketAppServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcos8154","download_url":"https://codeload.github.com/marcos8154/SocketAppServer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos8154%2FSocketAppServer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278197364,"owners_count":25946544,"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","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["appserver","mvc","nuget","overview","server","socket-server"],"created_at":"2025-10-03T17:31:33.932Z","updated_at":"2025-10-03T17:32:13.982Z","avatar_url":"https://github.com/marcos8154.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SocketAppServer\nA simple, extensible, lightweight and fast MVC-like Socket server\n\nThis framework will allow you to create a server that makes it easy to display data on intranet networks (and also the internet). The server will work in an \"embedded\" manner, with the premise of rapid deployment and startup in a production environment, without the need to configure application servers such as IIS or Apache.\n\nThe main communication of the server is based on Socket TCP / IP, which requires a specific client to connect and consume it. But if this is a flaw, the framework also allows to enable HTTP communication, which facilitates and expands the integration with a greater variety of clients (including mobile devices)\n\nFor more informations and tutorials, see project Wiki here: https://github.com/marcos8154/SocketAppServer/wiki\n\n**How to Setup**\n\nFirst, install the framework into your project through Nuget by searching for **\"MobileAppServer\"**, or by running the following command at the Visual Studio prompt: **Install-Package MobileAppServer -Version 2.0.7** (or higher)\n\nThe framework will add **NewtonSoft.Json** together\n\nNow let's implement a basic code that makes our server startup\n\n1 - Create a class in your project and name it Startup.cs, inheriting the AppServerConfigurator class\n```C#\n        public class Startup : AppServerConfigurator\n        {\n            public override void ConfigureServices(IServiceManager serviceManager)\n            {\n                //Here, we will enable and configure \n                //services and server modules.\n                //More details on the Wiki project\n                RegisterController(typeof(DeviceController));\n            }\n\n            public override ServerConfiguration GetServerConfiguration()\n            {\n\t        //Here, we must return the object that contains\n                //the server's operating parameters, such as port, \n                //Encoding, buffer and connection limit\n                return new ServerConfiguration(Encoding.UTF8,\n                         5000, 1024 * 100, false, 100, true);\n            }\n        }\n```\n\n2 - In the Main method, create a Host for the server, pointing the Startup class as a startup provider\n\n```C#\n   static void Main(string[] args)\n   {\n        SocketServerHost.CreateHostBuilder()\n               .UseStartup\u003cStartup\u003e()\n               .Run();\n   }\n```\n\n3 - Run the project and your server will be live :)\n\n![](https://raw.githubusercontent.com/marcos8154/SocketAppServer/master/CLI.png)\n\n**Implementing actions on your server**\n\nNow that your server is properly mapped and configured, the next step is the most fun: D\nLet's create classes for our Controllers, implementing the IContoller interface, and creating the methods we want to expose.\nActions methods must have the annotation/attribute **[ServerAction]**\n\nBelow is an example of how to implement an action with simple parameters, and another with parameters of complex types:\n\n```C#\n        public class DeviceController : IController\n        {\n            [ServerAction]\n            public void RegisterDevice(CustomerDevice device) //action with Complex type as paramneter\n            {\n                using (CustomerRepository repository = new CustomerRepository())\n                {\n                    IServiceManager services = ServiceManager.GetInstance();\n                    ILoggingService log = services.GetService\u003cILoggingService\u003e();\n\n                    log.WriteLog($\"Device registered\");\n\n                    repository.RegisterDevice(device);\n                }\n            }\n\n            [ServerAction]\n            public List\u003cCustomer\u003e SearchCustomers(string search) //action with simple type as parameter\n            {\n                using(CustomerRepository repository = new CustomerRepository())\n                {\n                    return repository.SearchCustomers(search);\n                }\n            }\n        }\n```\n\n**Making calls to your server**\n\n\nIn addition to responding by default in JSON, the server also receives requests through JSON syntax.\nThe calling commands are simple and clear and can be executed from any client-socket program.\n\nTake this DeviceController action as an example:\n\n```C#\n[ServerAction]\npublic void RegisterDevice(CustomerDevice device)\n{\n   ......\n}\n```\nFor the above action we will have the following request syntax sent by the client:\n\n```JSON\n\"Controller\" : \"DeviceController\",\n\"Action\" : \"RegisterDevice\",\n\"Parameters\" : [\n\t{ \"Name\" : \"device\", \"Value\" : \"{ CustomerDevice JSON object HERE }\" }\n]\n```\n\n**Making requests via the server's default client library**\n\nThe framework has a standard lib client written for it, and you can find it through Nuget:\n\"Install-Package MobileAppServer.Client -Version 1.2.0\" | or higher\n\nHaving it installed, you can submit requests for the same action example as follows:\n\n```C#\n\t    using MobileAppServerClient;\n\t    \n\t    .....\n\n            //default config for client\n            //necessary only on app startup\n            Client.Configure(\"serveraddress\", 5000, 200000);\n\n            //Instantiating the client. \n            //This will already result in an open connection on the server.\n            Client client = new Client();\n\n            CustomerDevice deviceObj = new CustomerDevice();\n\t    deviceObj.CustomerId = 8586965666;\n\t    deviceObj.DeviceName = \"Customer Device Example Name\";\n\t    deviceObj.Serial = \"ETL-PX00014185D9\"\n\n            //creating request with parameters\n            RequestBody rb = RequestBody.Create(\"DeviceController\", \"RegisterDevice\")\n                .AddParameter(\"device\", deviceObj);\n\n            //submit request to server\n            client.SendRequest(rb);\n\n            //get response and closes connection\n            client.GetResult();\n```\n\nIf your server has actions that return objects, you can easily convert them on the client side:\n\n```C#\n            List\u003cCustomerDevice\u003e devices = client.GetResult\u003cList\u003cCustomerDevice\u003e\u003e();\n```\n\nIf you want to enable HTTP communication on your server, so you don't need to use the specific client, see the step-by-step here https://github.com/marcos8154/SocketAppServer/wiki/Enable-HTTP-communication-on-your-server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcos8154%2Fsocketappserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcos8154%2Fsocketappserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcos8154%2Fsocketappserver/lists"}