About Monkey 2 › Forums › Monkey 2 Programming Help › Redis integration
This topic contains 4 replies, has 3 voices, and was last updated by
Simon Armstrong 2 years ago.
-
AuthorPosts
-
March 22, 2017 at 2:08 am #7567
Any thoughts on best approaches to access redis from monkey?
March 22, 2017 at 2:44 am #7568The recommended C client for redis seems to be this one https://github.com/redis/hiredis which unfortunately uses a vararg based API but still perhaps simplest way to connect from monkey2 with a bit of glue code.
Monkey123redisContext *redisConnect(const char *ip, int port);void *redisCommand(redisContext *c, const char *format, ...);void freeReplyObject(void *reply);What experience have you had and do you have an immediate use case for this?
March 22, 2017 at 3:30 am #7569Thanks . . . I was using redis to store variables for realtime parametric adjustments in a local network for rapid prototyping in the IDE across multiple builds and nearby wireless devices. (Formerly Mac and iPad… now moving to custom platforms)
To me, this is essential to game development to be able to see changes reflected live and tweak them instantly.
I wanted to rewrite the socket server in monkey and see how it compares.
I’m a bit clueless at the moment as to how to run C in combo with monkey as well as typecast the values over to monkey variables . . . can you point to some example code that demonstrates something similar?
March 22, 2017 at 8:41 am #7573there is the c2mx2 tool(src/c2mx2.monkey2, you have to install LLVM read readme of c2mx2).Tthat could do this for you automatically (with luck), it will be a good base and warn you for some parts that he could not glue correctly.
I made some little exercices example for external imports here:
https://github.com/abakobo/learn_monkey2/tree/master/externs
https://github.com/abakobo/learn_monkey2/tree/master/char_t
(not sure all this works fineconst does not exist in monkey2 so sometimes it is a problem (with abstract/pure virtual things mostly).
for chars you’ll want to use libc module’s char_t types:[/crayon]Monkey12345678910111213141516171819202122232425[crayon-5cba9faa08623599872429 inline="true" ]#rem monkeydoc C/C++ 'char' type.#endStruct char_t="char"End#rem monkeydoc C/C++ 'const char' type.#endStruct const_char_t="const char"End#rem monkeydoc C/C++ 'signed char' type.#endStruct signed_char_t="signed char"End#rem monkeydoc C/C++ 'unsigned char' type#endStruct unsigned_char_t="unsigned char"End#rem monkeydoc C/C++ 'wchar_t' type#endStruct wchar_t="wchar_t"Endunfortunately not findable in the docs because of some doc generation bug…
March 22, 2017 at 8:49 pm #7576Hi Jason, if you have an online server I can test with (or link to simple one I can run locally) I would be keen to prototype a hiredis based monkey2 module.
-
AuthorPosts
You must be logged in to reply to this topic.