private Dictionary <byte, object> GetInitObject() { var contract = new RegisterGameServerDataContract { GameServerAddress = this.Application.PublicIpAddress.ToString(), GameServerHostName = GameServerSettings.Default.PublicHostName, UdpPort = GameServerSettings.Default.RelayPortUdp == 0 ? this.Application.GamingUdpPort : GameServerSettings.Default.RelayPortUdp + this.Application.GetCurrentNodeId() - 1, TcpPort = GameServerSettings.Default.RelayPortTcp == 0 ? this.Application.GamingTcpPort : GameServerSettings.Default.RelayPortTcp + this.Application.GetCurrentNodeId() - 1, WebSocketPort = GameServerSettings.Default.RelayPortWebSocket == 0 ? this.Application.GamingWebSocketPort : GameServerSettings.Default.RelayPortWebSocket + this.Application.GetCurrentNodeId() - 1, SecureWebSocketPort = GameServerSettings.Default.RelayPortSecureWebSocket == 0 ? this.Application.GamingSecureWebSocketPort : GameServerSettings.Default.RelayPortSecureWebSocket + this.Application.GetCurrentNodeId() - 1, HttpPort = GameServerSettings.Default.RelayPortHttp == 0 ? this.Application.GamingHttpPort : GameServerSettings.Default.RelayPortHttp + this.Application.GetCurrentNodeId() - 1, SecureHttpPort = this.Application.GamingHttpsPort, WebRTCPort = GameServerSettings.Default.GamingWebRTCPort, HttpPath = this.Application.GamingHttpPath, ServerId = this.Application.ServerId.ToString(), ServerState = (int)this.Application.WorkloadController.ServerState, LoadLevelCount = (byte)FeedbackLevel.LEVELS_COUNT, PredictionData = this.GetPeer().GetPredictionData(), LoadBalancerPriority = GameServerSettings.Default.LoadBalancerPriority, LoadIndex = (byte)this.Application.WorkloadController.FeedbackLevel, SupportedProtocols = OutgoingMasterServerPeer.GetSupportedProtocolsFromString(GameServerSettings.Default.SupportedProtocols), }; if (this.Application.PublicIpAddressIPv6 != null) { contract.GameServerAddressIPv6 = this.Application.PublicIpAddressIPv6.ToString(); } if (log.IsInfoEnabled) { log.InfoFormat( "Connecting to master server with address {0}, TCP {1}, UDP {2}, WebSocket {3}, " + "Secure WebSocket {4}, HTTP {5}, ServerID {6}, Hostname {7}, IPv6Address {8}, WebRTC {9}", contract.GameServerAddress, contract.TcpPort, contract.UdpPort, contract.WebSocketPort, contract.SecureWebSocketPort, contract.HttpPort, contract.ServerId, contract.GameServerHostName, contract.GameServerAddressIPv6, contract.WebRTCPort); } return(contract.ToDictionary()); }
public void Dispose() { var timer = this.reconnectTimer; if (timer != null) { timer.Dispose(); this.reconnectTimer = null; } var masterPeer = this.peer; if (masterPeer != null) { masterPeer.Disconnect(); masterPeer.Dispose(); this.peer = null; } }
public void ConnectToMaster(IPEndPoint endPoint) { if (this.Application.Running == false) { return; } if (this.peer == null) { this.peer = this.CreateServerPeer(); } if (this.peer.ConnectTcp(endPoint, "Master")) { if (log.IsInfoEnabled) { log.InfoFormat("Connecting to master at {0}, serverId={1}", endPoint, this.Application.ServerId); } } else { log.WarnFormat("master connection refused - is the process shutting down ? {0}", this.Application.ServerId); } }