public DiscoveredServer(BroadcastData aData) { version = aData.version; peerId = aData.peerId; isOpen = aData.isOpen; numPlayers = aData.numPlayers; serverScore = aData.serverScore; privateTeamKey = aData.privateTeamKey; Name = aData.Name; }
public void Setup(MedivisNetworkManager aNetworkManager) { networkManager = aNetworkManager; broadcastKey = Mathf.Abs(aNetworkManager.broadcastIdentifier.Hash()); // Make sure broadcastKey matches client Debug.Log("Set-up hash code in Server: " + broadcastKey.ToString()); isOpen = false; numPlayers = 0; broadcastDataObject = new BroadcastData(); broadcastDataObject.Name = networkManager.RoomName; broadcastDataObject.peerId = networkManager.peerId; UpdateBroadcastData(); }
public override void OnReceivedBroadcast(string aFromAddress, string aRawData) { BroadcastData data = new BroadcastData(); data.FromString(aRawData); // DEBUG LOG broadcastLogCounter += 1; receivedBroadcastLog.Enqueue(broadcastLogTokens[broadcastLogCounter % broadcastLogTokens.Length] + " " + aRawData); if (receivedBroadcastLog.Count > maxLogLines) { receivedBroadcastLog.Dequeue(); } var server = new DiscoveredServer(data); server.rawData = aRawData; server.ipAddress = aFromAddress; server.timestamp = Time.time; bool newData = false; if (!discoveredServers.ContainsKey(aFromAddress)) { // New server discoveredServers.Add(aFromAddress, server); Debug.Log(server.ipAddress); newData = true; } else { if (discoveredServers[aFromAddress].rawData != aRawData) { // Old server with new info discoveredServers[aFromAddress] = server; newData = true; } else { // Just update the timestamp discoveredServers[aFromAddress].timestamp = Time.time; newData = false; } } networkManager.OnReceivedBroadcast(aFromAddress, aRawData); if (newData) { networkManager.OnDiscoveredServer(server); } }