ServerName is now 1st domain in token. Awaiting new token structure for true ServerName.
This commit is contained in:
parent
f809794f22
commit
41adbfaef5
|
@ -1,9 +1,6 @@
|
|||
package genericlistener
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
import "time"
|
||||
|
||||
//ServerAPI -- Structure to support the server API
|
||||
type ServerAPI struct {
|
||||
|
@ -20,7 +17,7 @@ type ServerAPI struct {
|
|||
//NewServerAPI - Constructor
|
||||
func NewServerAPI(c *Connection) (s *ServerAPI) {
|
||||
s = new(ServerAPI)
|
||||
s.ServerName = fmt.Sprintf("%p", c)
|
||||
s.ServerName = c.ServerName()
|
||||
s.ServerID = c.ConnectionID()
|
||||
s.Domains = make([]*DomainAPI, 0)
|
||||
s.Duration = time.Since(c.ConnectTime()).Seconds()
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package genericlistener
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
import "time"
|
||||
|
||||
//ServersAPI -- Structure to support the server API
|
||||
type ServersAPI struct {
|
||||
|
@ -22,7 +19,7 @@ type ServersAPI struct {
|
|||
//NewServersAPI - Constructor
|
||||
func NewServersAPI(c *Connection) (s *ServersAPI) {
|
||||
s = new(ServersAPI)
|
||||
s.ServerName = fmt.Sprintf("%p", c)
|
||||
s.ServerName = c.ServerName()
|
||||
s.ServerID = c.ConnectionID()
|
||||
s.Domains = make([]*DomainAPI, 0)
|
||||
s.Duration = time.Since(c.ConnectTime()).Seconds()
|
||||
|
|
|
@ -39,6 +39,9 @@ type Connection struct {
|
|||
// Address of the Remote End Point
|
||||
source string
|
||||
|
||||
// serverName -- Name of the server, at this point 1st domain registered. Will likely change with JWT
|
||||
serverName string
|
||||
|
||||
// bytes in
|
||||
bytesIn int64
|
||||
|
||||
|
@ -70,13 +73,15 @@ type Connection struct {
|
|||
}
|
||||
|
||||
//NewConnection -- Constructor
|
||||
func NewConnection(connectionTable *Table, conn *websocket.Conn, remoteAddress string, initialDomains []interface{}, connectionTrack *Tracking) (p *Connection) {
|
||||
func NewConnection(connectionTable *Table, conn *websocket.Conn, remoteAddress string,
|
||||
initialDomains []interface{}, connectionTrack *Tracking, serverName string) (p *Connection) {
|
||||
connectionID = connectionID + 1
|
||||
|
||||
p = new(Connection)
|
||||
p.connectionTable = connectionTable
|
||||
p.conn = conn
|
||||
p.source = remoteAddress
|
||||
p.serverName = serverName
|
||||
p.bytesIn = 0
|
||||
p.bytesOut = 0
|
||||
p.requests = 0
|
||||
|
@ -103,6 +108,16 @@ func (c *Connection) AddTrackedDomain(domain string) {
|
|||
c.DomainTrack[domain] = p
|
||||
}
|
||||
|
||||
//ServerName -- Property
|
||||
func (c *Connection) ServerName() string {
|
||||
return c.serverName
|
||||
}
|
||||
|
||||
//SetServerName -- Setter
|
||||
func (c *Connection) SetServerName(serverName string) {
|
||||
c.serverName = serverName
|
||||
}
|
||||
|
||||
//InitialDomains -- Property
|
||||
func (c *Connection) InitialDomains() []interface{} {
|
||||
return c.initialDomains
|
||||
|
|
|
@ -14,6 +14,9 @@ type Registration struct {
|
|||
// Address of the Remote End Point
|
||||
source string
|
||||
|
||||
// serverName
|
||||
serverName string
|
||||
|
||||
// communications channel between go routines
|
||||
commCh chan bool
|
||||
|
||||
|
@ -24,10 +27,11 @@ type Registration struct {
|
|||
}
|
||||
|
||||
//NewRegistration -- Constructor
|
||||
func NewRegistration(conn *websocket.Conn, remoteAddress string, initialDomains []interface{}, connectionTrack *Tracking) (p *Registration) {
|
||||
func NewRegistration(conn *websocket.Conn, remoteAddress string, initialDomains []interface{}, connectionTrack *Tracking, serverName string) (p *Registration) {
|
||||
p = new(Registration)
|
||||
p.conn = conn
|
||||
p.source = remoteAddress
|
||||
p.serverName = serverName
|
||||
p.commCh = make(chan bool)
|
||||
p.initialDomains = initialDomains
|
||||
p.connectionTrack = connectionTrack
|
||||
|
|
|
@ -103,7 +103,8 @@ func (c *Table) Run(ctx context.Context, defaultMethod string) {
|
|||
case registration := <-c.register:
|
||||
loginfo.Println("register fired")
|
||||
|
||||
connection := NewConnection(c, registration.conn, registration.source, registration.initialDomains, registration.connectionTrack)
|
||||
connection := NewConnection(c, registration.conn, registration.source, registration.initialDomains,
|
||||
registration.connectionTrack, registration.serverName)
|
||||
c.connections[connection] = make([]string, initialDomains)
|
||||
registration.commCh <- true
|
||||
|
||||
|
|
|
@ -382,10 +382,9 @@ func handleWssClient(ctx context.Context, oneConn *oneConnListener) {
|
|||
|
||||
loginfo.Println("before connection table")
|
||||
|
||||
//newConnection := connection.NewConnection(connectionTable, conn, r.RemoteAddr, domains)
|
||||
serverName := domains[0].(string)
|
||||
|
||||
//connectionTrack := ctx.Value(ctxConnectionTrack).(*Tracking)
|
||||
newRegistration := NewRegistration(conn, r.RemoteAddr, domains, serverStatus.ConnectionTracking)
|
||||
newRegistration := NewRegistration(conn, r.RemoteAddr, domains, serverStatus.ConnectionTracking, serverName)
|
||||
serverStatus.WSSConnectionRegister(newRegistration)
|
||||
|
||||
ok = <-newRegistration.CommCh()
|
||||
|
|
Loading…
Reference in New Issue