Commit graph

65 commits

Author SHA1 Message Date
d2a1a8ebe5 Use local reference to Network in constructor
To allow customizing the bc module in compatibility wrappers, use the
local reference instead of a global one.  This means a wrapper module
could set `BaseControl.Network` to a different default.
2021-01-31 13:33:04 +01:00
22328f313d Add fallback when uuid is not available
If the `uuid` module does not exist, fall back to a primitive ID
generation mechanism based on just math.random().  The fallback
mechanism provides the same amount of entropy so we can be sure this
won't degrade quality of the identifiers.
2021-01-30 11:13:43 +01:00
e2da98fbf4 Fallback to os.clock() if computer.uptime() is not available
To be compatible with systems that don't have computer.uptime(), use
os.clock() as a fallback.  The time is only used for timeout
calculations.
2021-01-30 10:33:48 +01:00
67cbb5badc Move serialization import into network implementation
The (default) network implementation is the only place where
`serialization` is used.  Thus, move the import into its constructor so
we don't unnecessarily load the module unconditionally.
2021-01-29 23:29:54 +01:00
4a5349be96 Switch from lunit to u-test
lunit is unmaintained since ~2011.  Switch to u-test [1] instead which
seems to be more actively maintained.

[1]: https://github.com/IUdalov/u-test
2021-01-29 22:11:16 +01:00
0d852d7aac Make cleanup more robust
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-19 14:13:49 +02:00
af97600952 Actually include bit32
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 23:12:31 +02:00
13b8fe9cea Use bit32 for Lua 5.2 compatibility
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 22:50:44 +02:00
b44f63a1bb Use bit32 for lua 5.2 compat
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 22:47:51 +02:00
c27e889d45 Cancel listeners when closing
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 22:26:03 +02:00
11babfad9e Cleanup
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 22:22:13 +02:00
2b935b87e4 Add timeout to call_sync
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:49:37 +02:00
253e04ff5d Implement batch register
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:41 +02:00
e8ec24dacc Small refactor
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:41 +02:00
50ae923ef7 Add late installed listeners
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:41 +02:00
c33fdd41a6 Implement listen cancelling
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:41 +02:00
719201e950 Implement listening
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
8fb07e22cc Implement close()
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
d6aa1637f1 Test fixes
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
1a9422af7d Better errors and return codes
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
c6f019f271 No reannouncing self
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
28a52cfd7d Only announce if bc has names
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
b9c3674755 Actually make bc timeout
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
9f10348b58 Implement finalize
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
1b73d0d04c Make get and call_sync error
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
4b5fcf3d99 More tests
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
9c44faa811 Fix network mock
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
646a5b28fd Update README
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:40 +02:00
62658906d8 Fix lunit not honoring "-t"
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
3b290e6853 Move pulling into network
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
0eed392d6e Fix pull-filters
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
888ad288af Implement call_sync
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
e4f19c3e20 Implement simple verb calling
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
c6bbdcf984 Modularize tests
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
da6c36922b Add get and pull
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
7063e7445d Basic network
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
e328ae0ab9 Improve table hierarchy
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
f9a14ecaeb Implement set and call
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
3508870c7f A new beginning
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
b2a12cc2dc Refactor dummies
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
6c51c4cb4e Fix indent
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
9f8e62923e Update README again
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
132cfb9921 Update README
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:39 +02:00
b205779a29 Rewrite attempt 1
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-17 12:42:02 +02:00
126d420e3c Update README
Signed-off-by: Rahix <rahix@rahix.de>
2019-04-12 10:50:26 +02:00
3c4920489a
Cleanup
Signed-off-by: Rahix <rahix@rahix.de>
2019-03-17 19:37:55 +01:00
c3ce5b0ac8
Fix some variables being non-local
Signed-off-by: Rahix <rahix@rahix.de>
2019-03-17 18:59:33 +01:00
9c32c826ea
More parameter verb-call checks
Signed-off-by: Rahix <rahix@rahix.de>
2019-03-16 14:47:24 +01:00
dc0e021ef6
Add test for verb parameter
Signed-off-by: Rahix <rahix@rahix.de>
2019-03-16 13:53:37 +01:00
fa0c331f8e Make testable version work in-game
Signed-off-by: Rahix <rahix@rahix.de>
2019-03-08 23:53:23 +01:00