- 将默认数据库从 MySQL 更改为 PostgreSQL - 更新数据库连接信息和相关设置 - 修改会话前缀为 "blazing:session:" - 添加 PostgreSQL 驱动支持 - 调整 Pet 模型中的 Data 字段类型从 longtext 改为 text
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package main
|
||
|
||
import (
|
||
"encoding/hex"
|
||
"fmt"
|
||
|
||
_ "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)
|
||
|
||
}
|