File: client.go

package info (click to toggle)
golang-github-francoispqt-gojay 1.2.13-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,456 kB
  • sloc: makefile: 86
file content (27 lines) | stat: -rw-r--r-- 412 bytes parent folder | download
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
package client

import (
	"github.com/francoispqt/gojay/examples/websocket/comm"
	"golang.org/x/net/websocket"
)

type client struct {
	comm.SenderReceiver
	id int
}

func NewClient(id int) *client {
	c := new(client)
	c.id = id
	return c
}

func (c *client) Dial(url, origin string) error {
	conn, err := websocket.Dial(url, "", origin)
	if err != nil {
		return err
	}
	c.Conn = conn
	c.Init(10)
	return nil
}