Skip to content

Commit

Permalink
fix import cycle and go dep update
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoSchw committed Mar 9, 2024
1 parent b39731c commit 12e4c9b
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
go-version: '1.21.x'
- name: Install dependencies
run: go get .
run: go get -u all
- name: Build
run: go build -v ./...
- name: Test with Go
Expand Down
18 changes: 9 additions & 9 deletions internal/lobby/clients/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ import (
"github.com/shigde/sfu/pkg/authentication"
)

type hostApiClient struct {
type ApiClient struct {
instanceId uuid.UUID // not needed?
name string
token string
url *url.URL
bearer string
}

func newHostApiClient(id uuid.UUID, token string, name string, shigUrl *url.URL) *hostApiClient {
return &hostApiClient{
func NewApiClient(id uuid.UUID, token string, name string, shigUrl *url.URL) *ApiClient {
return &ApiClient{
instanceId: id,
name: name,
token: token,
url: shigUrl,
}
}

func (a *hostApiClient) Login() (*authentication.Token, error) {
func (a *ApiClient) Login() (*authentication.Token, error) {
loginUrl := fmt.Sprintf("%s/authenticate", a.url.String())
user := &authentication.User{
UserId: a.name,
Expand Down Expand Up @@ -78,17 +78,17 @@ func (a *hostApiClient) Login() (*authentication.Token, error) {
return &result, nil
}

func (a *hostApiClient) PostHostPipeOffer(spaceId string, streamId string, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
func (a *ApiClient) PostHostPipeOffer(spaceId string, streamId string, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
requestUrl := fmt.Sprintf("%s/space/%s/stream/%s/pipe", a.url.String(), spaceId, streamId)
return a.doOfferRequest(requestUrl, offer)
}

func (a *hostApiClient) PostHostIngressOffer(spaceId string, streamId string, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
func (a *ApiClient) PostHostIngressOffer(spaceId string, streamId string, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
requestUrl := fmt.Sprintf("%s/space/%s/stream/%s/hostingress", a.url.String(), spaceId, streamId)
return a.doOfferRequest(requestUrl, offer)
}

func (a *hostApiClient) doOfferRequest(reqUrl string, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
func (a *ApiClient) doOfferRequest(reqUrl string, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
body := bytes.NewBuffer([]byte(offer.SDP))
c := http.Client{Timeout: time.Duration(1) * time.Second}
req, err := http.NewRequest("POST", reqUrl, body)
Expand Down Expand Up @@ -120,9 +120,9 @@ func (a *hostApiClient) doOfferRequest(reqUrl string, offer *webrtc.SessionDescr
return &webrtc.SessionDescription{SDP: answer, Type: webrtc.SDPTypeAnswer}, nil
}

func (a *hostApiClient) getBearer() string {
func (a *ApiClient) getBearer() string {
return a.bearer
}
func (a *hostApiClient) setBearer(bearer string) {
func (a *ApiClient) setBearer(bearer string) {
a.bearer = bearer
}
Loading

0 comments on commit 12e4c9b

Please sign in to comment.