0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

build sender

This commit is contained in:
Zack Scholl 2019-04-08 09:49:34 -07:00
parent 6999b292c0
commit db7cd4194c
4 changed files with 26 additions and 2 deletions

1
go.mod
View file

@ -14,4 +14,5 @@ require (
github.com/stretchr/testify v1.3.0 github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5 golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect
gopkg.in/urfave/cli.v1 v1.20.0
) )

3
go.sum
View file

@ -39,6 +39,7 @@ github.com/pion/ice v0.2.1/go.mod h1:igvbO76UeYthbSu0UsUTqjyWpFT3diUmM+x2vt4p4fw
github.com/pion/logging v0.2.1-0.20190404202522-3c79a8accd0a/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/logging v0.2.1-0.20190404202522-3c79a8accd0a/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/logging v0.2.1 h1:LwASkBKZ+2ysGJ+jLv1E/9H1ge0k1nTfi1X+5zirkDk= github.com/pion/logging v0.2.1 h1:LwASkBKZ+2ysGJ+jLv1E/9H1ge0k1nTfi1X+5zirkDk=
github.com/pion/logging v0.2.1/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/logging v0.2.1/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/quic v0.1.1 h1:D951FV+TOqI9A0rTF7tHx0Loooqz+nyzjEyj8o3PuMA=
github.com/pion/quic v0.1.1/go.mod h1:zEU51v7ru8Mp4AUBJvj6psrSth5eEFNnVQK5K48oV3k= github.com/pion/quic v0.1.1/go.mod h1:zEU51v7ru8Mp4AUBJvj6psrSth5eEFNnVQK5K48oV3k=
github.com/pion/rtcp v1.1.5 h1:UO4u+U3IYVzA1tWCNrR+hUo02tpOrn4elwZ9pQzBVKo= github.com/pion/rtcp v1.1.5 h1:UO4u+U3IYVzA1tWCNrR+hUo02tpOrn4elwZ9pQzBVKo=
github.com/pion/rtcp v1.1.5/go.mod h1:a5dj2d6BKIKHl43EnAOIrCczcjESrtPuMgfmL6/K6QM= github.com/pion/rtcp v1.1.5/go.mod h1:a5dj2d6BKIKHl43EnAOIrCczcjESrtPuMgfmL6/K6QM=
@ -139,5 +140,7 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View file

@ -85,3 +85,9 @@ func (s *Session) CreateOffer() (string, error) {
func (s *Session) SetSDP(sdp string) error { func (s *Session) SetSDP(sdp string) error {
return s.sess.SetSDP(sdp) return s.sess.SetSDP(sdp)
} }
func (s *Session) TransferFile() {
go s.readFile()
<-s.sess.Done
s.sess.OnCompletion()
}

View file

@ -18,6 +18,7 @@ import (
"github.com/go-redis/redis" "github.com/go-redis/redis"
"github.com/mattn/go-colorable" "github.com/mattn/go-colorable"
"github.com/pions/webrtc" "github.com/pions/webrtc"
common "github.com/schollz/croc/v5/pkg/session/common"
recvSess "github.com/schollz/croc/v5/pkg/session/receiver" recvSess "github.com/schollz/croc/v5/pkg/session/receiver"
sendSess "github.com/schollz/croc/v5/pkg/session/sender" sendSess "github.com/schollz/croc/v5/pkg/session/sender"
"github.com/schollz/croc/v5/src/utils" "github.com/schollz/croc/v5/src/utils"
@ -60,8 +61,8 @@ type Client struct {
CurrentFile *os.File CurrentFile *os.File
CurrentFileChunks []int64 CurrentFileChunks []int64
sendSess sendSess.Session sendSess *sendSess.Session
recvSess recvSess.Session recvSess *recvSess.Session
// channel data // channel data
incomingMessageChannel <-chan *redis.Message incomingMessageChannel <-chan *redis.Message
@ -557,6 +558,19 @@ func (c *Client) dataChannelReceive(num int) (err error) {
} }
func (c *Client) dataChannelSend(num int) (err error) { func (c *Client) dataChannelSend(num int) (err error) {
pathToFile := path.Join(c.FilesToTransfer[c.FilesToTransferCurrentNum].FolderSource, c.FilesToTransfer[c.FilesToTransferCurrentNum].Name)
c.CurrentFile, err = os.Open(pathToFile)
if err != nil {
return
}
c.sendSess = sendSess.NewWith(sendSess.Config{
Stream: c.CurrentFile,
Configuration: common.Configuration{
OnCompletion: func() {
},
},
})
if err := c.sendSess.CreateConnection(); err != nil { if err := c.sendSess.CreateConnection(); err != nil {
log.Error(err) log.Error(err)
return err return err