The Sims Online: Pre‐Alpha ‐ nio2so Protocol Regulators Reference - JDrocks450/nio2so GitHub Wiki

This reference material is generated from this directory in the repo.

Context

What is a Protocol-Regulator in nio2so

These handle incoming PDUs by their PDU Type. They can respond with one, or many PDUs.

When a PDU is received from the client in nio2so, the PDU given to the Protocol-Regulator that has a matching Handler function. These are broken-down into three types:

Three types of Handler Functions:

  1. TSOProtocolHandler - These are simple TSOVoltron PDUs, deriving from TSOVoltronPacket. They fall into this category if they are not one of the other two.
  2. TSOProtocolDatabaseHandler - These are Database PDUs, they derive from TSODBRequestWrapper.cs, which in turn derives its logic from TSOVoltronPacket, and therefore is also a TSOVoltron PDU. They have a different structure and format than a normal TSOVoltron PDU and are used primarily in Database operations, hence the name.
  3. TSOProtocolDatablobHandler - These are used specifically in the Simulation of the game. They have Broadcast and Transmit types of Datablob PDUs.

Protocol-Regulators can do the following things:

  1. Respond to the Client with a PDU it forms
  2. Insert a new PDU into the receiving queue (pass messages to another regulator)
  3. Append a PDU to the end of the receiving queue
  4. Ignore it
  5. Run other code depending on what the needs are.

These regulators have a connection to the nio2so Data Service to supply data to the Client.

Identifying a Protocol-Regulator

    /// <summary>
    /// Handles incoming requests related to the Avatars and their DB operations
    /// </summary>
    [TSORegulator("AvatarProtocol")]
    internal class AvatarProtocol : TSOProtocol

nio2so Protocol-Regulators have the TSORegulator attribute and inherit TSOProtocol (TSORegulatorBase).

TSOProtocolHandler

Incoming PDU CLSID Method Name Parameters
FIND_PLAYER_PDU FIND_PLAYER_PDU TSOVoltronPacket PDU

TSOProtocolDatabaseHandler Handler Functions

Incoming PDU CLSID Parameter(s) Associated Action CLSID
GetCharByID_Request TSODBRequestWrapper PDU GetCharByID_Request
SetCharByID_Request TSODBRequestWrapper PDU SetCharByID_Request
GetCharBlobByID_Request TSODBRequestWrapper PDU GetCharBlobByID_Request
GetBookmarks_Request TSODBRequestWrapper PDU GetBookmarks_Request
SetBookmarks_Request TSODBRequestWrapper PDU SetBookmarks_Request
InsertNewCharBlob_Request TSODBRequestWrapper PDU InsertNewCharBlob_Request
SetCharBlob_Request TSODBRequestWrapper PDU SetCharBlob_Request
DebitCredit_Request TSODBRequestWrapper PDU DebitCredit_Request
SetMoneyFields_Request TSODBRequestWrapper PDU SetMoneyFields_Request
GetRelationshipsByID_Request TSODBRequestWrapper PDU GetRelationshipsByID_Request
GetReversedRelationshipsByID_Request TSODBRequestWrapper PDU GetReversedRelationshipsByID_Request

TSOProtocolHandler

Incoming PDU CLSID Method Name Parameters
LOAD_HOUSE_PDU LOAD_HOUSE_PDU TSOVoltronPacket PDU

TSOProtocolDatabaseHandler Handler Functions

Incoming PDU CLSID Method Name Parameters
BuyLotByAvatarID_Request BuyLotByAvatarID_Request TSODBRequestWrapper PDU
GetRoommateInfoByLotID_Request GetRoommateInfoByLotID_Request TSODBRequestWrapper PDU
GetLotList_Request GetLotList_Request TSODBRequestWrapper PDU
GetLotByID_Request GetLotByID_Request TSODBRequestWrapper PDU
GetHouseThumbByID_Request GetHouseThumbByID_Request TSODBRequestWrapper PDU
SetHouseThumbByID_Request SetHouseThumbByID_Request TSODBRequestWrapper PDU
GetHouseBlobByID_Request GetHouseBlobByID_Request TSODBRequestWrapper PDU
SetHouseBlobByID_Request SetHouseBlobByID_Request TSODBRequestWrapper PDU
SetLotByID_Request SetLotByID_Request TSODBRequestWrapper PDU

TSOProtocolHandler

Incoming PDU CLSID Method Name Parameters
LIST_ROOMS_PDU LIST_ROOMS_PDU TSOVoltronPacket PDU
LOT_ENTRY_REQUEST_PDU LOT_ENTRY_REQUEST_PDU TSOVoltronPacket PDU
DESTROY_ROOM_PDU DESTROY_ROOM_PDU TSOVoltronPacket PDU
DETACH_FROM_ROOM_PDU DETACH_FROM_ROOM_PDU TSOVoltronPacket PDU
CHAT_MSG_PDU CHAT_MSG_PDU TSOVoltronPacket PDU

