Skip to content

Commit

Permalink
Lua CP event dispatcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasinsaurralde committed Aug 26, 2016
1 parent dbd4c00 commit 06e62d3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions coprocess_lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ static void LuaInit() {
// TODO: Cache the middlewares.
}
static void LuaReload() {
}
static struct CoProcessMessage* LuaDispatchHook(struct CoProcessMessage* object) {
struct CoProcessMessage* outputObject = malloc(sizeof *outputObject);
Expand All @@ -50,6 +53,9 @@ static struct CoProcessMessage* LuaDispatchHook(struct CoProcessMessage* object)
return outputObject;
}
static void LuaDispatchEvent(char* event_json) {
}
*/
import "C"

Expand Down Expand Up @@ -82,6 +88,18 @@ func (d *LuaDispatcher) Dispatch(objectPtr unsafe.Pointer) unsafe.Pointer {
return unsafe.Pointer(newObjectPtr)
}

func (d *LuaDispatcher) Reload() {
C.LuaReload()
}

func (d *LuaDispatcher) DispatchEvent(eventJSON []byte) {
var CEventJSON *C.char
CEventJSON = C.CString(string(eventJSON))
C.LuaDispatchEvent(CEventJSON)
C.free(unsafe.Pointer(CEventJSON))
return
}

func LuaInit() {
C.LuaInit()
}
Expand Down

0 comments on commit 06e62d3

Please sign in to comment.