Fetch the repository succeeded.
package main
import (
"flag"
"sync"
"math/rand"
"time"
_ "net/http/pprof"
"os"
"github.com/xiaonanln/goTimer"
"github.com/xiaonanln/goworld/engine/binutil"
"github.com/xiaonanln/goworld/engine/config"
"github.com/xiaonanln/goworld/engine/gwlog"
)
var (
quiet bool
configFile string
serverHost string
useWebSocket bool
useKCP bool
numClients int
startClientId int
noEntitySync bool
)
func parseArgs() {
flag.BoolVar(&quiet, "quiet", false, "run client quietly with much less output")
flag.StringVar(&configFile, "configfile", "", "set config file path")
flag.IntVar(&numClients, "N", 1000, "Number of clients")
flag.IntVar(&startClientId, "S", 1, "Start ID of clients")
flag.StringVar(&serverHost, "server", "localhost", "replace server address")
flag.BoolVar(&useWebSocket, "ws", false, "use WebSocket to connect server")
flag.BoolVar(&useKCP, "kcp", false, "use KCP to connect server")
flag.BoolVar(&noEntitySync, "nosync", false, "disable entity sync")
flag.Parse()
}
func main() {
rand.Seed(time.Now().UnixNano())
parseArgs()
if configFile != "" {
config.SetConfigFile(configFile)
}
binutil.SetupGWLog("test_client", "info", "test_client.log", true)
binutil.SetupHTTPServer("localhost", 18888, nil)
if useWebSocket && useKCP {
gwlog.Errorf("Can not use both websocket and KCP")
os.Exit(1)
}
if useWebSocket {
gwlog.Infof("Using websocket clients ...")
} else if useKCP {
gwlog.Infof("Using KCP clients ...")
}
var wait sync.WaitGroup
wait.Add(numClients)
for i := 0; i < numClients; i++ {
bot := newClientBot(startClientId+i, useWebSocket, useKCP, noEntitySync, &wait)
go bot.run()
}
timer.StartTicks(time.Millisecond * 100)
wait.Wait()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。