implemented an api call at /client-conns/id/routes/id/peers/id
This commit is contained in:
@ -4,14 +4,16 @@ import "fmt"
|
||||
import "net"
|
||||
import "sync"
|
||||
|
||||
func NewClientPeerConn(r *ClientRoute, c *net.TCPConn, id uint32) *ClientPeerConn {
|
||||
func NewClientPeerConn(r *ClientRoute, c *net.TCPConn, id uint32, pts_raddr string, pts_laddr string) *ClientPeerConn {
|
||||
var cpc ClientPeerConn
|
||||
|
||||
cpc.route = r
|
||||
cpc.conn = c
|
||||
cpc.conn_id = id
|
||||
cpc.pts_raddr = pts_raddr
|
||||
cpc.pts_laddr = pts_laddr
|
||||
cpc.pts_eof.Store(false)
|
||||
cpc.stop_req.Store(false)
|
||||
cpc.server_peer_eof.Store(false)
|
||||
|
||||
return &cpc
|
||||
}
|
||||
@ -43,6 +45,7 @@ fmt.Printf("CONNECTION ESTABLISHED TO PEER... ABOUT TO READ DATA...\n")
|
||||
cpc.route.cts.psc.Send(MakePeerStoppedPacket(cpc.route.id, cpc.conn_id)) // nothing much to do upon failure. no error check here
|
||||
|
||||
cpc.ReqStop()
|
||||
cpc.route.RemoveClientPeerConn(cpc)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -56,7 +59,7 @@ func (cpc *ClientPeerConn) ReqStop() {
|
||||
}
|
||||
|
||||
func (cpc *ClientPeerConn) CloseWrite() {
|
||||
if cpc.server_peer_eof.CompareAndSwap(false, true) {
|
||||
if cpc.pts_eof.CompareAndSwap(false, true) {
|
||||
if cpc.conn != nil {
|
||||
cpc.conn.CloseWrite()
|
||||
}
|
||||
|
Reference in New Issue
Block a user