TSOProtocolDatabaseHandler

Incoming PDU CLSID Method Name Parameters
GetHouseLeaderByLotID_Request GetHouseLeaderByLotID_Request TSODBRequestWrapper PDU
Incoming PDU CLSID Method Name Parameters
GET_MPS_MESSAGES_PDU GET_MPS_MESSAGES_PDU TSOVoltronPacket PDU
FLASH_MSG_PDU FLASH_MESSAGE_PDU TSOVoltronPacket PDU

Implementation Details:

  • Inbox Lifecycle: The GET_MPS_MESSAGES_PDU handler follows a "fetch-and-clear" pattern. It downloads all pending messages for the avatar from the data service, transmits them to the client as individual flash packets, and then immediately calls ClearInboxMessages to empty the server-side queue.

  • Flash Message Routing: The FLASH_MESSAGE_PDU logic differentiates between two types of communication:

    • SMS: Attempts a real-time delivery using TrySendTo. If the recipient is online and the packet sends successfully, it confirms back to the sender.

    • Letter: Persists the message to the database via SendInboxMessageToAvatar for later retrieval, acting as an offline mailing system.

  • Data Conversion: The class includes helper methods ToLetter and FromLetter to bridge the gap between the network-layer TSOFlashMessagePDU and the data-service-layer Letter object.

TSOProtocolDatabaseHandler

Incoming PDU CLSID Method Name Parameters
SearchExactMatch_Request SearchExactMatch_Request TSODBRequestWrapper PDU
Search_Request Search_Request TSODBRequestWrapper PDU

Implementation Details:

  • Unified Logic: Both exact and wildcard searches are routed through UnifiedSearchHandler. This method determines the search type by checking the object type (TSOExactSearchRequest) and then awaits the results from the data service.

  • Category Mapping: The search utilizes the TSO_PreAlpha_Categories enum, which is converted to a string before being sent to the nio2soVoltronDataServiceClient.

  • Search Results: The results are mapped from the data service IDs and names into TSOSearchResultStruct objects before being packaged into either a TSOExactSearchResponse or a standard TSOSearchResponse.

TSOProtocolDatabaseHandler

Incoming PDU CLSID Method Name Parameters
GetTopList_Request GET_TOP_LIST_REQUEST TSODBRequestWrapper DBPDU
GetTopResultSetByID_Request GET_TOP_RESULT_SET_BY_ID_REQUEST TSODBRequestWrapper DBPDU

Implementation Details:

  • Dynamic Image Conversion: The class includes a unique TO_RLE8 method. Since The Sims Online (Pre-Alpha) requires specific legacy formats, this converts modern images into 8-bit Indexed BMPs with RLE (Run-Length Encoding) compression on the fly.

  • Resource Caching: It uses a ConcurrentDictionary to cache these encoded bytes during a single request cycle to avoid redundant processing, though it calls FLUSH_CACHE() at the end of the GET_TOP_LIST_REQUEST to prevent memory bloat.

  • Format Constraints: Images are explicitly cropped and clamped to a maximum size of 96x23 pixels during the conversion process to ensure they fit the UI constraints of the Top 100 list icons.

  • Top 100 Lists: The logic supports different list types (e.g., "Most Popular Places") by mapping the remote data service results into the TSOTop100List and TSOTopListResultStruct formats required by the client.

TSOProtocolHandler

Incoming PDU CLSID Method Name Parameters
BYE_PDU BYE_PDU TSOVoltronPacket PDU
CLIENT_ONLINE_PDU CLIENT_ONLINE_PDU TSOVoltronPacket PDU
BC_VERSION_LIST_PDU BC_VERSION_LIST_PDU TSOVoltronPacket PDU

TSOProtocolDatabaseHandler

This handler manages incoming telemetry and logging from the client.

Incoming PDU CLSID Method Name Parameters
InsertGenericLog_Request InsertGenericLog_Request TSODBRequestWrapper PDU

Implementation Details:

  • UPDATE_PLAYER_PDU this PDU tells the client "who" the player is, their name and account ID.

  • This Protocol handles when someone disconnects from Voltron, ensuring their session is properly closed: their house they're hosting is taken offline, and they're properly marked as being offline.

  • BC_VERSION_LIST_PDU is currently unknown what it does.

  • InsertGenericLog_Request is sent from the Client when it wants to log something important, and it is shown in nio2so as well.

⚠️ **GitHub.com Fallback** ⚠️