Implement a new feature, that idtcp server use Instruction to internally parse out the structure instance corresponding to Data.
It better be like this:
type Fruit struct {
name string
price int
}
func receive_fruit(fruit *Fruit) error {
// do something
}
var Endpoints = []func(interface{}) error {
...
recive_fruit,
...
}
// run server
idtcp.NewServer(
...
Endpoints,
...
).Run()
But it's hard, so may be like this:
type Request struct {
Conn *net.TCPConn
Payloads []interface{}
}
type IReceive interface {
Receive(*Request)
}
type Apple struct {
Color string
Sweet bool
}
type Banana struct {
Thickness int
Length int
}
func (apple *Apple) Receive(req *Request) {
fmt.Println(apple)
}
func (banana *Banana) Receive(req *Request) {
fmt.Println(banana)
}
var Endpoints = []IReceive{
&Apple{},
&Banana{},
}
Implement a new feature, that idtcp server use
Instructionto internally parse out the structure instance corresponding toData.It better be like this:
But it's hard, so may be like this: