I cant connect to MasterServer by Realtime
I want do performance test in game server. So I create client by this code.
public TestClient() { this.client.AddCallbackTarget(this); this.client.StateChanged += this.OnStateChange; this.client.ConnectUsingSettings(new AppSettings()); Thread t = new Thread(this.Loop); t.Start(); } private void Loop(object state) { this.client.Service(); Thread.Sleep(33); } /// <summary> /// 连接状态发生改变时 /// </summary> /// <param name="statusCode"></param> private void OnStateChange(ClientState arg1, ClientState arg2) { log.Info(arg1 + " -> " + arg2); } public void OnConnectedToMaster() { log.Info("OnConnectedToMaster Server: " + this.client.LoadBalancingPeer.ServerIpAddress); EnterRoomParams opParams = new EnterRoomParams(); opParams.RoomName = "sas"; log.Info("-----------------------------------------JoinRoom Success"); this.client.OpJoinRoom(opParams); }
the method ConnectUsingSettings(AppSettings appSettings) in LoadBalancingClient is work(peer.connect() was called) .but OnConnectedToMaster() not be called.
I write constructor in AppSetting class
public AppSettings() { Server = "10.253.32.166";//the master server already running Port = 5055; UseNameServer = false; Protocol = ConnectionProtocol.Udp; EnableProtocolFallback = true; NetworkLogging = DebugLevel.ERROR; }
I want connect to master server by Realtime.So hope can help me! Thanks!
0
Answers
-
Loop should actually loop. Put in a while loop.
1