aboutsummaryrefslogtreecommitdiff
path: root/cast/standalone_receiver/cast_socket_message_port.h
blob: 67d037e96b6b3e0d6c7ef4286fd5dbdcc3084492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CAST_STANDALONE_RECEIVER_CAST_SOCKET_MESSAGE_PORT_H_
#define CAST_STANDALONE_RECEIVER_CAST_SOCKET_MESSAGE_PORT_H_

#include <memory>
#include <string>
#include <vector>

#include "cast/common/public/cast_socket.h"
#include "cast/streaming/receiver_session.h"
#include "util/weak_ptr.h"

namespace openscreen {
namespace cast {

class CastSocketMessagePort : public MessagePort {
 public:
  CastSocketMessagePort();
  ~CastSocketMessagePort() override;

  void SetSocket(WeakPtr<CastSocket> socket);

  // Returns current socket identifier, or -1 if not connected.
  int GetSocketId();

  // MessagePort overrides.
  void SetClient(MessagePort::Client* client) override;
  void PostMessage(absl::string_view sender_id,
                   absl::string_view message_namespace,
                   absl::string_view message) override;

 private:
  MessagePort::Client* client_ = nullptr;
  WeakPtr<CastSocket> socket_;
};

}  // namespace cast
}  // namespace openscreen

#endif  // CAST_STANDALONE_RECEIVER_CAST_SOCKET_MESSAGE_PORT_H_