You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package gate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"git.noahlan.cn/northlan/ngs/component"
|
|
|
|
"git.noahlan.cn/northlan/ngs/examples/cluster/protocol"
|
|
|
|
"git.noahlan.cn/northlan/ngs/session"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BindService struct {
|
|
|
|
component.Base
|
|
|
|
nextGateUid int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func newBindService() *BindService {
|
|
|
|
return &BindService{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type (
|
|
|
|
LoginRequest struct {
|
|
|
|
Nickname string `json:"nickname"`
|
|
|
|
}
|
|
|
|
LoginResponse struct {
|
|
|
|
Code int `json:"code"`
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (bs *BindService) Login(s *session.Session, msg *LoginRequest) error {
|
|
|
|
bs.nextGateUid++
|
|
|
|
uid := bs.nextGateUid
|
|
|
|
request := &protocol.NewUserRequest{
|
|
|
|
Nickname: msg.Nickname,
|
|
|
|
GateUid: uid,
|
|
|
|
}
|
|
|
|
if err := s.RPC("TopicService.NewUser", request); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return s.Response(&LoginResponse{})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bs *BindService) BindChatServer(s *session.Session, msg []byte) error {
|
|
|
|
return errors.New(fmt.Sprintf("not implement"))
|
|
|
|
}
|