FromString() public method

public FromString ( string aString ) : void
aString string
return void
Esempio n. 1
0
    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);
        }
    }
    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);
            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);
        }
    }