xref: /aosp_15_r20/external/openscreen/osp/go/client.go (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
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(jophba):
8// - Read messages as well, and more than one
9
10import (
11	"context"
12)
13
14func SendMessageAsClient(ctx context.Context, hostname string, port int, msg interface{}) error {
15	session, err := DialAsQuicClient(ctx, hostname, port)
16	if err != nil {
17		return err
18	}
19	stream, err := session.OpenStreamSync()
20	if err != nil {
21		return err
22	}
23	return WriteMessage(msg, stream)
24}
25