From 5838515b9a4136b1287236bb83e8c4a9625bfc38 Mon Sep 17 00:00:00 2001 From: zhengshilong <1725838433@qq.com> Date: Wed, 30 Jul 2025 18:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=80=9A=E8=AF=9D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- livekitManage/biz/dal/init.go | 1 + livekitManage/biz/dal/livekit/init.go | 32 +- .../biz/dal/redis/audio_call_processor.go | 43 +- .../biz/dal/redis/video_call_processor.go | 128 + .../audioAndVideoCalls/audio_call_service.go | 4 +- .../audioAndVideoCalls/room_service.go | 51 + .../audioAndVideoCalls/video_call_service.go | 32 + .../audioAndVideoCalls/audioAndVideoCalls.go | 2147 ++++++++++++++++- .../audioAndVideoCalls/audioAndVideoCalls.go | 5 +- .../router/audioAndVideoCalls/middleware.go | 25 + livekitManage/biz/utils/utils.go | 22 + livekitManage/idl/audioAndVideoCalls.thrift | 39 +- livekitManage/protocol/message.go | 13 + .../biz/handler/wsCenter/wsCenter_server.go | 2 + pushNotificationCenter/protocol/message.go | 13 + 15 files changed, 2493 insertions(+), 64 deletions(-) create mode 100644 livekitManage/biz/dal/redis/video_call_processor.go create mode 100644 livekitManage/biz/handler/audioAndVideoCalls/room_service.go create mode 100644 livekitManage/biz/handler/audioAndVideoCalls/video_call_service.go diff --git a/livekitManage/biz/dal/init.go b/livekitManage/biz/dal/init.go index 4c12494..f4bced1 100644 --- a/livekitManage/biz/dal/init.go +++ b/livekitManage/biz/dal/init.go @@ -8,5 +8,6 @@ import ( func Init() { redis.InitRedis() go redis.AudioCallProcessorInit() + go redis.VideoCallProcessorInit() go mysql.Init() } diff --git a/livekitManage/biz/dal/livekit/init.go b/livekitManage/biz/dal/livekit/init.go index 1b91e43..b00f90a 100644 --- a/livekitManage/biz/dal/livekit/init.go +++ b/livekitManage/biz/dal/livekit/init.go @@ -109,14 +109,36 @@ func (c *RoomClient) CreateAudioRoom() (*livekit.Room, error) { return room, nil } +// CreateVideoRoom 创建视频房间 +func (c *RoomClient) CreateVideoRoom() (*livekit.Room, error) { + hlog.Infof("start CreateVideoRoom") + creatReq := &livekit.CreateRoomRequest{ + Name: utils.GenerateUniqueVideoRoomName(), + EmptyTimeout: 60, + MaxParticipants: 2, + MinPlayoutDelay: 0, + MaxPlayoutDelay: 0, + SyncStreams: false, + } + + room, err := c.client.CreateRoom(context.Background(), creatReq) + if err != nil { + return nil, fmt.Errorf("创建房间失败: %w", err) + } + hlog.Info("create room:", room) + return room, nil +} + // ListRooms 列出房间 -func (c *RoomClient) ListRooms(req *livekit.ListRoomsRequest) (*livekit.ListRoomsResponse, error) { +func (c *RoomClient) ListRooms() (*livekit.ListRoomsResponse, error) { if !c.isInit { if err := c.Init(); err != nil { return nil, err } } - + req := &livekit.ListRoomsRequest{ + Names: nil, + } resp, err := c.client.ListRooms(context.Background(), req) if err != nil { return nil, fmt.Errorf("列出房间失败: %w", err) @@ -158,7 +180,7 @@ func (c *RoomClient) GetJoinToken(roomName, userId, userName string) string { } // 用户名可为空,使用默认值 if userName == "" { - userName = "user_" + userId[:6] // 取用户ID前6位作为默认名 + userName = userId // 取用户ID } // 2. 初始化访问令牌 @@ -175,8 +197,8 @@ func (c *RoomClient) GetJoinToken(roomName, userId, userName string) string { Room: roomName, // 绑定具体房间(限制只能加入该房间) CanUpdateOwnMetadata: &metaOpen, // 允许更新自己的元数据(如昵称、头像) // 可根据业务需求添加更多权限,如: - // CanPublish: true, // 允许发布媒体流 - // CanSubscribe: true, // 允许订阅媒体流 + CanPublish: &metaOpen, // 允许发布媒体流 + CanSubscribe: &metaOpen, // 允许订阅媒体流 } // 4. 设置令牌属性 diff --git a/livekitManage/biz/dal/redis/audio_call_processor.go b/livekitManage/biz/dal/redis/audio_call_processor.go index 4a8ac8b..61a6a10 100644 --- a/livekitManage/biz/dal/redis/audio_call_processor.go +++ b/livekitManage/biz/dal/redis/audio_call_processor.go @@ -15,6 +15,7 @@ import ( "time" ) +// AudioCallProcessorInit 音频通话消息监听器 func AudioCallProcessorInit() { // 订阅所有音频通话消息通道 pubsub := rdb.PSubscribe(ctx, "audioCall*") @@ -22,11 +23,12 @@ func AudioCallProcessorInit() { ch := pubsub.Channel() for msg := range ch { - go handleRedisMessage(msg.Channel, []byte(msg.Payload)) + go audioHandleRedisMessage(msg.Channel, []byte(msg.Payload)) } } -func handleRedisMessage(channel string, payload []byte) { +// 音频消息解析器 +func audioHandleRedisMessage(channel string, payload []byte) { // 解析消息类型和目标 parts := strings.Split(channel, ":") @@ -44,10 +46,10 @@ func handleRedisMessage(channel string, payload []byte) { return } //handleGroupMessage(target, msg) - go HandleUserMessage(target, msg) + go audioHandleUserMessage(target, msg) } -func handleGroupMessage(groupID string, msg protocol.Message) { +func audioHandleGroupMessage(groupID string, msg protocol.Message) { hlog.Infof("处理音频通话消息: %s -> 群组 %s", msg.From, groupID) // 查询群组成员 @@ -64,7 +66,7 @@ func handleGroupMessage(groupID string, msg protocol.Message) { } } -func HandleUserMessage(groupID string, msg protocol.Message) { +func audioHandleUserMessage(groupID string, msg protocol.Message) { hlog.Infof("处理音频通话消息: %s -> user: %s", msg.From, groupID) if msg.Content != protocol.AudioCallAgree { @@ -80,7 +82,7 @@ func HandleUserMessage(groupID string, msg protocol.Message) { } fromUserToken := client.GetJoinToken(room.Name, msg.From, "") toUserTokem := client.GetJoinToken(room.Name, msg.To, "") - hlog.Infof("获取访问密钥成功 -> fromUserToken:%s toUserTokem:%s", fromUserToken, toUserTokem) + hlog.Infof("获取访问密钥成功 -> fromUserToken:%s \n toUserTokem:%s", fromUserToken, toUserTokem) server := fmt.Sprintf("%s:%s", config.LivekitHost, config.LivekitPort) expand_from := protocol.AudioCallMessage{ Room: room.Name, @@ -178,3 +180,32 @@ func AudioCall(req audioAndVideoCalls.AudioCallReq) error { PublishToRedis(protocol.TypePrivate+":"+req.TargetUserID, msgBytes) return nil } + +// VideoCall 发起通话申请 +func VideoCall(req audioAndVideoCalls.VideoCallReq) error { + if req.UserID == "" { + return errors.New("invalid user id") + } + if req.TargetUserID == "" { + return errors.New("invalid target user id") + } + + msg := protocol.Message{ + Type: protocol.TypeVideoCall, + FileType: "", + From: req.UserID, + To: req.TargetUserID, + Content: "Video Call", + MsgID: "", + SendTime: time.Now().Format("2006-01-02 15:04:05"), + Expand: nil, + } + // 序列化消息 + msgBytes, err := json.Marshal(msg) + if err != nil { + hlog.Errorf("消息序列化错误: %v", err) + return err + } + PublishToRedis(protocol.TypePrivate+":"+req.TargetUserID, msgBytes) + return nil +} diff --git a/livekitManage/biz/dal/redis/video_call_processor.go b/livekitManage/biz/dal/redis/video_call_processor.go new file mode 100644 index 0000000..016dcc1 --- /dev/null +++ b/livekitManage/biz/dal/redis/video_call_processor.go @@ -0,0 +1,128 @@ +package redis + +import ( + "audioAndVideoCalls/biz/dal/livekit" + audioAndVideoCalls "audioAndVideoCalls/biz/model/audioAndVideoCalls" + "audioAndVideoCalls/config" + "audioAndVideoCalls/protocol" + "encoding/json" + "fmt" + "github.com/cloudwego/hertz/pkg/common/hlog" + lsdk "github.com/livekit/protocol/livekit" + "log" + "strings" + "time" +) + +// VideoCallProcessorInit 视频通话消息监听器 +func VideoCallProcessorInit() { + // 订阅所有音频通话消息通道 + pubsub := rdb.PSubscribe(ctx, "videoCall*") + defer pubsub.Close() + + ch := pubsub.Channel() + for msg := range ch { + go videoHandleRedisMessage(msg.Channel, []byte(msg.Payload)) + } +} + +// 音频消息解析器 +func videoHandleRedisMessage(channel string, payload []byte) { + + // 解析消息类型和目标 + parts := strings.Split(channel, ":") + if len(parts) < 2 { + log.Printf("无效的通道格式: %s", channel) + return + } + + target := parts[1] + + // 解析消息内容 + var msg protocol.Message + if err := json.Unmarshal(payload, &msg); err != nil { + hlog.Errorf("消息解析错误: %v", err) + return + } + go videoHandleUserMessage(target, msg) +} + +func videoHandleUserMessage(groupID string, msg protocol.Message) { + hlog.Infof("处理视频通话消息: %s -> user: %s", msg.From, groupID) + + if msg.Content != protocol.VideoCallAgree { + return + } + // 向每个参与者员发送房间和权限消息 + client := livekit.GetGlobalRoomClient() + + room, err := client.CreateVideoRoom() + if err != nil { + hlog.Errorf("创建视频房间失败: %v", err) + return + } + fromUserToken := client.GetJoinToken(room.Name, msg.From, "") + toUserTokem := client.GetJoinToken(room.Name, msg.To, "") + hlog.Infof("获取访问密钥成功 -> fromUserToken:%s \n toUserTokem:%s", fromUserToken, toUserTokem) + server := fmt.Sprintf("%s:%s", config.LivekitHost, config.LivekitPort) + expand_from := protocol.AudioCallMessage{ + Room: room.Name, + Token: fromUserToken, + Server: server, + } + expand_from_marshal, err := json.Marshal(expand_from) + if err != nil { + hlog.Errorf("序列化 expand_from 失败: %v", err) + return + } + expand_to := protocol.AudioCallMessage{ + Room: room.Name, + Token: toUserTokem, + Server: server, + } + expand_to_marshal, err := json.Marshal(expand_to) + if err != nil { + hlog.Errorf("序列化 expand_from 失败: %v", err) + return + } + msg_from := protocol.Message{ + Type: protocol.TypeVideoCall, + FileType: "", + From: "sys", + To: msg.From, + Content: "", + MsgID: "", + SendTime: time.Now().Format("2006-01-02 15:04:05"), + Expand: expand_from_marshal, + } + msg_to := protocol.Message{ + Type: protocol.TypeVideoCall, + FileType: "", + From: "sys", + To: msg.To, + Content: "", + MsgID: "", + SendTime: time.Now().Format("2006-01-02 15:04:05"), + Expand: expand_to_marshal, + } + go forwardToUser(msg.From, msg_from) + go forwardToUser(msg.To, msg_to) +} + +func RoomList() (*lsdk.ListRoomsResponse, error) { + client := livekit.GetGlobalRoomClient() + data, err := client.ListRooms() + if err != nil { + return nil, err + } + return data, nil +} + +func RoomRemove(req audioAndVideoCalls.RemoveRoomReq) error { + client := livekit.GetGlobalRoomClient() + err := client.DeleteRoom(req.RoomID) + if err != nil { + return err + } + return nil +} diff --git a/livekitManage/biz/handler/audioAndVideoCalls/audio_call_service.go b/livekitManage/biz/handler/audioAndVideoCalls/audio_call_service.go index a8fbb43..f1c4e41 100644 --- a/livekitManage/biz/handler/audioAndVideoCalls/audio_call_service.go +++ b/livekitManage/biz/handler/audioAndVideoCalls/audio_call_service.go @@ -10,9 +10,9 @@ import ( "github.com/cloudwego/hertz/pkg/protocol/consts" ) -// Call . +// AudioCall . // @router /audioCall [POST] -func Call(ctx context.Context, c *app.RequestContext) { +func AudioCall(ctx context.Context, c *app.RequestContext) { var err error var req audioAndVideoCalls.AudioCallReq err = c.BindAndValidate(&req) diff --git a/livekitManage/biz/handler/audioAndVideoCalls/room_service.go b/livekitManage/biz/handler/audioAndVideoCalls/room_service.go new file mode 100644 index 0000000..aaa5f0b --- /dev/null +++ b/livekitManage/biz/handler/audioAndVideoCalls/room_service.go @@ -0,0 +1,51 @@ +// Code generated by hertz generator. + +package audioAndVideoCalls + +import ( + "audioAndVideoCalls/biz/dal/redis" + audioAndVideoCalls "audioAndVideoCalls/biz/model/audioAndVideoCalls" + "context" + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// RoomList . +// @router /roomlist [GET] +func RoomList(ctx context.Context, c *app.RequestContext) { + var err error + var req audioAndVideoCalls.RoomListReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + data, err := redis.RoomList() + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + c.JSON(consts.StatusOK, data) +} + +// RoomRemove . +// @router /room [DELETE] +func RoomRemove(ctx context.Context, c *app.RequestContext) { + var err error + var req audioAndVideoCalls.RemoveRoomReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + err = redis.RoomRemove(req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + resp := new(audioAndVideoCalls.RemoveRoomResp) + + c.JSON(consts.StatusOK, resp) +} diff --git a/livekitManage/biz/handler/audioAndVideoCalls/video_call_service.go b/livekitManage/biz/handler/audioAndVideoCalls/video_call_service.go new file mode 100644 index 0000000..2dc8360 --- /dev/null +++ b/livekitManage/biz/handler/audioAndVideoCalls/video_call_service.go @@ -0,0 +1,32 @@ +// Code generated by hertz generator. + +package audioAndVideoCalls + +import ( + "audioAndVideoCalls/biz/dal/redis" + "context" + + audioAndVideoCalls "audioAndVideoCalls/biz/model/audioAndVideoCalls" + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// VideoCall . +// @router /videoCall [POST] +func VideoCall(ctx context.Context, c *app.RequestContext) { + var err error + var req audioAndVideoCalls.VideoCallReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + err = redis.VideoCall(req) + if err != nil { + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + resp := new(audioAndVideoCalls.VideoCallResp) + + c.JSON(consts.StatusOK, resp) +} diff --git a/livekitManage/biz/model/audioAndVideoCalls/audioAndVideoCalls.go b/livekitManage/biz/model/audioAndVideoCalls/audioAndVideoCalls.go index 1b7cce7..90a3c98 100644 --- a/livekitManage/biz/model/audioAndVideoCalls/audioAndVideoCalls.go +++ b/livekitManage/biz/model/audioAndVideoCalls/audioAndVideoCalls.go @@ -430,8 +430,863 @@ func (p *AudioCallResp) String() string { } +type VideoCallReq struct { + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id"` + TargetUserID string `thrift:"target_user_id,2" form:"target_user_id" json:"target_user_id"` +} + +func NewVideoCallReq() *VideoCallReq { + return &VideoCallReq{} +} + +func (p *VideoCallReq) InitDefault() { +} + +func (p *VideoCallReq) GetUserID() (v string) { + return p.UserID +} + +func (p *VideoCallReq) GetTargetUserID() (v string) { + return p.TargetUserID +} + +var fieldIDToName_VideoCallReq = map[int16]string{ + 1: "user_id", + 2: "target_user_id", +} + +func (p *VideoCallReq) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_VideoCallReq[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *VideoCallReq) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.UserID = _field + return nil +} +func (p *VideoCallReq) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.TargetUserID = _field + return nil +} + +func (p *VideoCallReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("videoCallReq"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *VideoCallReq) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.UserID); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *VideoCallReq) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("target_user_id", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.TargetUserID); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *VideoCallReq) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("VideoCallReq(%+v)", *p) + +} + +type VideoCallResp struct { + Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` + Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` +} + +func NewVideoCallResp() *VideoCallResp { + return &VideoCallResp{} +} + +func (p *VideoCallResp) InitDefault() { +} + +func (p *VideoCallResp) GetCode() (v Code) { + return p.Code +} + +func (p *VideoCallResp) GetMsg() (v string) { + return p.Msg +} + +var fieldIDToName_VideoCallResp = map[int16]string{ + 1: "code", + 2: "msg", +} + +func (p *VideoCallResp) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_VideoCallResp[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *VideoCallResp) ReadField1(iprot thrift.TProtocol) error { + + var _field Code + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = Code(v) + } + p.Code = _field + return nil +} +func (p *VideoCallResp) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Msg = _field + return nil +} + +func (p *VideoCallResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("videoCallResp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *VideoCallResp) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(p.Code)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *VideoCallResp) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Msg); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *VideoCallResp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("VideoCallResp(%+v)", *p) + +} + +type RoomListReq struct { +} + +func NewRoomListReq() *RoomListReq { + return &RoomListReq{} +} + +func (p *RoomListReq) InitDefault() { +} + +var fieldIDToName_RoomListReq = map[int16]string{} + +func (p *RoomListReq) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RoomListReq) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("roomListReq"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RoomListReq) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoomListReq(%+v)", *p) + +} + +type RoomListResp struct { +} + +func NewRoomListResp() *RoomListResp { + return &RoomListResp{} +} + +func (p *RoomListResp) InitDefault() { +} + +var fieldIDToName_RoomListResp = map[int16]string{} + +func (p *RoomListResp) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RoomListResp) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("roomListResp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RoomListResp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoomListResp(%+v)", *p) + +} + +type RemoveRoomReq struct { + RoomID string `thrift:"room_id,1" form:"room_id" json:"room_id"` +} + +func NewRemoveRoomReq() *RemoveRoomReq { + return &RemoveRoomReq{} +} + +func (p *RemoveRoomReq) InitDefault() { +} + +func (p *RemoveRoomReq) GetRoomID() (v string) { + return p.RoomID +} + +var fieldIDToName_RemoveRoomReq = map[int16]string{ + 1: "room_id", +} + +func (p *RemoveRoomReq) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_RemoveRoomReq[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RemoveRoomReq) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.RoomID = _field + return nil +} + +func (p *RemoveRoomReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("RemoveRoomReq"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RemoveRoomReq) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("room_id", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.RoomID); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *RemoveRoomReq) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RemoveRoomReq(%+v)", *p) + +} + +type RemoveRoomResp struct { + Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` + Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` +} + +func NewRemoveRoomResp() *RemoveRoomResp { + return &RemoveRoomResp{} +} + +func (p *RemoveRoomResp) InitDefault() { +} + +func (p *RemoveRoomResp) GetCode() (v Code) { + return p.Code +} + +func (p *RemoveRoomResp) GetMsg() (v string) { + return p.Msg +} + +var fieldIDToName_RemoveRoomResp = map[int16]string{ + 1: "code", + 2: "msg", +} + +func (p *RemoveRoomResp) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_RemoveRoomResp[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RemoveRoomResp) ReadField1(iprot thrift.TProtocol) error { + + var _field Code + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = Code(v) + } + p.Code = _field + return nil +} +func (p *RemoveRoomResp) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Msg = _field + return nil +} + +func (p *RemoveRoomResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("RemoveRoomResp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RemoveRoomResp) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(p.Code)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *RemoveRoomResp) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Msg); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *RemoveRoomResp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RemoveRoomResp(%+v)", *p) + +} + type AudioCallService interface { - Call(ctx context.Context, request *AudioCallReq) (r *AudioCallResp, err error) + AudioCall(ctx context.Context, request *AudioCallReq) (r *AudioCallResp, err error) } type AudioCallServiceClient struct { @@ -460,11 +1315,102 @@ func (p *AudioCallServiceClient) Client_() thrift.TClient { return p.c } -func (p *AudioCallServiceClient) Call(ctx context.Context, request *AudioCallReq) (r *AudioCallResp, err error) { - var _args AudioCallServiceCallArgs +func (p *AudioCallServiceClient) AudioCall(ctx context.Context, request *AudioCallReq) (r *AudioCallResp, err error) { + var _args AudioCallServiceAudioCallArgs _args.Request = request - var _result AudioCallServiceCallResult - if err = p.Client_().Call(ctx, "Call", &_args, &_result); err != nil { + var _result AudioCallServiceAudioCallResult + if err = p.Client_().Call(ctx, "audioCall", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type VideoCallService interface { + VideoCall(ctx context.Context, request *VideoCallReq) (r *VideoCallResp, err error) +} + +type VideoCallServiceClient struct { + c thrift.TClient +} + +func NewVideoCallServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *VideoCallServiceClient { + return &VideoCallServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewVideoCallServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *VideoCallServiceClient { + return &VideoCallServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewVideoCallServiceClient(c thrift.TClient) *VideoCallServiceClient { + return &VideoCallServiceClient{ + c: c, + } +} + +func (p *VideoCallServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *VideoCallServiceClient) VideoCall(ctx context.Context, request *VideoCallReq) (r *VideoCallResp, err error) { + var _args VideoCallServiceVideoCallArgs + _args.Request = request + var _result VideoCallServiceVideoCallResult + if err = p.Client_().Call(ctx, "videoCall", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type RoomService interface { + RoomList(ctx context.Context, request *RoomListReq) (r *RoomListResp, err error) + + RoomRemove(ctx context.Context, request *RemoveRoomReq) (r *RemoveRoomResp, err error) +} + +type RoomServiceClient struct { + c thrift.TClient +} + +func NewRoomServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *RoomServiceClient { + return &RoomServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewRoomServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *RoomServiceClient { + return &RoomServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewRoomServiceClient(c thrift.TClient) *RoomServiceClient { + return &RoomServiceClient{ + c: c, + } +} + +func (p *RoomServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *RoomServiceClient) RoomList(ctx context.Context, request *RoomListReq) (r *RoomListResp, err error) { + var _args RoomServiceRoomListArgs + _args.Request = request + var _result RoomServiceRoomListResult + if err = p.Client_().Call(ctx, "RoomList", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *RoomServiceClient) RoomRemove(ctx context.Context, request *RemoveRoomReq) (r *RemoveRoomResp, err error) { + var _args RoomServiceRoomRemoveArgs + _args.Request = request + var _result RoomServiceRoomRemoveResult + if err = p.Client_().Call(ctx, "RoomRemove", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil @@ -490,7 +1436,7 @@ func (p *AudioCallServiceProcessor) ProcessorMap() map[string]thrift.TProcessorF func NewAudioCallServiceProcessor(handler AudioCallService) *AudioCallServiceProcessor { self := &AudioCallServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("Call", &audioCallServiceProcessorCall{handler: handler}) + self.AddToProcessorMap("audioCall", &audioCallServiceProcessorAudioCall{handler: handler}) return self } func (p *AudioCallServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -511,16 +1457,16 @@ func (p *AudioCallServiceProcessor) Process(ctx context.Context, iprot, oprot th return false, x } -type audioCallServiceProcessorCall struct { +type audioCallServiceProcessorAudioCall struct { handler AudioCallService } -func (p *audioCallServiceProcessorCall) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AudioCallServiceCallArgs{} +func (p *audioCallServiceProcessorAudioCall) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AudioCallServiceAudioCallArgs{} if err = args.Read(iprot); err != nil { iprot.ReadMessageEnd() x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Call", thrift.EXCEPTION, seqId) + oprot.WriteMessageBegin("audioCall", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -529,11 +1475,11 @@ func (p *audioCallServiceProcessorCall) Process(ctx context.Context, seqId int32 iprot.ReadMessageEnd() var err2 error - result := AudioCallServiceCallResult{} + result := AudioCallServiceAudioCallResult{} var retval *AudioCallResp - if retval, err2 = p.handler.Call(ctx, args.Request); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Call: "+err2.Error()) - oprot.WriteMessageBegin("Call", thrift.EXCEPTION, seqId) + if retval, err2 = p.handler.AudioCall(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing audioCall: "+err2.Error()) + oprot.WriteMessageBegin("audioCall", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -541,7 +1487,7 @@ func (p *audioCallServiceProcessorCall) Process(ctx context.Context, seqId int32 } else { result.Success = retval } - if err2 = oprot.WriteMessageBegin("Call", thrift.REPLY, seqId); err2 != nil { + if err2 = oprot.WriteMessageBegin("audioCall", thrift.REPLY, seqId); err2 != nil { err = err2 } if err2 = result.Write(oprot); err == nil && err2 != nil { @@ -559,35 +1505,35 @@ func (p *audioCallServiceProcessorCall) Process(ctx context.Context, seqId int32 return true, err } -type AudioCallServiceCallArgs struct { +type AudioCallServiceAudioCallArgs struct { Request *AudioCallReq `thrift:"request,1"` } -func NewAudioCallServiceCallArgs() *AudioCallServiceCallArgs { - return &AudioCallServiceCallArgs{} +func NewAudioCallServiceAudioCallArgs() *AudioCallServiceAudioCallArgs { + return &AudioCallServiceAudioCallArgs{} } -func (p *AudioCallServiceCallArgs) InitDefault() { +func (p *AudioCallServiceAudioCallArgs) InitDefault() { } -var AudioCallServiceCallArgs_Request_DEFAULT *AudioCallReq +var AudioCallServiceAudioCallArgs_Request_DEFAULT *AudioCallReq -func (p *AudioCallServiceCallArgs) GetRequest() (v *AudioCallReq) { +func (p *AudioCallServiceAudioCallArgs) GetRequest() (v *AudioCallReq) { if !p.IsSetRequest() { - return AudioCallServiceCallArgs_Request_DEFAULT + return AudioCallServiceAudioCallArgs_Request_DEFAULT } return p.Request } -var fieldIDToName_AudioCallServiceCallArgs = map[int16]string{ +var fieldIDToName_AudioCallServiceAudioCallArgs = map[int16]string{ 1: "request", } -func (p *AudioCallServiceCallArgs) IsSetRequest() bool { +func (p *AudioCallServiceAudioCallArgs) IsSetRequest() bool { return p.Request != nil } -func (p *AudioCallServiceCallArgs) Read(iprot thrift.TProtocol) (err error) { +func (p *AudioCallServiceAudioCallArgs) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -632,7 +1578,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AudioCallServiceCallArgs[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AudioCallServiceAudioCallArgs[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -642,7 +1588,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *AudioCallServiceCallArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AudioCallServiceAudioCallArgs) ReadField1(iprot thrift.TProtocol) error { _field := NewAudioCallReq() if err := _field.Read(iprot); err != nil { return err @@ -651,9 +1597,9 @@ func (p *AudioCallServiceCallArgs) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *AudioCallServiceCallArgs) Write(oprot thrift.TProtocol) (err error) { +func (p *AudioCallServiceAudioCallArgs) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("Call_args"); err != nil { + if err = oprot.WriteStructBegin("audioCall_args"); err != nil { goto WriteStructBeginError } if p != nil { @@ -679,7 +1625,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *AudioCallServiceCallArgs) writeField1(oprot thrift.TProtocol) (err error) { +func (p *AudioCallServiceAudioCallArgs) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { goto WriteFieldBeginError } @@ -696,43 +1642,43 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *AudioCallServiceCallArgs) String() string { +func (p *AudioCallServiceAudioCallArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("AudioCallServiceCallArgs(%+v)", *p) + return fmt.Sprintf("AudioCallServiceAudioCallArgs(%+v)", *p) } -type AudioCallServiceCallResult struct { +type AudioCallServiceAudioCallResult struct { Success *AudioCallResp `thrift:"success,0,optional"` } -func NewAudioCallServiceCallResult() *AudioCallServiceCallResult { - return &AudioCallServiceCallResult{} +func NewAudioCallServiceAudioCallResult() *AudioCallServiceAudioCallResult { + return &AudioCallServiceAudioCallResult{} } -func (p *AudioCallServiceCallResult) InitDefault() { +func (p *AudioCallServiceAudioCallResult) InitDefault() { } -var AudioCallServiceCallResult_Success_DEFAULT *AudioCallResp +var AudioCallServiceAudioCallResult_Success_DEFAULT *AudioCallResp -func (p *AudioCallServiceCallResult) GetSuccess() (v *AudioCallResp) { +func (p *AudioCallServiceAudioCallResult) GetSuccess() (v *AudioCallResp) { if !p.IsSetSuccess() { - return AudioCallServiceCallResult_Success_DEFAULT + return AudioCallServiceAudioCallResult_Success_DEFAULT } return p.Success } -var fieldIDToName_AudioCallServiceCallResult = map[int16]string{ +var fieldIDToName_AudioCallServiceAudioCallResult = map[int16]string{ 0: "success", } -func (p *AudioCallServiceCallResult) IsSetSuccess() bool { +func (p *AudioCallServiceAudioCallResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AudioCallServiceCallResult) Read(iprot thrift.TProtocol) (err error) { +func (p *AudioCallServiceAudioCallResult) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -777,7 +1723,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AudioCallServiceCallResult[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AudioCallServiceAudioCallResult[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -787,7 +1733,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *AudioCallServiceCallResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AudioCallServiceAudioCallResult) ReadField0(iprot thrift.TProtocol) error { _field := NewAudioCallResp() if err := _field.Read(iprot); err != nil { return err @@ -796,9 +1742,9 @@ func (p *AudioCallServiceCallResult) ReadField0(iprot thrift.TProtocol) error { return nil } -func (p *AudioCallServiceCallResult) Write(oprot thrift.TProtocol) (err error) { +func (p *AudioCallServiceAudioCallResult) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("Call_result"); err != nil { + if err = oprot.WriteStructBegin("audioCall_result"); err != nil { goto WriteStructBeginError } if p != nil { @@ -824,7 +1770,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *AudioCallServiceCallResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AudioCallServiceAudioCallResult) writeField0(oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { goto WriteFieldBeginError @@ -843,10 +1789,1113 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) } -func (p *AudioCallServiceCallResult) String() string { +func (p *AudioCallServiceAudioCallResult) String() string { if p == nil { return "" } - return fmt.Sprintf("AudioCallServiceCallResult(%+v)", *p) + return fmt.Sprintf("AudioCallServiceAudioCallResult(%+v)", *p) + +} + +type VideoCallServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler VideoCallService +} + +func (p *VideoCallServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *VideoCallServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *VideoCallServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewVideoCallServiceProcessor(handler VideoCallService) *VideoCallServiceProcessor { + self := &VideoCallServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("videoCall", &videoCallServiceProcessorVideoCall{handler: handler}) + return self +} +func (p *VideoCallServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type videoCallServiceProcessorVideoCall struct { + handler VideoCallService +} + +func (p *videoCallServiceProcessorVideoCall) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := VideoCallServiceVideoCallArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("videoCall", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := VideoCallServiceVideoCallResult{} + var retval *VideoCallResp + if retval, err2 = p.handler.VideoCall(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing videoCall: "+err2.Error()) + oprot.WriteMessageBegin("videoCall", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("videoCall", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type VideoCallServiceVideoCallArgs struct { + Request *VideoCallReq `thrift:"request,1"` +} + +func NewVideoCallServiceVideoCallArgs() *VideoCallServiceVideoCallArgs { + return &VideoCallServiceVideoCallArgs{} +} + +func (p *VideoCallServiceVideoCallArgs) InitDefault() { +} + +var VideoCallServiceVideoCallArgs_Request_DEFAULT *VideoCallReq + +func (p *VideoCallServiceVideoCallArgs) GetRequest() (v *VideoCallReq) { + if !p.IsSetRequest() { + return VideoCallServiceVideoCallArgs_Request_DEFAULT + } + return p.Request +} + +var fieldIDToName_VideoCallServiceVideoCallArgs = map[int16]string{ + 1: "request", +} + +func (p *VideoCallServiceVideoCallArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *VideoCallServiceVideoCallArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_VideoCallServiceVideoCallArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *VideoCallServiceVideoCallArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewVideoCallReq() + if err := _field.Read(iprot); err != nil { + return err + } + p.Request = _field + return nil +} + +func (p *VideoCallServiceVideoCallArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("videoCall_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *VideoCallServiceVideoCallArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *VideoCallServiceVideoCallArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("VideoCallServiceVideoCallArgs(%+v)", *p) + +} + +type VideoCallServiceVideoCallResult struct { + Success *VideoCallResp `thrift:"success,0,optional"` +} + +func NewVideoCallServiceVideoCallResult() *VideoCallServiceVideoCallResult { + return &VideoCallServiceVideoCallResult{} +} + +func (p *VideoCallServiceVideoCallResult) InitDefault() { +} + +var VideoCallServiceVideoCallResult_Success_DEFAULT *VideoCallResp + +func (p *VideoCallServiceVideoCallResult) GetSuccess() (v *VideoCallResp) { + if !p.IsSetSuccess() { + return VideoCallServiceVideoCallResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_VideoCallServiceVideoCallResult = map[int16]string{ + 0: "success", +} + +func (p *VideoCallServiceVideoCallResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *VideoCallServiceVideoCallResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_VideoCallServiceVideoCallResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *VideoCallServiceVideoCallResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewVideoCallResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *VideoCallServiceVideoCallResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("videoCall_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *VideoCallServiceVideoCallResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *VideoCallServiceVideoCallResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("VideoCallServiceVideoCallResult(%+v)", *p) + +} + +type RoomServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler RoomService +} + +func (p *RoomServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *RoomServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *RoomServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewRoomServiceProcessor(handler RoomService) *RoomServiceProcessor { + self := &RoomServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("RoomList", &roomServiceProcessorRoomList{handler: handler}) + self.AddToProcessorMap("RoomRemove", &roomServiceProcessorRoomRemove{handler: handler}) + return self +} +func (p *RoomServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type roomServiceProcessorRoomList struct { + handler RoomService +} + +func (p *roomServiceProcessorRoomList) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := RoomServiceRoomListArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("RoomList", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := RoomServiceRoomListResult{} + var retval *RoomListResp + if retval, err2 = p.handler.RoomList(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing RoomList: "+err2.Error()) + oprot.WriteMessageBegin("RoomList", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("RoomList", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type roomServiceProcessorRoomRemove struct { + handler RoomService +} + +func (p *roomServiceProcessorRoomRemove) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := RoomServiceRoomRemoveArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("RoomRemove", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := RoomServiceRoomRemoveResult{} + var retval *RemoveRoomResp + if retval, err2 = p.handler.RoomRemove(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing RoomRemove: "+err2.Error()) + oprot.WriteMessageBegin("RoomRemove", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("RoomRemove", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type RoomServiceRoomListArgs struct { + Request *RoomListReq `thrift:"request,1"` +} + +func NewRoomServiceRoomListArgs() *RoomServiceRoomListArgs { + return &RoomServiceRoomListArgs{} +} + +func (p *RoomServiceRoomListArgs) InitDefault() { +} + +var RoomServiceRoomListArgs_Request_DEFAULT *RoomListReq + +func (p *RoomServiceRoomListArgs) GetRequest() (v *RoomListReq) { + if !p.IsSetRequest() { + return RoomServiceRoomListArgs_Request_DEFAULT + } + return p.Request +} + +var fieldIDToName_RoomServiceRoomListArgs = map[int16]string{ + 1: "request", +} + +func (p *RoomServiceRoomListArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *RoomServiceRoomListArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_RoomServiceRoomListArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RoomServiceRoomListArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewRoomListReq() + if err := _field.Read(iprot); err != nil { + return err + } + p.Request = _field + return nil +} + +func (p *RoomServiceRoomListArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("RoomList_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RoomServiceRoomListArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *RoomServiceRoomListArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoomServiceRoomListArgs(%+v)", *p) + +} + +type RoomServiceRoomListResult struct { + Success *RoomListResp `thrift:"success,0,optional"` +} + +func NewRoomServiceRoomListResult() *RoomServiceRoomListResult { + return &RoomServiceRoomListResult{} +} + +func (p *RoomServiceRoomListResult) InitDefault() { +} + +var RoomServiceRoomListResult_Success_DEFAULT *RoomListResp + +func (p *RoomServiceRoomListResult) GetSuccess() (v *RoomListResp) { + if !p.IsSetSuccess() { + return RoomServiceRoomListResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_RoomServiceRoomListResult = map[int16]string{ + 0: "success", +} + +func (p *RoomServiceRoomListResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *RoomServiceRoomListResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_RoomServiceRoomListResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RoomServiceRoomListResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewRoomListResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *RoomServiceRoomListResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("RoomList_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RoomServiceRoomListResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *RoomServiceRoomListResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoomServiceRoomListResult(%+v)", *p) + +} + +type RoomServiceRoomRemoveArgs struct { + Request *RemoveRoomReq `thrift:"request,1"` +} + +func NewRoomServiceRoomRemoveArgs() *RoomServiceRoomRemoveArgs { + return &RoomServiceRoomRemoveArgs{} +} + +func (p *RoomServiceRoomRemoveArgs) InitDefault() { +} + +var RoomServiceRoomRemoveArgs_Request_DEFAULT *RemoveRoomReq + +func (p *RoomServiceRoomRemoveArgs) GetRequest() (v *RemoveRoomReq) { + if !p.IsSetRequest() { + return RoomServiceRoomRemoveArgs_Request_DEFAULT + } + return p.Request +} + +var fieldIDToName_RoomServiceRoomRemoveArgs = map[int16]string{ + 1: "request", +} + +func (p *RoomServiceRoomRemoveArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *RoomServiceRoomRemoveArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_RoomServiceRoomRemoveArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RoomServiceRoomRemoveArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewRemoveRoomReq() + if err := _field.Read(iprot); err != nil { + return err + } + p.Request = _field + return nil +} + +func (p *RoomServiceRoomRemoveArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("RoomRemove_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RoomServiceRoomRemoveArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *RoomServiceRoomRemoveArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoomServiceRoomRemoveArgs(%+v)", *p) + +} + +type RoomServiceRoomRemoveResult struct { + Success *RemoveRoomResp `thrift:"success,0,optional"` +} + +func NewRoomServiceRoomRemoveResult() *RoomServiceRoomRemoveResult { + return &RoomServiceRoomRemoveResult{} +} + +func (p *RoomServiceRoomRemoveResult) InitDefault() { +} + +var RoomServiceRoomRemoveResult_Success_DEFAULT *RemoveRoomResp + +func (p *RoomServiceRoomRemoveResult) GetSuccess() (v *RemoveRoomResp) { + if !p.IsSetSuccess() { + return RoomServiceRoomRemoveResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_RoomServiceRoomRemoveResult = map[int16]string{ + 0: "success", +} + +func (p *RoomServiceRoomRemoveResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *RoomServiceRoomRemoveResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_RoomServiceRoomRemoveResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *RoomServiceRoomRemoveResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewRemoveRoomResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *RoomServiceRoomRemoveResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("RoomRemove_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *RoomServiceRoomRemoveResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *RoomServiceRoomRemoveResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoomServiceRoomRemoveResult(%+v)", *p) } diff --git a/livekitManage/biz/router/audioAndVideoCalls/audioAndVideoCalls.go b/livekitManage/biz/router/audioAndVideoCalls/audioAndVideoCalls.go index 4d8146a..7ef64b8 100644 --- a/livekitManage/biz/router/audioAndVideoCalls/audioAndVideoCalls.go +++ b/livekitManage/biz/router/audioAndVideoCalls/audioAndVideoCalls.go @@ -17,5 +17,8 @@ import ( func Register(r *server.Hertz) { root := r.Group("/", rootMw()...) - root.POST("/audioCall", append(_callMw(), audioAndVideoCalls.Call)...) + root.POST("/audioCall", append(_audiocallMw(), audioAndVideoCalls.AudioCall)...) + root.DELETE("/room", append(_roomremoveMw(), audioAndVideoCalls.RoomRemove)...) + root.GET("/roomlist", append(_roomlistMw(), audioAndVideoCalls.RoomList)...) + root.POST("/videoCall", append(_videocallMw(), audioAndVideoCalls.VideoCall)...) } diff --git a/livekitManage/biz/router/audioAndVideoCalls/middleware.go b/livekitManage/biz/router/audioAndVideoCalls/middleware.go index 2b58dda..1aa484f 100644 --- a/livekitManage/biz/router/audioAndVideoCalls/middleware.go +++ b/livekitManage/biz/router/audioAndVideoCalls/middleware.go @@ -20,3 +20,28 @@ func _callMw() []app.HandlerFunc { // your code... return nil } + +func _call0Mw() []app.HandlerFunc { + // your code... + return nil +} + +func _audiocallMw() []app.HandlerFunc { + // your code... + return nil +} + +func _videocallMw() []app.HandlerFunc { + // your code... + return nil +} + +func _roomlistMw() []app.HandlerFunc { + // your code... + return nil +} + +func _roomremoveMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/livekitManage/biz/utils/utils.go b/livekitManage/biz/utils/utils.go index 639f7ee..ec20e0f 100644 --- a/livekitManage/biz/utils/utils.go +++ b/livekitManage/biz/utils/utils.go @@ -28,3 +28,25 @@ func GenerateUniqueAudioRoomName() string { // 3. 拼接结果 return fmt.Sprintf("audio%s-%s", hexTimestamp, randomStr) } + +// GenerateUniqueVideoRoomName 生成唯一视频房间名 +// 格式:[时间戳(16进制)]-[随机字符(4位)] +func GenerateUniqueVideoRoomName() string { + // 1. 获取毫秒级时间戳,并转为16进制(缩短长度) + timestamp := time.Now().UnixMilli() // 毫秒级时间戳(13位数字) + hexTimestamp := fmt.Sprintf("%x", timestamp) // 转为16进制,约10-11位 + + // 2. 生成4位随机字符(字母+数字) + randomBytes := make([]byte, 3) // 3字节经base64编码后约4字符 + _, err := rand.Read(randomBytes) + if err != nil { + // 极端情况下随机数生成失败,用当前纳秒补充(降低重复风险) + ns := time.Now().UnixNano() % 10000 + return fmt.Sprintf("%s-%04d", hexTimestamp, ns) + } + // 取base64的前4位(过滤特殊字符) + randomStr := base64.URLEncoding.EncodeToString(randomBytes)[:4] + + // 3. 拼接结果 + return fmt.Sprintf("video%s-%s", hexTimestamp, randomStr) +} diff --git a/livekitManage/idl/audioAndVideoCalls.thrift b/livekitManage/idl/audioAndVideoCalls.thrift index 9e5dbaf..a81f534 100644 --- a/livekitManage/idl/audioAndVideoCalls.thrift +++ b/livekitManage/idl/audioAndVideoCalls.thrift @@ -20,5 +20,42 @@ struct audioCallResp { service AudioCallService { - audioCallResp Call(1: audioCallReq request) (api.post="/audioCall"); + audioCallResp audioCall(1: audioCallReq request) (api.post="/audioCall"); +} + +struct videoCallReq { + 1: string user_id (api.body="user_id"); + 2: string target_user_id (api.body="target_user_id"); +} + +struct videoCallResp { + 1: Code code + 2: string msg +} + +service VideoCallService { + videoCallResp videoCall(1: videoCallReq request) (api.post="/videoCall"); +} + + +struct roomListReq { + +} + +struct roomListResp { + +} + +struct RemoveRoomReq { + 1: string room_id (api.body="room_id"); +} + +struct RemoveRoomResp { + 1: Code code + 2: string msg +} + +service RoomService { + roomListResp RoomList(1: roomListReq request) (api.get="/roomlist"); + RemoveRoomResp RoomRemove(1: RemoveRoomReq request) (api.delete="/room"); } \ No newline at end of file diff --git a/livekitManage/protocol/message.go b/livekitManage/protocol/message.go index 0e7da6e..b2078c3 100644 --- a/livekitManage/protocol/message.go +++ b/livekitManage/protocol/message.go @@ -8,12 +8,18 @@ const ( TypeGroup = "group" TypeSys = "sys" TypeAudioCall = "audioCall" + TypeVideoCall = "videoCall" ) // 消息固定值 const ( + //音频通话 AudioCallAgree = "AudioCallAgree" AudioCallRefuse = "AudioCallRefuse" + + //视频通话 + VideoCallAgree = "VideoCallAgree" + VideoCallRefuse = "videoCallRefuse" ) // 消息结构 @@ -40,3 +46,10 @@ type AudioCallMessage struct { Token string `json:"token"` Server string `json:"server"` } + +// 视频通话消息 +type VideoCallMessage struct { + Room string `json:"room"` + Token string `json:"token"` + Server string `json:"server"` +} diff --git a/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go b/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go index 2f5f187..895f125 100644 --- a/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go +++ b/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go @@ -123,6 +123,8 @@ func handleIncomingMessage(senderID string, msg []byte) { redis.PublishToRedis(protocol.TypeSys, msg) case protocol.TypeAudioCall: redis.PublishToRedis(protocol.TypeAudioCall+":"+message.To, msg) + case protocol.TypeVideoCall: + redis.PublishToRedis(protocol.TypeVideoCall+":"+message.To, msg) default: hlog.Errorf("未知消息类型: %s", message.Type) diff --git a/pushNotificationCenter/protocol/message.go b/pushNotificationCenter/protocol/message.go index 0e7da6e..b2078c3 100644 --- a/pushNotificationCenter/protocol/message.go +++ b/pushNotificationCenter/protocol/message.go @@ -8,12 +8,18 @@ const ( TypeGroup = "group" TypeSys = "sys" TypeAudioCall = "audioCall" + TypeVideoCall = "videoCall" ) // 消息固定值 const ( + //音频通话 AudioCallAgree = "AudioCallAgree" AudioCallRefuse = "AudioCallRefuse" + + //视频通话 + VideoCallAgree = "VideoCallAgree" + VideoCallRefuse = "videoCallRefuse" ) // 消息结构 @@ -40,3 +46,10 @@ type AudioCallMessage struct { Token string `json:"token"` Server string `json:"server"` } + +// 视频通话消息 +type VideoCallMessage struct { + Room string `json:"room"` + Token string `json:"token"` + Server string `json:"server"` +}