Add eventUpstreamConnected

This is used in the next commit.
This commit is contained in:
Simon Ser 2020-04-01 12:05:25 +02:00
parent 977a1b294f
commit dd13e1cb62
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -14,6 +14,10 @@ type eventUpstreamMessage struct {
uc *upstreamConn uc *upstreamConn
} }
type eventUpstreamConnected struct {
uc *upstreamConn
}
type eventUpstreamDisconnected struct { type eventUpstreamDisconnected struct {
uc *upstreamConn uc *upstreamConn
} }
@ -75,6 +79,7 @@ func (net *network) run() {
net.conn = uc net.conn = uc
net.lock.Unlock() net.lock.Unlock()
net.user.events <- eventUpstreamConnected{uc}
if err := uc.readMessages(net.user.events); err != nil { if err := uc.readMessages(net.user.events); err != nil {
uc.logger.Printf("failed to handle messages: %v", err) uc.logger.Printf("failed to handle messages: %v", err)
} }
@ -167,6 +172,8 @@ func (u *user) run() {
for e := range u.events { for e := range u.events {
switch e := e.(type) { switch e := e.(type) {
case eventUpstreamConnected:
// Nothing to do
case eventUpstreamDisconnected: case eventUpstreamDisconnected:
uc := e.uc uc := e.uc
for _, log := range uc.logs { for _, log := range uc.logs {