forked from gocircuit/circuit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn.go
48 lines (39 loc) · 876 Bytes
/
conn.go
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
44
45
46
47
48
// Copyright 2013 The Go Circuit Project
// Use of this source code is governed by the license for
// The Go Circuit Project, found in the LICENSE file.
//
// Authors:
// 2013 Petar Maymounkov <p@gocircuit.org>
package tele
import (
"github.com/hoijui/circuit/pkg/kit/tele/blend"
"github.com/hoijui/circuit/pkg/use/n"
)
type Conn struct {
addr *Addr
sub *blend.Conn
}
func NewConn(sub *blend.Conn, addr *Addr) *Conn {
return &Conn{addr: addr, sub: sub}
}
func (c *Conn) Read() (v interface{}, err error) {
if v, err = c.sub.Read(); err != nil {
return nil, err
}
return
}
func (c *Conn) Write(v interface{}) (err error) {
if err = c.sub.Write(v); err != nil {
return err
}
return nil
}
func (c *Conn) Close() error {
return c.sub.Close()
}
func (c *Conn) Abort(reason error) {
c.sub.Abort(reason)
}
func (c *Conn) Addr() n.Addr {
return c.addr
}