aboutsummaryrefslogtreecommitdiff
path: root/osp/go/client.go
blob: ead684b058dfdb5f9913d5b9da384738172f695f (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
// Copyright 2018 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.

package osp

// TODO(jophba):
// - Read messages as well, and more than one

import (
	"context"
)

func SendMessageAsClient(ctx context.Context, hostname string, port int, msg interface{}) error {
	session, err := DialAsQuicClient(ctx, hostname, port)
	if err != nil {
		return err
	}
	stream, err := session.OpenStreamSync()
	if err != nil {
		return err
	}
	return WriteMessage(msg, stream)
}