Skip to content

Commit

Permalink
UserData for a agent
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Jul 6, 2015
1 parent b418216 commit d88e05e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions gate/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ package gate
type Agent interface {
WriteMsg(msg interface{})
Close()
UserData() interface{}
SetUserData(data interface{})
}
13 changes: 11 additions & 2 deletions gate/tcp_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ func (gate *TCPGate) Run(closeSig chan bool) {
func (gate *TCPGate) OnDestroy() {}

type TCPAgent struct {
conn *network.TCPConn
gate *TCPGate
conn *network.TCPConn
gate *TCPGate
userData interface{}
}

func (a *TCPAgent) Run() {
Expand Down Expand Up @@ -124,3 +125,11 @@ func (a *TCPAgent) WriteMsg(msg interface{}) {
func (a *TCPAgent) Close() {
a.conn.Close()
}

func (a *TCPAgent) UserData() interface{} {
return a.userData
}

func (a *TCPAgent) SetUserData(data interface{}) {
a.userData = data
}

0 comments on commit d88e05e

Please sign in to comment.