Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
starwing committed Jan 21, 2016
1 parent efa0b70 commit 7656dca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
72 changes: 41 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
loki - one-header online game framework
`loki` - one-header online game framework
----------------------------------------

loki is a online game framework, inspired by cloudwu's
`loki` is a online game framework, inspired by cloudwu's
[skynet](https://github.com/cloudwu/skynet).

loki is not only used in online game server, but more. It's a multi-thread
service signal/slot system. Every service register it's own slots, and receive
message to offer service.
To start, see the header file
[loki.h](https://github.com/starwing/`loki`/blob/master/`loki`.h).
`loki` now doesn't have documentations for now, but I will finish that after
complete the built-in service.

loki only have one header as it's core. To define loki functions (only allow
in only **one** C file, define `LOKI_IMPLEMENTATION` before include `loki.h`.
loki also has several *built-in* service, that will defined as `lsvr_*.c`
files, each file can singly build as a DLL/so file, or build together with
lsvr_init.c file.
`loki` is not only used in online game server, but more. It's a *multi-thread*
service *signal/slot* system. Every service register it's own slots, and
send/receive message to offer service.

In loki, you must create a `lk_State` to contain all information loki used,
loki doesn't use global variables. A `lk_State` is also a `lk_Service`, and a
`lk_Service` is also a `lk_Slot`. To get the name of a slot, just cast it to
`const char*`.
`loki` only have one header as it's core. To define `loki` functions (only
allow in only **one** C file), define `LOKI_IMPLEMENTATION` before include
`loki.h`. `loki` also has several *built-in* service, that will defined as
`lsvr_*.c` files, each file can singly build as a DLL/so file, or build
together with `lsvr_init.c` file.

A service has a handler to register slots, all slots it's registered are
prefixed the name of the service. Service's name limited to 31 characters, and
the name of slot are limited to 63 character. e.g. If you have a service 'foo'
and it create a slot 'bar', then the slot is named 'foo.bar'.
In `loki`, you must create a `lk_State` to contain all information `loki`
used, `loki` doesn't use global variables. A `lk_State` is also a
`lk_Service`, and a `lk_Service` is also a `lk_Slot`. To get the name of a
slot, just cast it to `const char*`. You can emit signals to slot by
`lk_emit()`, and process them in a function called `lk_SlotHandler`.

You can find a slot by it's name, and send a message to that. That's made by
use API `lk_emit`. After that slot process this message, it may return a
response message to you, defaultly this response will directly send to your
service. (remember your service is also a slot?)
A service must have a function named `lk_ServiceHandler` to register slots.
All slots it registered are prefixed the name of the service. Service's name
limited to 31 characters, and the name of slot are limited to 63 character.

Loki is a simple library that offer these message passing service. It can used
e.g. If you have a service 'foo' and it create a slot 'bar', then the slot is
named 'foo.bar'.

You can find a slot/service by it's name, and send a message to that.After
slot process the message, it may return a response message to you by default.
This response will directly send to your service. (remember your service is
also a slot?)

loki is that simple library offer these message passing service. It can used
on Windows or POSIX systems. It can load DLL/so to get new services. If you
have a `foo.dll` on Windows, you should only define a entry function named
`loki_service_foo`, then Loki can load it and offer new service.
`loki_service_foo`, then loki can load it and offer new service.

Loki is a multi-thread library, but every single service's handler are running
in sequence just like single thread programs. You needn't use lock in a single
service, and use message to communicate with other service.
loki uses multi-thread, but every single service's handler are running in
order, just like other single thread programs. You needn't use locks in a
single service, you can use message to communicate with other service to avoid
the use of locks.

Loki may offer such built-in service:
loki offers such built-in service:
- timer: register timer to callback after several times.
- task: to run a long-time task in other thread, or run a poll thread
backward.
- socket: offer network ability. Implemented my other library
[znet](https://github.com/starwing/znet).
- harbor: multi-process loki server support.
- harbor: multi-process `loki` server support.
- logger: logger whatever you want.
- monitor: to get internal informations about loki services.
- monitor: to get internal informations about `loki` services.


PLAN
----

Loki's core library is completed, the built-in services are work-in-progress.
Loki's core library is completed.
The built-in services are work-in-progress.


License
Expand Down
7 changes: 0 additions & 7 deletions README.txt

This file was deleted.

0 comments on commit 7656dca

Please sign in to comment.