BF2Statistics.Gamespy.MasterClient.MasterClient C# (CSharp) Method

MasterClient() public method

Constructor
public MasterClient ( GamespyTcpStream client ) : System
client BF2Statistics.Gamespy.Net.GamespyTcpStream
return System
        public MasterClient(GamespyTcpStream client)
        {
            // Internal Variables
            this.Disposed = false;

            // Generate a unique name for this connection
            this.ConnectionId = Interlocked.Increment(ref SessionsCreated);

            // Init a new client stream class
            Stream = client;
            Stream.OnDisconnect += () => Dispose();
            Stream.DataReceived += (receivedData) =>
            {
                // lets split up the message based on the delimiter
                string[] messages = receivedData.Split(new string[] { "\x00\x00\x00\x00" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string message in messages)
                {
                    // Ignore Non-BF2 related queries
                    if (message.StartsWith("battlefield2"))
                        ParseRequest(message);
                }
            };
        }