Giter Site home page Giter Site logo

loki's Introduction

loki - one-header online game framework

loki is a online game framework, inspired by cloudwu's skynet.

To start, see the header file loki.h. loki now doesn't have documentations for now, but I will finish that after complete the built-in service.

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.

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.

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.

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.

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 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 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.
  • harbor: multi-process loki server support.
  • logger: logger whatever you want.
  • monitor: to get internal informations about loki services.

PLAN

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

License

Loki use MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.