|
|
|
@ -29,9 +29,19 @@ func GetPort() (int, error) {
|
|
|
|
|
return system.GetPort()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewReactorListener(ch chan error) *ReactorListener {
|
|
|
|
|
func NewReactorListener(ifconfig string,ch chan error) (*ReactorListener, error) {
|
|
|
|
|
m := make(map[uint32]*ReactorManager)
|
|
|
|
|
return &ReactorListener{Err:ch, Reactor:m}
|
|
|
|
|
var ip string
|
|
|
|
|
var port int
|
|
|
|
|
var err error
|
|
|
|
|
if ip, err = GetIp(ifconfig); err != nil {
|
|
|
|
|
return &ReactorListener{}, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if port, err = GetPort(); err != nil {
|
|
|
|
|
return &ReactorListener{}, err
|
|
|
|
|
}
|
|
|
|
|
return &ReactorListener{Ip:ip,Port:port,Err:ch, Reactor:m}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ReactorListener) GetIp() string {
|
|
|
|
@ -48,18 +58,6 @@ func (r *ReactorListener) GetPort() int {
|
|
|
|
|
|
|
|
|
|
func (r *ReactorListener) Start() {
|
|
|
|
|
// start grpc server and implement reciever
|
|
|
|
|
if ip, err := GetIp("eth2"); err != nil {
|
|
|
|
|
r.Err <-err
|
|
|
|
|
} else {
|
|
|
|
|
r.Ip = ip
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if port, err := GetPort(); err != nil {
|
|
|
|
|
r.Err <-err
|
|
|
|
|
} else {
|
|
|
|
|
r.Port = port
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := r.Register(); err != nil {
|
|
|
|
|
r.Err <- err
|
|
|
|
|
}
|
|
|
|
|