Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
)

var clientIP net.Addr
// Client holds info about connection
type Client struct {
conn net.Conn
Expand Down Expand Up @@ -75,6 +76,10 @@ func (s *server) OnNewMessage(callback func(c *Client, message string)) {
s.onNewMessage = callback
}

func (s *server) GetClientIP() (net.Addr) {
return clientIP
}

// Listen starts network server
func (s *server) Listen() {
var listener net.Listener
Expand All @@ -95,6 +100,7 @@ func (s *server) Listen() {
conn: conn,
Server: s,
}
clientIP = conn.RemoteAddr()
go client.listen()
}
}
Expand Down