func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup, in <-chan message.Message, inSM <-chan message.Socket) <-chan message.Message {
	ctx, cancelFunc := context.WithCancel(ctx)
	socketOut := make(chan message.Message)
	out := make(chan message.Message)
	wg.Add(1)
	run := func() {
		defer wg.Done()
		defer r.log.Printf("socket runner stopped")
		defer close(out)
		defer cancelFunc()
		for { // BLOCKING
			select {
			case <-ctx.Done():
				return
			case m, ok := <-in:
				if !ok {
					return
				}
				r.handleLobbyMessage(ctx, wg, m)
			case sm, ok := <-inSM:
				if !ok {
					return
				}
				r.handleLobbyModifyRequest(ctx, wg, sm, socketOut, out)
			case m := <-socketOut:
				r.handleSocketMessage(ctx, m, out)
			}
		}
	}
	go run()
	return out
}
// Run consumes messages from the message channel.  This channel is used to create sockets and send messages from games to them.
// The messages received from sockets are sent on an "out" channel to be read by games.
Run consumes messages from the message channel.  This channel is used to create sockets and send messages from games to them.
The messages received from sockets are sent on an "out" channel to be read by games.
// Run consumes messages from the message channel . This channel is used to create sockets and send messages from games to them . // The messages received from sockets are sent on an " out " channel to be read by games .
func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup, in <-chan message.Message, inSM <-chan message.Socket) <-chan message.Message {
	ctx, cancelFunc := context.WithCancel(ctx)
	socketOut := make(chan message.Message)
	out := make(chan message.Message)
	wg.Add(1)
	run := func() {
		defer wg.Done()
		defer r.log.Printf("socket runner stopped")
		defer close(out)
		defer cancelFunc()
		for { 
			select {
			case <-ctx.Done():
				return
			case m, ok := <-in:
				if !ok {
					return
				}
				r.handleLobbyMessage(ctx, wg, m)
			case sm, ok := <-inSM:
				if !ok {
					return
				}
				r.handleLobbyModifyRequest(ctx, wg, sm, socketOut, out)
			case m := <-socketOut:
				r.handleSocketMessage(ctx, m, out)
			}
		}
	}
	go run()
	return out
}
func ( r * Runner ) Run ( ctx context . Context , wg * sync . WaitGroup , in <- chan message . Message , inSM <- chan message . Socket ) <- chan message . Message { ctx , cancelFunc := context . WithCancel ( ctx ) socketOut := make ( chan message . Message ) out := make ( chan message . Message ) wg . Add ( 1 ) run := func ( ) { defer wg . Done ( ) defer r . log . Printf ( " " ) defer close ( out ) defer cancelFunc ( ) for { select { case <- ctx . Done ( ) : return case m , ok := <- in : if ! ok { return } r . handleLobbyMessage ( ctx , wg , m ) case sm , ok := <- inSM : if ! ok { return } r . handleLobbyModifyRequest ( ctx , wg , sm , socketOut , out ) case m := <- socketOut : r . handleSocketMessage ( ctx , m , out ) } } } go run ( ) return out }
Run consumes messages from the message channel.
Run consumes messages from the message channel .
// BLOCKING