/// <summary> /// Called when a client message is received from the network. /// </summary> /// <param name="packetMsg">The packet message.</param> protected virtual bool OnClientMsgReceived(IPacketMsg packetMsg) { if (packetMsg == null) { DebugLog.WriteLine("CMClient", "Packet message failed to parse, shutting down connection"); Disconnect(); return(false); } DebugLog.WriteLine("CMClient", "<- Recv'd EMsg: {0} ({1}) (Proto: {2})", packetMsg.MsgType, ( int )packetMsg.MsgType, packetMsg.IsProto); // Multi message gets logged down the line after it's decompressed if (packetMsg.MsgType != EMsg.Multi) { try { DebugNetworkListener?.OnIncomingNetworkMessage(packetMsg.MsgType, packetMsg.GetData()); } catch (Exception e) { DebugLog.WriteLine("CMClient", "DebugNetworkListener threw an exception: {0}", e); } } switch (packetMsg.MsgType) { case EMsg.Multi: HandleMulti(packetMsg); break; case EMsg.ClientLogOnResponse: // we handle this to get the SteamID/SessionID and to setup heartbeating HandleLogOnResponse(packetMsg); break; case EMsg.ClientLoggedOff: // to stop heartbeating when we get logged off HandleLoggedOff(packetMsg); break; case EMsg.ClientServerList: // Steam server list HandleServerList(packetMsg); break; case EMsg.ClientCMList: HandleCMList(packetMsg); break; case EMsg.ClientSessionToken: // am session token HandleSessionToken(packetMsg); break; } return(true); }
/// <summary> /// Called when a client message is received from the network. /// </summary> /// <param name="packetMsg">The packet message.</param> protected virtual bool OnClientMsgReceived([NotNullWhen(true)] IPacketMsg?packetMsg) { if (packetMsg == null) { LogDebug("CMClient", "Packet message failed to parse, shutting down connection"); Disconnect(userInitiated: false); return(false); } // Multi message gets logged down the line after it's decompressed if (packetMsg.MsgType != EMsg.Multi) { try { DebugNetworkListener?.OnIncomingNetworkMessage(packetMsg.MsgType, packetMsg.GetData()); } catch (Exception e) { LogDebug("CMClient", "DebugNetworkListener threw an exception: {0}", e); } } switch (packetMsg.MsgType) { case EMsg.Multi: HandleMulti(packetMsg); break; case EMsg.ClientLogOnResponse: // we handle this to get the SteamID/SessionID and to setup heartbeating HandleLogOnResponse(packetMsg); break; case EMsg.ClientLoggedOff: // to stop heartbeating when we get logged off HandleLoggedOff(packetMsg); break; case EMsg.ClientServerUnavailable: HandleServerUnavailable(packetMsg); break; case EMsg.ClientCMList: HandleCMList(packetMsg); break; case EMsg.ClientSessionToken: // am session token HandleSessionToken(packetMsg); break; } return(true); }