fix
parent
9ceb30d0d7
commit
022fcf092d
@ -1,13 +1,13 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
||||
<module name="sumo_server" />
|
||||
<configuration default="false" name="go build app/cmd/main" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
||||
<module name="dy_server" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<envs>
|
||||
<env name="REDIS_URL" value="redis://:adhd@123@101.35.201.220:6381/2?protocol=3" />
|
||||
</envs>
|
||||
<kind value="FILE" />
|
||||
<kind value="DIRECTORY" />
|
||||
<package value="app/cmd/main" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<directory value="$PROJECT_DIR$/cmd/main" />
|
||||
<filePath value="$PROJECT_DIR$/cmd/main/main.go" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
@ -1,49 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"app/network"
|
||||
"app/service/main/message/pb"
|
||||
"app/service/main/msg_util"
|
||||
"app/service/robot/user"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := network.NewTcpClient(
|
||||
":8888",
|
||||
newParser,
|
||||
newHandler)
|
||||
err := client.Connect(false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = client.SendMsg(&pb.Report{
|
||||
Info: []*pb.ReportInfo{
|
||||
{
|
||||
OpenId: "1",
|
||||
Score: 123,
|
||||
},
|
||||
{
|
||||
OpenId: "2",
|
||||
Score: 456,
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func newParser() network.ICodec {
|
||||
return msg_util.NewProtoCodec(msg_util.NewProtoParser("message", "MSG_TYPE"), 1024*64, false)
|
||||
}
|
||||
|
||||
func newHandler() network.INetHandler {
|
||||
return user.NewUser()
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"app/network"
|
||||
"app/service/main/message/pb"
|
||||
"app/service/main/msg_util"
|
||||
"app/service/robot/user"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
client := network.NewTcpClient(
|
||||
"129.211.8.84:8899",
|
||||
newParser,
|
||||
newHandler)
|
||||
err := client.Connect(false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//登陆
|
||||
login := &pb.Login{
|
||||
AppId: "debug",
|
||||
IsDebug: true,
|
||||
}
|
||||
err = client.SendMsg(login)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//上传分数
|
||||
openIdList := []string{
|
||||
"7374686837987841059",
|
||||
"7374698021348676648",
|
||||
"7372845558429537319",
|
||||
"7374677100777002003",
|
||||
"7374698021348660264",
|
||||
"7374673415892489242",
|
||||
"7374683012379776011",
|
||||
"7374686060594746368",
|
||||
"7374687164753499177",
|
||||
"7372850431053173801",
|
||||
}
|
||||
report := &pb.Report{}
|
||||
for _, openId := range openIdList {
|
||||
report.Info = append(report.Info, &pb.ReportInfo{
|
||||
OpenId: openId,
|
||||
Score: rand.Int31n(100),
|
||||
IsWin: rand.Float32() > 0.5,
|
||||
})
|
||||
}
|
||||
err = client.SendMsg(report)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//拉排行榜
|
||||
rank := &pb.GetRank{
|
||||
TopCount: 5,
|
||||
}
|
||||
err = client.SendMsg(rank)
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func newParser() network.ICodec {
|
||||
return msg_util.NewProtoCodec(msg_util.NewProtoParser("message", "MSG_TYPE"), 1024*64, false)
|
||||
}
|
||||
|
||||
func newHandler() network.INetHandler {
|
||||
return user.NewUser()
|
||||
}
|
||||
Loading…
Reference in New Issue