{"id":13421115,"url":"https://github.com/mage/mage-sdk-cpp","last_synced_at":"2025-04-10T02:14:19.995Z","repository":{"id":18124982,"uuid":"21202958","full_name":"mage/mage-sdk-cpp","owner":"mage","description":"MAGE SDK and libraries for C++ Development","archived":false,"fork":false,"pushed_at":"2014-08-15T09:45:01.000Z","size":18839,"stargazers_count":4,"open_issues_count":3,"forks_count":5,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-04-10T02:13:51.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.wizcorp.jp","language":"C","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/mage.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}},"created_at":"2014-06-25T12:50:35.000Z","updated_at":"2022-09-25T11:32:47.000Z","dependencies_parsed_at":"2022-07-25T06:31:58.744Z","dependency_job_id":null,"html_url":"https://github.com/mage/mage-sdk-cpp","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-sdk-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-sdk-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-sdk-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-sdk-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mage","download_url":"https://codeload.github.com/mage/mage-sdk-cpp/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142903,"owners_count":21054671,"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":[],"created_at":"2024-07-30T22:01:49.660Z","updated_at":"2025-04-10T02:14:19.972Z","avatar_url":"https://github.com/mage.png","language":"C","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"mage-sdk-cpp\n============\n\n![MAGE Logo](./img/logo.jpg)\n\nWhat is this MAGE thing anyway?\n-------------------------------\n\n- English\n\t- [http://www.wizcorp.jp/#portfolio](http://www.wizcorp.jp/#portfolio)\n- 日本語\n\t- [http://www.wizcorp.jp/#portfolio](http://www.wizcorp.jp/ja/#portfolio)\n\t- [http://www.spiralsense.jp/products/m-a-g-e/](http://www.spiralsense.jp/products/m-a-g-e/)\n\nDescription\n------------\n\nThis is a C++ library that enables you to interact with a MAGE\nserver. More specifically, it allows you to call any user commands\nmade available on a given server.\n\nInstallation\n-------------\n\n### Requirements\n\n#### OS X\n\nYou will need OS X 10.9 and up, with XCode installed.\n\nFor a better user experience with `magecli`,\nwe recommend that you install [GNU readline](http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html).\n\nWith brew:\n```bash\nbrew install readline\n```\n\n#### CentOS\n\n```\nsudo yum install cmake automake autoconf libtool libcurl-devel readline-devel\n```\n\nCMake 2.8+ is required. It can be found in the [rpmforge-extras](http://repoforge.org/use/) repository.\n\nA recent version of GCC is required to be able to use the C++11 features.\nYou can get one using the [Red Hat Developer Toolset](https://access.redhat.com/documentation/en-US/Red_Hat_Developer_Toolset/2/html/User_Guide/index.html).\n\n```bash\nwget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo\nyum install devtoolset-2-gcc devtoolset-2-gcc-c++ devtoolset-2-libstdc++-devel\n```\n\nThen you will have to run `scl enable devtoolset-2 bash` to start a new shell with the new GCC activated.\n\n#### Ubuntu/Debian\n\n```\nsudo apt-get install libcurl4-openssl-dev cmake libreadline-dev\n```\n\n### Setup\n\n```bash\ngit clone https://github.com/mage/mage-sdk-cpp.git\ncd mage-sdk-cpp\ngit submodule update --init\n```\n\n### OS X/Linux\n\n```\nmkdir build\ncd build\ncmake ..\nmake all\n```\n\n### Building for iOS, Android, WP8, etc\n\n**Note**: when building libraries under platforms,\nyou should never need to provide your own cURL implementation.\nWe are using the one coming from a bootstrapped cocos2d-x project;\nthis happens to work very well on all platforms tested so far. Please\n[post an issue](./issues/new) if you encounter any problems.\n\n#### Make all platforms\n\n```\nmake platforms\n```\n\n#### Make a specific platform\n\n```\nmake [ios|android|wp8]\n```\n\n### magecli\n\nThw default make will produce a binary called\n`magecli` under `./bin`. To use:\n\n```bash\n\u003e ./bin/magecli -h\nUsage: magecli -a [application name] -d [domain] [-p [protocol]] [-h]\n\n\t-a\tThe name of the MAGE application you wish to access\n\t-d\tThe domain name or IP address where the MAGE instance is hosted\n\t-p\tThe protocol through which you wish to communicate with MAGE (default: http)\n\t-h\tShow this help screen\n```\n\nSome real-life examples:\n\n![Screenshot](./img/screenshot.png)\n\nThis application can be useful for manually interacting\nwith a remote MAGE instance without having to write code\nyourself; great for testing and debugging.\n\n**Note**: In the future, we would love to add some manual\ncommands to do the following:\n\n* List available commands\n* Destroy current session (if it is set)\n* Store, manipulate and use JSON blobs in your user commands\n  (instead of having to paste long strings all the time)\n\nPlease let us know if any of those feature would be really\nuseful/critical to you.\n\n### Building the example scripts\n\n```\nmake examples\n```\n\nThis will build the example programs under ./examples. Feel\nfree to use them to experiment a bit with the API (you will need\nto change the application name and ports).\n\nIntegration\n-----------\n\n### With Cocos2dx\n\nComing soon\n\n### With Unity/Unreal/Cry/etc.\n\nWe haven't tried to integrate with these platforms yet. We\nwill add some integration notes for each of those projects\nas soon as we have experimented with them.\n\nEvents polling\n--------------\n\nYou can pull events from the `msgStream` of your MAGE server by using\nthe `void PullEvents(Transport transport);` function.\n\nTwo transports are available:\n* `LONGPOLLING`: the request will be kept open by the server,\n  until an event becomes available, or the server send a heartbeat.\n* `SHORTPOLLING`: the request will return immediately with the response\n  from the server.\n\nWhen you use `void StartPolling(transport transport);`,\na loop is started in another thread to call `PullEvents()`.\n\nIf you use `LONGPOLLING`, after each request a new one will be sent.\nIf you use `SHORTPOLLING`, the loop will wait `SHORTPOLLING_INTERVAL_SECS`\nseconds before sending a new request.\n\nBy default `SHORTPOLLING_INTERVAL_SECS` is set to 5 seconds.\nYou can change it, by adding a new flag in the `Makefile`.\nYou need to add `-DSHORTPOLLING_INTERVAL_SECS=5` with your value,\nat the end of the `CFGLAGS` line.\n\nConcurrency\n-----------\n\n```c++\nvirtual std::future\u003cvoid\u003e Call(const std::string\u0026 name,\n\t\t\t\t  const Json::Value\u0026 params,\n\t\t\t\t  const std::function\u003cvoid(mage::MageError, Json::Value)\u003e\u0026 callback,\n\t\t\t\t  bool doAsync) const;\n```\n\nWhen you use `mage::RPC::Call()` with a callback and in an asynchronous way,\nwith `doAsync` set to true, the callback will be called in a different thread.\n\n```c++\nvoid StartPolling(Transport transport = LONGPOLLING);\n```\n\nWhen you use `mage::RPC::StartPolling()`, all the `mage::RPC::ReceiveEvent()`\ncalls will be done in a different thread.\nIn consequence, your implementation of `mage::EventObserver::ReceiveEvent()`\nwill be called in a different thread too.\n\nIn these cases, you need to use `std::mutex` or other locking strategy to\nensure your data are not accessed at the same time by two different\nthreads.\n\nTodo\n-----\n\n- [ ] Test/fix build on CentOS, Debian and Ubuntu\n- [ ] Test integration against popular game development SDKs\n- [ ] Session handling: save the session when we receive it, and offer an API to interact with it\n- [ ] Make install/clean for the binaries (maybe)\n- [ ] CLI: Have the option to list and describe the remote calls\n\nConding Style\n-------------\n\nWe try to follow the [Google C++ Style Guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml).\nThere are some exceptions:\n* We use default arguments in functions;\n* We use C++ exceptions;\n* We use lambda expressions;\n* We use tabs for indentation and spaces for alignment.\n\nWe use the [Hungarian Notation](http://en.wikipedia.org/wiki/Hungarian_notation) to name class attributes.\nMore references on Hungarian Notation:\n* [http://web.mst.edu/~cpp/common/hungarian.html](http://web.mst.edu/~cpp/common/hungarian.html)\n* [http://www.cse.iitk.ac.in/users/dsrkg/cs245/html/Guide.htm](http://www.cse.iitk.ac.in/users/dsrkg/cs245/html/Guide.htm)\n\nYou can check if you follow the rules by running:\n```bash\nmake lint\n```\n\nSee also\n---------\n\n- [JSONCPP, the library we use for our JSON operations](http://jsoncpp.sourceforge.net/)\n- [libjson-rpc-cpp](https://github.com/cinemast/libjson-rpc-cpp)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmage%2Fmage-sdk-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmage%2Fmage-sdk-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmage%2Fmage-sdk-cpp/lists"}