xsockets.net

XSockets 4.0 ClientGuid replacment?


I'm re-factoring a project that currently uses XSockets 3.x where we keep track of the mapping between our playback sessions and clients using the old ClientGuid property.

With 4.0 what is the intended replacement for ClientGuid? I can find PersistentId and ConnectionId but I'm unsure which one if any to use.

Here is the context of the question in the 3.x code...

public string CreatePlayback( string RecordingID )    {
    string PlayID = SMFRecordServer.Instance.Player.Create( RecordingID, null );
    XSocketMediaSink clientSink = new XSocketMediaSink( PlayID, this.ClientGuid, this );
    lock ( m_tblSessions ){
        if ( m_tblSessions.ContainsKey( ClientGuid ) ){
            m_tblSessions[ ClientGuid ].Add( PlayID, clientSink );
        }else{
            m_tblSessions[ ClientGuid ] = new Dictionary<string,XSocketMediaSink>();
            m_tblSessions[ ClientGuid ].Add( PlayID, clientSink );
        }
    }
    SMFRecordServer.Instance.Player.AttachPlaySink( PlayID, clientSink );
    return PlayID;
}

Solution

  • In 4.0 that would be...

    public string CreatePlayback( string RecordingID )
    {
        string PlayID = SMFRecordServer.Instance.Player.Create( RecordingID, null );
    
        XSocketMediaSink clientSink = new XSocketMediaSink( PlayID, this.ConnectionId, this );
    
        lock ( m_tblSessions )
        {
            if ( m_tblSessions.ContainsKey( ConnectionId) )
            {
                m_tblSessions[ ConnectionId].Add( PlayID, clientSink );
            }
            else
            {
                m_tblSessions[ ConnectionId] = new Dictionary<string,XSocketMediaSink>();
                m_tblSessions[ ConnectionId].Add( PlayID, clientSink );
            }
        }
    
        SMFRecordServer.Instance.Player.AttachPlaySink( PlayID, clientSink );
    
        return PlayID;
    }
    

    A big difference between 3.* and 4.0 is that you can multiplex over several controllers on the same connection. So the ConnectionId is unique for each controller you are using while the PersistentId is for the connection itself.

    So on the controller you can get both this.ConnectionId (previously ClientGuid) and this.PersistentId (previously StorageGuid). You can also get this.Context that will contain information about the client (the ConnectionId will not be in there since that is on controller level).