Skip to content

Commit

Permalink
added sample
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoe123 committed Jan 14, 2022
1 parent 531d0c7 commit a89d2d6
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sample/simple/build/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Test Application",
"description": "This is a test app.",
"packageId": "ela.testapp",
"build": 1,
"version": "0.3.1",
"program": "ela.testapp",
"permissions": null,
"exportService": true,
"activities": null,
"actionListener": null,
"location": "system",
"nodejs": false,
"packagerVersion": "0.1.0",
"ext": null
}
6 changes: 6 additions & 0 deletions sample/simple/build/packager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cwd": "",
"config": "info.json",
"binDir": "./bin",
"bin": ""
}
15 changes: 15 additions & 0 deletions sample/simple/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import "github.com/cansulting/elabox-system-tools/foundation/app"

var controller *app.Controller

func main() {
var err error
controller, err = app.NewController(&MyActivity{}, &MyService{})
if err != nil {
panic(err)
}

app.RunApp(controller)
}
19 changes: 19 additions & 0 deletions sample/simple/myActivity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import "github.com/cansulting/elabox-system-tools/foundation/event/data"

type MyActivity struct {
}

func (instance *MyActivity) IsRunning() bool {
return true
}

func (instance *MyActivity) OnStart(action *data.Action) error {

return nil
}

func (instance *MyActivity) OnEnd() error {
return nil
}
27 changes: 27 additions & 0 deletions sample/simple/myService.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"github.com/cansulting/elabox-system-tools/foundation/event/data"
"github.com/cansulting/elabox-system-tools/foundation/event/protocol"
)

type MyService struct {
}

func (instance *MyService) IsRunning() bool {
return true
}

func (instance *MyService) OnStart() error {
controller.RPC.OnRecieved("testapp.action.GREETINGS", instance.onGreeted)
return nil
}

func (instance *MyService) OnEnd() error {
return nil

}

func (instance *MyService) onGreeted(client protocol.ClientInterface, action data.Action) string {
return "hello"
}

0 comments on commit a89d2d6

Please sign in to comment.