func (l *Lobby) Run(ctx context.Context, wg *sync.WaitGroup) {
	gameRunnerIn := make(chan message.Message)
	socketRunnerIn := make(chan message.Message)
	socketRunnerOut := l.socketRunner.Run(ctx, wg, socketRunnerIn, l.socketMessages)
	gameRunnerOut := l.gameRunner.Run(ctx, wg, gameRunnerIn)
	wg.Add(1)
	run := func() {
		defer wg.Done()
		defer l.log.Printf("lobby stopped")
		defer close(socketRunnerIn)
		defer close(gameRunnerIn)
		for { // BLOCKING
			select {
			case <-ctx.Done():
				return
			case m, ok := <-socketRunnerOut:
				if !ok {
					return
				}
				l.handleSocketMessage(m, gameRunnerIn, socketRunnerIn)
			case m, ok := <-gameRunnerOut:
				if !ok {
					return
				}
				l.handleGameMessage(m, socketRunnerIn)
			}
		}
	}
	go run()
}
// Run runs the lobby until the context is closed.
Run runs the lobby until the context is closed.
// Run runs the lobby until the context is closed .
func (l *Lobby) Run(ctx context.Context, wg *sync.WaitGroup) {
	gameRunnerIn := make(chan message.Message)
	socketRunnerIn := make(chan message.Message)
	socketRunnerOut := l.socketRunner.Run(ctx, wg, socketRunnerIn, l.socketMessages)
	gameRunnerOut := l.gameRunner.Run(ctx, wg, gameRunnerIn)
	wg.Add(1)
	run := func() {
		defer wg.Done()
		defer l.log.Printf("lobby stopped")
		defer close(socketRunnerIn)
		defer close(gameRunnerIn)
		for { 
			select {
			case <-ctx.Done():
				return
			case m, ok := <-socketRunnerOut:
				if !ok {
					return
				}
				l.handleSocketMessage(m, gameRunnerIn, socketRunnerIn)
			case m, ok := <-gameRunnerOut:
				if !ok {
					return
				}
				l.handleGameMessage(m, socketRunnerIn)
			}
		}
	}
	go run()
}
func ( l * Lobby ) Run ( ctx context . Context , wg * sync . WaitGroup ) { gameRunnerIn := make ( chan message . Message ) socketRunnerIn := make ( chan message . Message ) socketRunnerOut := l . socketRunner . Run ( ctx , wg , socketRunnerIn , l . socketMessages ) gameRunnerOut := l . gameRunner . Run ( ctx , wg , gameRunnerIn ) wg . Add ( 1 ) run := func ( ) { defer wg . Done ( ) defer l . log . Printf ( " " ) defer close ( socketRunnerIn ) defer close ( gameRunnerIn ) for { select { case <- ctx . Done ( ) : return case m , ok := <- socketRunnerOut : if ! ok { return } l . handleSocketMessage ( m , gameRunnerIn , socketRunnerIn ) case m , ok := <- gameRunnerOut : if ! ok { return } l . handleGameMessage ( m , socketRunnerIn ) } } } go run ( ) }
Run runs the lobby until the context is closed.
Run runs the lobby until the context is closed .
// BLOCKING