{"id":17168190,"url":"https://github.com/nadilas/ds-orpc-java","last_synced_at":"2025-08-30T23:35:09.387Z","repository":{"id":104377134,"uuid":"94697494","full_name":"nadilas/ds-orpc-java","owner":"nadilas","description":"Deepstream.io object based RPC handler extension including session handling and server-to-client callback using protocol-buffers.","archived":false,"fork":false,"pushed_at":"2019-05-17T23:45:22.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T05:18:11.283Z","etag":null,"topics":["callback","consumer","deepstream","kotlin","object-oriented","protobuf-definitions","protocol-buffers","rpc","session"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nadilas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-06-18T15:55:49.000Z","updated_at":"2019-05-17T23:45:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"61e6b51d-be5f-40f4-a734-ad9e8ffc8ac0","html_url":"https://github.com/nadilas/ds-orpc-java","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadilas%2Fds-orpc-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadilas%2Fds-orpc-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadilas%2Fds-orpc-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadilas%2Fds-orpc-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nadilas","download_url":"https://codeload.github.com/nadilas/ds-orpc-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245327104,"owners_count":20597153,"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":["callback","consumer","deepstream","kotlin","object-oriented","protobuf-definitions","protocol-buffers","rpc","session"],"created_at":"2024-10-14T23:11:24.095Z","updated_at":"2025-03-24T18:27:24.153Z","avatar_url":"https://github.com/nadilas.png","language":"Kotlin","readme":"[![CircleCI](https://circleci.com/gh/nadilas/ds-orpc-java.svg?style=shield)](https://circleci.com/gh/nadilas/ds-orpc-java)\n[![CircleCI](https://thumbs.dreamstime.com/z/background-texture-color-wax-crayons-random-pattern-abstract-29035891.jpg)](https://thumbs.dreamstime.com/z/background-texture-color-wax-crayons-random-pattern-abstract-29035891.jpg)\n\n# ds-orpc-java\n\nDeepstream.io object based RPC handler extension.\n\n- [Featrues](#featrues)\n- [Todo](#todo)\n- [Usage in Kotlin](#usage-in-kotlin)\n  - [Compiling source from protobuf definitions](#compiling-source-from-protobuf-definitions)\n  - [Creating a Service Provider](#creating-a-service-provider)\n  - [Using the endpoints in a client](#using-the-endpoints-in-a-client)\n\n### Featrues\n\n- `interface` implementations as provider classes\n- automatic parsing and conversion of input parameters and return values\n- Session based callback implementations (from backend to frontend client)\n\n### Todo\n\n- code generators from IDL (preferred solution protobuf-plugin) for:\n    - kotlin\n    - javascript\n    - cpp\n- js client\n- cpp client\n\n### Usage in Kotlin\n\n#### Compiling source from protobuf definitions\n\nTODO\n\n#### Creating a Service Provider\n\nFor a complete example, look at the examples package. A very basic usage with the compiled protobuf source looks like this:\n\n```kotlin\n/**\n * The simplest usage of the RpcHandler extension\n */\nclass ExampleService101 {\n    private var rpcHandler: IProtoRpcHandler\n    private val logger = LoggerFactory.getLogger(ExampleService101::class.java)\n    private var appName: String = \"ExampleService101\"\n    val deepstreamClient: DeepstreamClient\n\n    constructor() {\n        val version = ExampleService101::class.java.`package`.implementationVersion\n        logger.info(\"Starting $appName v$version\")\n        deepstreamClient = DeepstreamClient(\"localhost:6020\")\n        // Standard login to deepstream client\n        deepstreamClient.login()\n\n        // Retrieving the RpcHandler extension\n        rpcHandler = deepstreamClient.mappedRpcHandler(ClientMode.Provider)\n\n        // Register global providers and session providers from one call, session dependant providers will be redirected to SessionManager\n        rpcHandler.register(::GlobalDummyProviderImpl, ::GlobalDummyProvider2Impl, ::SessionDummyProviderImpl)\n\n        // print registered global endpoints\n        val global = rpcHandler as DefaultProtoRpcHandlerImpl\n        global.listProvidedMethods().forEach {\n            it.value.forEach {\n                logger.info(\"Endpoint: $it\")\n            }\n        }\n\n        // print registered session endpoints\n        rpcHandler.sessionProvider.listProvidedMethods().forEach {\n            val session = it.key\n            it.value.forEach {\n                it.value.forEach {\n                    logger.info(\"Endpoint: $it\")\n                }\n            }\n        }\n    }\n\n    fun shutdown() {\n        // finish providing session\n        rpcHandler.unregister()\n        deepstreamClient.close()\n    }\n\n}\n\n\nfun main(args: Array\u003cString\u003e) {\n    val service = ExampleService101()\n}\n```\n\nThe following classes in the above service are implementations of the generated interfaces from the protobuf definitions:\n- GlobalDummyProviderImpl implements GlobalDummyProvider\n- GlobalDummyProvider2Impl implements GlobalDummyProvider2\n- SessionDummyProviderImpl implements SessionDummyProviderImpl\n\n#### Using the endpoints in a client\n\nNow that the server is started and providing global and session endpoints as well, let's take a look at an example client, which would use these endpoints:\n\nThe following classes are generated from the protobuf definitions:\n- GeneratedGlobalDummyProviderConsumer - a consumer implementation with all the methods of the GlobalDummyProvider interface\n- GeneratedAllServiceConsumer - an all-in-one consumer providing access to all consumer implementations and through that to all methods\n\n```kotlin\nfun main(args: Array\u003cString\u003e) {\n    val deepstream = DeepstreamClient(\"localhost:6020\")\n\n    try {\n        deepstream.login()\n\n        val rpcHandler = deepstream.mappedRpcHandler()\n\n        val session: DefaultSession? = rpcHandler.startSession()\n\n        // using the global providers without a session\n        val globalDummyProviderConsumer = GeneratedGlobalDummyProviderConsumer(deepstream)\n        val globalProviderOutput = globalDummyProviderConsumer.testMethod01(DummyProviderInput(\"global message input\"))\n        val msg = globalProviderOutput?.msg\n        println(\"dummy global call responded: $msg\")\n\n        if(session == null) {\n            println(\"failed to initialize session... but we still had globals\")\n            deepstream.close()\n            System.exit(3)\n        }\n\n        // using the session\n        val serviceConsumer = GeneratedAllServiceConsumer(session!!, deepstream)\n        \n        // make simple call\n        val dummyProviderOutput: DummyProviderOutput?\n        try {\n            dummyProviderOutput = serviceConsumer.generatedSessionDummyProvider.sessionScopeTestMethod01(DummyProviderInput(\"first message\"))\n            println(\"dummy session call responded: \" + dummyProviderOutput!!.msg)\n        } catch(e: Exception) {\n            println(\"failed to get dummy session response. Error=${e.message}\")\n        }\n\n        // dummy wait\n        Thread.sleep(5000)\n        rpcHandler.closeSession()\n    } catch(e: Exception) {\n        print(\"there was en error: ${e.message}\")\n    } finally {\n        deepstream.close()\n        System.exit(0)\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnadilas%2Fds-orpc-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnadilas%2Fds-orpc-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnadilas%2Fds-orpc-java/lists"}