test-errcode
Gordon 2 years ago
parent 72aa6d5eab
commit 8d998ad63c

@ -45,6 +45,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
userRouterGroupChildToken.POST("/get_all_users_uid", u.GetAllUsersID) // todo userRouterGroupChildToken.POST("/get_all_users_uid", u.GetAllUsersID) // todo
userRouterGroupChildToken.POST("/account_check", u.AccountCheck) // todo userRouterGroupChildToken.POST("/account_check", u.AccountCheck) // todo
userRouterGroupChildToken.POST("/get_users", u.GetUsers) userRouterGroupChildToken.POST("/get_users", u.GetUsers)
userRouterGroupChildToken.POST("/get_users_online_status", u.GetUsersOnlineStatus)
} }
//friend routing group //friend routing group
friendRouterGroup := r.Group("/friend") friendRouterGroup := r.Group("/friend")
@ -141,7 +142,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
msgGroup.POST("/batch_send_msg", m.ManagementBatchSendMsg) msgGroup.POST("/batch_send_msg", m.ManagementBatchSendMsg)
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess) msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
msgGroup.POST("/get_users_online_status", m.GetUsersOnlineStatus)
//msgGroup.POST("/set_message_reaction_extensions", msg.SetMessageReactionExtensions) //msgGroup.POST("/set_message_reaction_extensions", msg.SetMessageReactionExtensions)
//msgGroup.POST("/get_message_list_reaction_extensions", msg.GetMessageListReactionExtensions) //msgGroup.POST("/get_message_list_reaction_extensions", msg.GetMessageListReactionExtensions)
//msgGroup.POST("/add_message_reaction_extensions", msg.AddMessageReactionExtensions) //msgGroup.POST("/add_message_reaction_extensions", msg.AddMessageReactionExtensions)

@ -2,6 +2,10 @@ package api
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r" "github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
@ -55,3 +59,15 @@ func (u *User) AccountCheck(c *gin.Context) {
func (u *User) GetUsers(c *gin.Context) { func (u *User) GetUsers(c *gin.Context) {
a2r.Call(user.UserClient.GetPaginationUsers, u.client, c) a2r.Call(user.UserClient.GetPaginationUsers, u.client, c)
} }
func (u *User) GetUsersOnlineStatus(c *gin.Context) {
params := apistruct.ManagementSendMsgReq{}
if err := c.BindJSON(&params); err != nil {
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
return
}
if !tokenverify.IsAppManagerUid(c) {
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
return
}
}

@ -202,7 +202,9 @@ func (c *Client) replyMessage(ctx context.Context, binaryReq *Req, err error, re
} }
} }
func (c *Client) PushMessage(ctx context.Context, msgData *sdkws.MsgData) error { func (c *Client) PushMessage(ctx context.Context, msgData *sdkws.MsgData) error {
data, err := proto.Marshal(msgData) var msg sdkws.PushMessages
msg.Msgs = append(msg.Msgs, msgData)
data, err := proto.Marshal(&msg)
if err != nil { if err != nil {
return err return err
} }

@ -125,7 +125,6 @@ func (s *Server) SuperGroupOnlineBatchPushOneMsg(ctx context.Context, req *msgga
func (s *Server) KickUserOffline(ctx context.Context, req *msggateway.KickUserOfflineReq) (*msggateway.KickUserOfflineResp, error) { func (s *Server) KickUserOffline(ctx context.Context, req *msggateway.KickUserOfflineReq) (*msggateway.KickUserOfflineResp, error) {
for _, v := range req.KickUserIDList { for _, v := range req.KickUserIDList {
if clients, _, ok := s.LongConnServer.GetUserPlatformCons(v, int(req.PlatformID)); ok { if clients, _, ok := s.LongConnServer.GetUserPlatformCons(v, int(req.PlatformID)); ok {
for _, client := range clients { for _, client := range clients {
err := client.KickOnlineMessage(ctx) err := client.KickOnlineMessage(ctx)

@ -9,27 +9,25 @@ import (
type LongConn interface { type LongConn interface {
//Close this connection //Close this connection
Close() error Close() error
//Write message to connection,messageType means data type,can be set binary(2) and text(1). // WriteMessage Write message to connection,messageType means data type,can be set binary(2) and text(1).
WriteMessage(messageType int, message []byte) error WriteMessage(messageType int, message []byte) error
//Read message from connection. // ReadMessage Read message from connection.
ReadMessage() (int, []byte, error) ReadMessage() (int, []byte, error)
// SetReadDeadline sets the read deadline on the underlying network connection, // SetReadDeadline sets the read deadline on the underlying network connection,
//after a read has timed out, will return an error. //after a read has timed out, will return an error.
SetReadDeadline(timeout time.Duration) error SetReadDeadline(timeout time.Duration) error
// SetWriteDeadline sets the write deadline when send message,when read has timed out,will return error. // SetWriteDeadline sets to write deadline when send message,when read has timed out,will return error.
SetWriteDeadline(timeout time.Duration) error SetWriteDeadline(timeout time.Duration) error
//Try to dial a connection,url must set auth args,header can control compress data // Dial Try to dial a connection,url must set auth args,header can control compress data
Dial(urlStr string, requestHeader http.Header) (*http.Response, error) Dial(urlStr string, requestHeader http.Header) (*http.Response, error)
//Whether the connection of the current long connection is nil // IsNil Whether the connection of the current long connection is nil
IsNil() bool IsNil() bool
//Set the connection of the current long connection to nil // SetConnNil Set the connection of the current long connection to nil
SetConnNil() SetConnNil()
// SetReadLimit sets the maximum size for a message read from the peer.bytes // SetReadLimit sets the maximum size for a message read from the peer.bytes
SetReadLimit(limit int64) SetReadLimit(limit int64)
SetPongHandler(handler PongHandler) SetPongHandler(handler PongHandler)
//Check the connection of the current and when it was sent are the same // GenerateLongConn Check the connection of the current and when it was sent are the same
//CheckSendConnDiffNow() bool
//
GenerateLongConn(w http.ResponseWriter, r *http.Request) error GenerateLongConn(w http.ResponseWriter, r *http.Request) error
} }
type GWebSocket struct { type GWebSocket struct {

Loading…
Cancel
Save