- 修改端口配置:将 .vscode/launch.json 中的端口从 27777 改为 27000 - 优化会话管理:更新 session 包中的 GetSession 和 SaveSession 函数,使用新的 sessionprx 变量 - 调整登录逻辑:修改 login 控制器中的 Login 函数,优化会话验证流程 - 扩展服务器信息结构:在 CommendSvrInfo 结构中添加好友和黑名单信息字段 - 修复 GetSessionId 函数:改进错误处理,确保返回值的一致性 - 更新服务器配置:修改 ServerR.xml 中的 EmailLogin URL 为本地地址 - 其他 minor changes:删除了一些不必要的注释和打印语句
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package main
|
||
|
||
import (
|
||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||
"github.com/panjf2000/gnet/v2"
|
||
|
||
"blazing/common/core"
|
||
"blazing/common/socket"
|
||
"blazing/common/socket/handler"
|
||
_ "blazing/contrib/files/local"
|
||
"blazing/cool"
|
||
"blazing/logic/service/login"
|
||
|
||
// Minio,按需启用
|
||
// _ "blazing/contrib/files/minio"
|
||
|
||
// 阿里云OSS,按需启用
|
||
// _ "blazing/contrib/files/oss"
|
||
|
||
// _ "blazing/contrib/drivers/sqlite"
|
||
|
||
//_ "blazing/contrib/drivers/mysql"
|
||
|
||
_ "blazing/contrib/drivers/pgsql"
|
||
|
||
_ "blazing/modules"
|
||
|
||
"github.com/gogf/gf/v2/os/gctx"
|
||
|
||
"blazing/login/internal/cmd"
|
||
)
|
||
|
||
func main() {
|
||
go Start(cool.Config.Port)
|
||
cmd.Main.Run(gctx.New())
|
||
}
|
||
|
||
func Start(port string) {
|
||
|
||
head := handler.NewTomeeHandler()
|
||
head.Callback = recv
|
||
socket.NewServer(socket.WithPort(port), socket.WithCORS(), socket.WithSocketHandler(head)).Start()
|
||
}
|
||
|
||
func recv(c gnet.Conn, data handler.TomeeHeader) {
|
||
|
||
ret := login.NewCommendSvrInfo()
|
||
|
||
lofin := login.NewServerInfo()
|
||
lofin.OnlineID = 1
|
||
lofin.UserCnt = 77
|
||
lofin.IP = "127.0.0.1"
|
||
lofin.Port = 27000
|
||
lofin.Friends = 1
|
||
//ret.Handler = data
|
||
ret.ServerList = append(ret.ServerList, *lofin)
|
||
|
||
tt := core.Pack(data, ret)
|
||
//fmt.Println(hex.EncodeToString(tt))
|
||
c.Write(tt)
|
||
|
||
}
|