object instead of string
This commit is contained in:
parent
29b4881c08
commit
c7a178e5a4
@ -183,7 +183,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
this._ws!.send(JSON.stringify({ event, ...payload }))
|
||||
}
|
||||
|
||||
public createPeer(sdp: string, lite: boolean, servers: string) {
|
||||
public createPeer(sdp: string, lite: boolean, servers: RTCIceServer[]) {
|
||||
this.emit('debug', `creating peer`)
|
||||
if (!this.socketOpen) {
|
||||
this.emit(
|
||||
@ -202,7 +202,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
this._peer = new RTCPeerConnection()
|
||||
if (lite !== true) {
|
||||
this._peer = new RTCPeerConnection({
|
||||
iceServers: JSON.parse(servers),
|
||||
iceServers: servers,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ export interface SignalProvideMessage extends WebSocketMessage, SignalProvidePay
|
||||
export interface SignalProvidePayload {
|
||||
id: string
|
||||
lite: boolean
|
||||
ice: string
|
||||
ice: RTCIceServer[]
|
||||
sdp: string
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,9 @@ func (s *WebRTC) Set() {
|
||||
s.ICELite = viper.GetBool("icelite")
|
||||
s.ICEServers = []webrtc.ICEServer{{URLs: viper.GetStringSlice("iceserver")}}
|
||||
if (viper.GetString("iceservers") != "") {
|
||||
errj := json.Unmarshal([]byte(viper.GetString("iceservers")), &s.ICEServers)
|
||||
if (errj != nil) {
|
||||
panic(errj)
|
||||
err := json.Unmarshal([]byte(viper.GetString("iceservers")), &s.ICEServers)
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
s.NAT1To1IPs = viper.GetStringSlice("nat1to1")
|
||||
|
@ -2,6 +2,8 @@ package message
|
||||
|
||||
import (
|
||||
"n.eko.moe/neko/internal/types"
|
||||
|
||||
"github.com/pion/webrtc/v3"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
@ -18,7 +20,7 @@ type SignalProvide struct {
|
||||
ID string `json:"id"`
|
||||
SDP string `json:"sdp"`
|
||||
Lite bool `json:"lite"`
|
||||
ICE string `json:"ice"`
|
||||
ICE []webrtc.ICEServer `json:"ice"`
|
||||
}
|
||||
|
||||
type SignalAnswer struct {
|
||||
|
@ -1,8 +1,6 @@
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"n.eko.moe/neko/internal/types"
|
||||
"n.eko.moe/neko/internal/types/event"
|
||||
"n.eko.moe/neko/internal/types/message"
|
||||
@ -14,17 +12,12 @@ func (h *MessageHandler) signalProvide(id string, session types.Session) error {
|
||||
return err
|
||||
}
|
||||
|
||||
tmp, err := json.Marshal(ice)
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := session.Send(message.SignalProvide{
|
||||
Event: event.SIGNAL_PROVIDE,
|
||||
ID: id,
|
||||
SDP: sdp,
|
||||
Lite: lite,
|
||||
ICE: string(tmp),
|
||||
ICE: ice,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user