Exemple #1
0
        void HandleLogOnResponse(IPacketMsg packetMsg)
        {
            if (!packetMsg.IsProto)
            {
                // a non proto ClientLogonResponse can come in as a result of connecting but never sending a ClientLogon
                // in this case, it always fails, so we don't need to do anything special here
                LogDebug("CMClient", "Got non-proto logon response, this is indicative of no logon attempt after connecting.");
                return;
            }

            var logonResp   = new ClientMsgProtobuf <CMsgClientLogonResponse>(packetMsg);
            var logonResult = ( EResult )logonResp.Body.eresult;

            if (logonResult == EResult.OK)
            {
                SessionID = logonResp.ProtoHeader.client_sessionid;
                SteamID   = logonResp.ProtoHeader.steamid;

                CellID        = logonResp.Body.cell_id;
                PublicIP      = NetHelpers.GetIPAddress(logonResp.Body.deprecated_public_ip);
                IPCountryCode = logonResp.Body.ip_country_code;

                int hbDelay = logonResp.Body.out_of_game_heartbeat_seconds;

                // restart heartbeat
                heartBeatFunc.Stop();
                heartBeatFunc.Delay = TimeSpan.FromSeconds(hbDelay);
                heartBeatFunc.Start();
            }
            else if (logonResult == EResult.TryAnotherCM || logonResult == EResult.ServiceUnavailable)
            {
                if (connection?.CurrentEndPoint != null)
                {
                    Servers.TryMark(connection.CurrentEndPoint, connection.ProtocolTypes, ServerQuality.Bad);
                }
            }
        }
Exemple #2
0
        void HandleCMList(IPacketMsg packetMsg)
        {
            var cmMsg = new ClientMsgProtobuf <CMsgClientCMList>(packetMsg);

            DebugLog.Assert(cmMsg.Body.cm_addresses.Count == cmMsg.Body.cm_ports.Count, "CMClient", "HandleCMList received malformed message");

            var cmList = cmMsg.Body.cm_addresses
                         .Zip(cmMsg.Body.cm_ports, (addr, port) => ServerRecord.CreateSocketServer(new IPEndPoint(NetHelpers.GetIPAddress(addr), ( int )port)));

            var webSocketList = cmMsg.Body.cm_websocket_addresses.Select(addr => ServerRecord.CreateWebSocketServer(addr));

            // update our list with steam's list of CMs
            Servers.ReplaceList(cmList.Concat(webSocketList));
        }
Exemple #3
0
 public void GetIPAddress()
 {
     Assert.Equal(IPAddress.Loopback, NetHelpers.GetIPAddress(2130706433));
     Assert.Equal(2130706433u, NetHelpers.GetIPAddressAsUInt(IPAddress.Loopback));
 }