// gets Channel Info by Name
        public static TtsrChannelInfo GetChannelInfo(string channel_name)
        {
            int             nRetVal = 0;
            int             records = 0;
            TtsrChannelInfo ci      = new TtsrChannelInfo();

            int ci_size = Marshal.SizeOf(typeof(TtsrChannelInfo));

            System.IntPtr p_channel = Marshal.AllocHGlobal(ci_size);

            nRetVal = tsrGetChannelInfoByName(channel_name, p_channel, (IntPtr)0, out records);

            // now process the items
            if (nRetVal == 0)
            {
                nRetVal = ci.ReadHeapValues(p_channel);
                Marshal.DestroyStructure(p_channel, typeof(TtsrChannelInfo));
            }

            // Free the memory that was allocated on the heap, otherwise
            // you will create a memory leak.
            Marshal.FreeHGlobal(p_channel);

            return(ci);
        }
        // gets Channel Info and Players by Name
        public static TtsrChannelInfo GetChannelInfo(string channel_name, ref TtsrPlayerInfo [] arr_pi)
        {
            const int       MAX_PLAYERS = 200;
            int             nRetVal     = 0;
            int             records     = MAX_PLAYERS;
            bool            bGetPlayers = false;
            TtsrChannelInfo ci          = new TtsrChannelInfo();

            TtsrPlayerInfo [] pi = new TtsrPlayerInfo[MAX_PLAYERS];

            int ci_size = Marshal.SizeOf(typeof(TtsrChannelInfo));
            int pi_size = Marshal.SizeOf(typeof(TtsrPlayerInfo)) * MAX_PLAYERS;

            System.IntPtr p_channel = Marshal.AllocHGlobal(ci_size);
            System.IntPtr p_player  = Marshal.AllocHGlobal(pi_size);
            System.IntPtr p_current = (IntPtr)0;

            nRetVal = tsrGetChannelInfoByName(channel_name, p_channel, p_player, out records);

            // figure out if we are to get the player list too.
            if (arr_pi != null)
            {
                bGetPlayers = true;
            }
            arr_pi = null;

            // now process the items
            if (nRetVal == 0)
            {
                nRetVal = ci.ReadHeapValues(p_channel);
                Marshal.DestroyStructure(p_channel, typeof(TtsrChannelInfo));

                if (nRetVal == 0 && bGetPlayers == true)
                {
                    // build the new player array...
                    arr_pi = new TtsrPlayerInfo [records];

                    // keep track of our player pointer
                    p_current = p_player;

                    for (int i = 0; i < records; i++)
                    {
                        arr_pi[i] = new TtsrPlayerInfo();

                        Marshal.PtrToStructure(p_current, arr_pi[i]);
                        Marshal.DestroyStructure(p_current, typeof(TtsrPlayerInfo));

                        p_current = (IntPtr)((int)p_current + Marshal.SizeOf(typeof(TtsrPlayerInfo)) - 2);
                    }
                }
            }

            // Free the memory that was allocated on the heap, otherwise
            // you will create a memory leak.
            Marshal.FreeHGlobal(p_channel);
            Marshal.FreeHGlobal(p_player);

            return(ci);
        }
Exemple #3
0
        // gets Channel Info by Name
        public static TtsrChannelInfo GetChannelInfo( string channel_name )
        {
            int        nRetVal    = 0;
            int        records    = 0;
            TtsrChannelInfo ci    = new TtsrChannelInfo();

            int        ci_size    = Marshal.SizeOf( typeof( TtsrChannelInfo ) );

            System.IntPtr p_channel = Marshal.AllocHGlobal( ci_size );

            nRetVal = tsrGetChannelInfoByName( channel_name, p_channel, (IntPtr)0, out records );

            // now process the items
            if ( nRetVal == 0 )
            {
                nRetVal = ci.ReadHeapValues( p_channel );
                Marshal.DestroyStructure( p_channel, typeof( TtsrChannelInfo ) );
            }

            // Free the memory that was allocated on the heap, otherwise
            // you will create a memory leak.
            Marshal.FreeHGlobal(p_channel);

            return ci;
        }
Exemple #4
0
        // gets Channel Info and Players by Name
        public static TtsrChannelInfo GetChannelInfo( string channel_name, ref TtsrPlayerInfo [] arr_pi )
        {
            const int MAX_PLAYERS = 200;
            int        nRetVal    = 0;
            int        records    = MAX_PLAYERS;
            bool bGetPlayers      = false;
            TtsrChannelInfo ci    = new TtsrChannelInfo();
            TtsrPlayerInfo [] pi  = new TtsrPlayerInfo[MAX_PLAYERS];

            int        ci_size    = Marshal.SizeOf( typeof( TtsrChannelInfo ) );
            int        pi_size    = Marshal.SizeOf( typeof( TtsrPlayerInfo  ) ) * MAX_PLAYERS;

            System.IntPtr p_channel = Marshal.AllocHGlobal( ci_size );
            System.IntPtr p_player  = Marshal.AllocHGlobal( pi_size );
            System.IntPtr p_current = (IntPtr)0;

            nRetVal = tsrGetChannelInfoByName( channel_name, p_channel, p_player, out records );

            // figure out if we are to get the player list too.
            if ( arr_pi != null )
            {
                bGetPlayers = true;
            }
            arr_pi = null;

            // now process the items
            if ( nRetVal == 0 )
            {
                nRetVal = ci.ReadHeapValues( p_channel );
                Marshal.DestroyStructure( p_channel, typeof( TtsrChannelInfo ) );

                if ( nRetVal == 0 && bGetPlayers == true )
                {
                    // build the new player array...
                    arr_pi = new TtsrPlayerInfo [ records ];

                    // keep track of our player pointer
                    p_current = p_player;

                    for( int i = 0; i < records; i++ )
                    {
                        arr_pi[ i ] = new TtsrPlayerInfo();

                        Marshal.PtrToStructure  ( p_current, arr_pi[ i ]);
                        Marshal.DestroyStructure( p_current, typeof(TtsrPlayerInfo) );

                        p_current = (IntPtr)((int)p_current + Marshal.SizeOf( typeof( TtsrPlayerInfo ) ) - 2 );
                    }
                }
            }

            // Free the memory that was allocated on the heap, otherwise
            // you will create a memory leak.
            Marshal.FreeHGlobal(p_channel);
            Marshal.FreeHGlobal(p_player);

            return ci;
        }
Exemple #5
0
 public TtsrUserInfo()
 {
     Player        = new TtsrPlayerInfo();
     Channel       = new TtsrChannelInfo();
     ParentChannel = new TtsrChannelInfo();
 }
 public TtsrUserInfo()
 {
     Player        = new TtsrPlayerInfo();
     Channel       = new TtsrChannelInfo();
     ParentChannel = new TtsrChannelInfo();
 }