http request대신 직접 호출
This commit is contained in:
@ -78,7 +78,7 @@ type eosRoomParticipants struct {
|
||||
Participants []eosRoomParticipantRequests `json:"participants"`
|
||||
}
|
||||
|
||||
func (gv *eosauth) joinVoiceChat(data joinVoiceChatRequst) map[string]any {
|
||||
func (gv *eosauth) joinVoiceChat(data JoinVoiceChatRequst) map[string]any {
|
||||
// https://dev.epicgames.com/docs/web-api-ref/voice-web-api
|
||||
accessToken := gv.AccessToken
|
||||
if len(accessToken) == 0 {
|
||||
@ -125,7 +125,7 @@ func (gv *eosauth) joinVoiceChat(data joinVoiceChatRequst) map[string]any {
|
||||
return result
|
||||
}
|
||||
|
||||
func (gv *eosauth) leaveVoiceChat(data leaveVoiceChatRequst) {
|
||||
func (gv *eosauth) leaveVoiceChat(data LeaveVoiceChatRequst) {
|
||||
voiceendpoint := fmt.Sprintf("https://api.epicgames.dev/rtc/v1/%s/room/%s/participants/%s", config.EosDeploymentId, data.Gid, data.Mid)
|
||||
accessToken := gv.AccessToken
|
||||
|
||||
|
||||
@ -2,8 +2,6 @@ package voicechat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"net/http"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
||||
@ -11,24 +9,19 @@ import (
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
)
|
||||
|
||||
type joinVoiceChatRequst struct {
|
||||
type JoinVoiceChatRequst struct {
|
||||
Gid string
|
||||
Mid string
|
||||
Service string
|
||||
Alias string
|
||||
}
|
||||
|
||||
type leaveVoiceChatRequst struct {
|
||||
type LeaveVoiceChatRequst struct {
|
||||
Gid string
|
||||
Mid string
|
||||
Service string
|
||||
}
|
||||
|
||||
func init() {
|
||||
gob.Register(joinVoiceChatRequst{})
|
||||
gob.Register(leaveVoiceChatRequst{})
|
||||
}
|
||||
|
||||
type voiceChatConfig struct {
|
||||
EosClientId string `json:"eos_client_id"`
|
||||
EosClientSecret string `json:"eos_client_secret"`
|
||||
@ -36,8 +29,8 @@ type voiceChatConfig struct {
|
||||
}
|
||||
|
||||
type voiceServiceImpl interface {
|
||||
joinVoiceChat(joinVoiceChatRequst) map[string]any
|
||||
leaveVoiceChat(leaveVoiceChatRequst)
|
||||
joinVoiceChat(JoinVoiceChatRequst) map[string]any
|
||||
leaveVoiceChat(LeaveVoiceChatRequst)
|
||||
}
|
||||
|
||||
var config voiceChatConfig
|
||||
@ -74,32 +67,18 @@ func (gv *VoiceChatService) eos() voiceServiceImpl {
|
||||
return (*eosauth)(ptr)
|
||||
}
|
||||
|
||||
func (gv *VoiceChatService) JoinVoiceChat(w http.ResponseWriter, r *http.Request) {
|
||||
var data joinVoiceChatRequst
|
||||
|
||||
if err := gocommon.MakeDecoder(r).Decode(&data); err != nil {
|
||||
logger.Println("JoinVoiceChat failed. DecodeGob returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
switch data.Service {
|
||||
func (gv *VoiceChatService) JoinVoiceChat(req JoinVoiceChatRequst) map[string]any {
|
||||
switch req.Service {
|
||||
case "eos":
|
||||
result := gv.eos().joinVoiceChat(data)
|
||||
gocommon.MakeEncoder(w, r).Encode(result)
|
||||
}
|
||||
return gv.eos().joinVoiceChat(req)
|
||||
}
|
||||
|
||||
func (gv *VoiceChatService) LeaveVoiceChat(w http.ResponseWriter, r *http.Request) {
|
||||
var data leaveVoiceChatRequst
|
||||
if err := gocommon.MakeDecoder(r).Decode(&data); err != nil {
|
||||
logger.Println("JoinVoiceChat failed. DecodeGob returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
switch data.Service {
|
||||
func (gv *VoiceChatService) LeaveVoiceChat(req LeaveVoiceChatRequst) {
|
||||
switch req.Service {
|
||||
case "eos":
|
||||
gv.eos().leaveVoiceChat(data)
|
||||
gv.eos().leaveVoiceChat(req)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user