Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package busybus
- import (
- "bufio"
- "net"
- )
- type Client struct {
- counter integer
- conn net.Conn
- bufin *bufio.Reader
- bufout *bufio.Writer
- messages chan string
- state string
- }
- func NewClient(conn net.Conn, messages chan string) *Client {
- return &Client{
- counter: 0,
- conn: conn,
- bufin: bufio.NewReader(conn),
- bufout: bufio.NewWriter(conn),
- messages: messages,
- state: "waiting",
- }
- }
- package busybus
- import (
- "net"
- "testing"
- )
- func TestNewClient(t *testing.T) {
- ln, _ := net.Listen("tcp", ":65535")
- conn, _ := ln.Accept()
- messages := make(chan string)
- client := NewClient(conn, messages)
- if client.conn != conn {
- t.Errorf("NewClient(%q, %q).conn == %q, want %q", conn, messages, client.conn, conn)
- }
- }
- client.buf = bufio.NewReadWriter(...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement