Skip to content

Commit

Permalink
Removed curl / gfile sdp commands
Browse files Browse the repository at this point in the history
- Now able to paste SDP
  • Loading branch information
Antonito committed Mar 11, 2019
1 parent 4361c41 commit 0e5ea54
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 67 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ As of today, it works well with small files. It doesn't work with huge files, du
```bash
# Terminal 1
gfile send --file filename

# Terminal 2
echo "$SDP" | gfile sdp
```

- Run the command
- A base64 encoded SDP will appear, send it to the remote client
- Follow the instructions to send the client's SDP to your process
- The file transfer should start

> Due to terms restrictions (ability to treat lines with +1024 characters), the SDP must be sent through the `gfile sdp` command
### Receiver

```bash
Expand Down
2 changes: 0 additions & 2 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"sort"

"github.com/antonito/gfile/cmd/receive"
"github.com/antonito/gfile/cmd/sdp"
"github.com/antonito/gfile/cmd/send"
"gopkg.in/urfave/cli.v1"
)
Expand All @@ -14,7 +13,6 @@ func Install(app *cli.App) {
app.Commands = []cli.Command{
send.New(),
receive.New(),
sdp.New(),
}
sort.Sort(cli.CommandsByName(app.Commands))
}
52 changes: 0 additions & 52 deletions cmd/sdp/cmd.go

This file was deleted.

19 changes: 11 additions & 8 deletions cmd/send/session/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ func (s *Session) Connect() error {
return err
}

sdpChan := utils.HTTPSDPServer()

if err := s.createOffer(); err != nil {
return err
}

// Wait for the answer to be pasted
fmt.Println(`Please, provide the SDP via:
echo "$SDP" | gfile sdp`)
fmt.Println(`Please, paste the remote SDP`)
answer := webrtc.SessionDescription{}
for {
if err := utils.Decode(<-sdpChan, &answer); err == nil {
val, err := utils.MustReadStream(s.sdpInput)
if err != nil {
fmt.Printf("Error reading SDP: %v\n", err)
continue
}
if err := utils.Decode(val, &answer); err == nil {
break
}
fmt.Println("Invalid SDP, try aagain...")
Expand Down Expand Up @@ -85,9 +87,10 @@ func (s *Session) createOffer() error {
}

func (s *Session) createDataChannel() error {
//ordered := true
//maxPacketLifeTime := uint16(0xFFFF)
dataChannel, err := s.peerConnection.CreateDataChannel("data", nil)
maxPacketLifeTime := uint16(5000)
dataChannel, err := s.peerConnection.CreateDataChannel("data", &webrtc.DataChannelInit{
MaxPacketLifeTime: &maxPacketLifeTime,
})
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/send/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type outputMsg struct {
// Session contains informations about a Send Session
type Session struct {
stream io.Reader
sdpInput io.Reader
sdpOutput io.Writer
peerConnection *webrtc.PeerConnection
dataChannel *webrtc.DataChannel
Expand All @@ -46,6 +47,7 @@ type Session struct {
func NewSession(f io.Reader) *Session {
return &Session{
stream: f,
sdpInput: os.Stdin,
sdpOutput: os.Stdout,
dataBuff: make([]byte, buffSize),
done: make(chan struct{}),
Expand Down

0 comments on commit 0e5ea54

Please sign in to comment.