Skip to content

Commit

Permalink
[client] Remove redundant function parameters (fatedier#3016)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiayao authored Jul 14, 2022
1 parent 6f25719 commit 1bc899e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
9 changes: 1 addition & 8 deletions client/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ import (
"github.com/fatedier/frp/pkg/msg"
)

type Type int

const (
EvStartProxy Type = iota
EvCloseProxy
)

var (
ErrPayloadType = errors.New("error payload type")
)

type Handler func(evType Type, payload interface{}) error
type Handler func(payload interface{}) error

type StartProxyPayload struct {
NewProxyMsg *msg.NewProxy
Expand Down
2 changes: 1 addition & 1 deletion client/proxy/proxy_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (pm *Manager) HandleWorkConn(name string, workConn net.Conn, m *msg.StartWo
}
}

func (pm *Manager) HandleEvent(evType event.Type, payload interface{}) error {
func (pm *Manager) HandleEvent(payload interface{}) error {
var m msg.Message
switch e := payload.(type) {
case *event.StartProxyPayload:
Expand Down
4 changes: 2 additions & 2 deletions client/proxy/proxy_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (pw *Wrapper) Stop() {
}

func (pw *Wrapper) close() {
pw.handler(event.EvCloseProxy, &event.CloseProxyPayload{
pw.handler(&event.CloseProxyPayload{
CloseProxyMsg: &msg.CloseProxy{
ProxyName: pw.Name,
},
Expand Down Expand Up @@ -174,7 +174,7 @@ func (pw *Wrapper) checkWorker() {
var newProxyMsg msg.NewProxy
pw.Cfg.MarshalToMsg(&newProxyMsg)
pw.lastSendStartMsg = now
pw.handler(event.EvStartProxy, &event.StartProxyPayload{
pw.handler(&event.StartProxyPayload{
NewProxyMsg: &newProxyMsg,
})
}
Expand Down

0 comments on commit 1bc899e

Please sign in to comment.