aboutsummaryrefslogtreecommitdiff
path: root/connect.go
blob: 93bb4e77d3bcdd42ae89205af59e18bb6b834fec (plain) (blame)
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
package main

import (
	"net"

	"github.com/anon55555/mt"
)

func connect(conn net.Conn, name string, cc *clientConn) *serverConn {
	sc := &serverConn{
		Peer:   mt.Connect(conn),
		initCh: make(chan struct{}),
		clt:    cc,
		name:   name,
	}
	sc.log("-->", "connect")
	cc.srv = sc

	go handleSrv(sc)
	return sc
}

func connectContent(conn net.Conn, name, userName string) *contentConn {
	cc := &contentConn{
		Peer:     mt.Connect(conn),
		doneCh:   make(chan struct{}),
		name:     name,
		userName: userName,
	}

	go handleContent(cc)
	return cc
}