• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package osp
6
7// TODO(pthatcher):
8// - Send a response message
9// - Make a nice object API with methods
10// - Make it possible to have a presentation receiver that is a client
11// - Close connection on unknown message types
12
13import (
14	"context"
15	"crypto/tls"
16)
17
18func RunPresentationReceiver(ctx context.Context, mdnsInstanceName string, port int, cert tls.Certificate, presentUrl func(string)) {
19	messages := make(chan interface{})
20	go ReadMessagesAsServer(ctx, mdnsInstanceName, port, cert, messages)
21	for msg := range messages {
22		switch m := msg.(type) {
23		case PresentationStartRequest:
24			presentUrl(m.URL)
25		}
26	}
27}
28