Пример #1
0
        public PropertyBag(InfiniminerGame gameInstance)
        {
            // Initialize our network device.
            NetPeerConfiguration netConfig = new NetPeerConfiguration("InfiniminerPlus");

            netClient = new NetClient(netConfig);
            netConfig.SetMessageTypeEnabled(NetIncomingMessageType.ErrorMessage, true);
            //netClient.SimulatedMinimumLatency = 0.1f;
            //netClient.SimulatedLatencyVariance = 0.05f;
            //netClient.SimulatedLoss = 0.1f;
            //netClient.SimulatedDuplicates = 0.05f;
            netClient.Start();

            // Initialize engines.
            blockEngine     = new BlockEngine(gameInstance);
            interfaceEngine = new InterfaceEngine(gameInstance);
            playerEngine    = new PlayerEngine(gameInstance);
            skyplaneEngine  = new SkyplaneEngine(gameInstance);
            particleEngine  = new ParticleEngine(gameInstance);

            // Create a camera.
            playerCamera = new Camera(gameInstance.GraphicsDevice);
            UpdateCamera();

            // Load sounds.
            if (!gameInstance.NoSound)
            {
                soundList[InfiniminerSound.DigDirt]         = gameInstance.Content.Load <SoundEffect>("sounds/dig-dirt");
                soundList[InfiniminerSound.DigMetal]        = gameInstance.Content.Load <SoundEffect>("sounds/dig-metal");
                soundList[InfiniminerSound.Ping]            = gameInstance.Content.Load <SoundEffect>("sounds/ping");
                soundList[InfiniminerSound.ConstructionGun] = gameInstance.Content.Load <SoundEffect>("sounds/build");
                soundList[InfiniminerSound.Death]           = gameInstance.Content.Load <SoundEffect>("sounds/death");
                soundList[InfiniminerSound.CashDeposit]     = gameInstance.Content.Load <SoundEffect>("sounds/cash");
                soundList[InfiniminerSound.ClickHigh]       = gameInstance.Content.Load <SoundEffect>("sounds/click-loud");
                soundList[InfiniminerSound.ClickLow]        = gameInstance.Content.Load <SoundEffect>("sounds/click-quiet");
                soundList[InfiniminerSound.GroundHit]       = gameInstance.Content.Load <SoundEffect>("sounds/hitground");
                soundList[InfiniminerSound.Teleporter]      = gameInstance.Content.Load <SoundEffect>("sounds/teleport");
                soundList[InfiniminerSound.Jumpblock]       = gameInstance.Content.Load <SoundEffect>("sounds/jumpblock");
                soundList[InfiniminerSound.Explosion]       = gameInstance.Content.Load <SoundEffect>("sounds/explosion");
                soundList[InfiniminerSound.RadarHigh]       = gameInstance.Content.Load <SoundEffect>("sounds/radar-high");
                soundList[InfiniminerSound.RadarLow]        = gameInstance.Content.Load <SoundEffect>("sounds/radar-low");
                soundList[InfiniminerSound.RadarSwitch]     = gameInstance.Content.Load <SoundEffect>("sounds/switch");
            }

            // Create a SINGLE SPRITEBATCH FOR THE F*****G GOD DAMN STATES AND SHIT
            spriteBatch = new SpriteBatch(gameInstance.GraphicsDevice);

            //Generate a SINGLE 1px white texture
            shade = new Texture2D(gameInstance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            shade.SetData(new Color[] { Color.White });
        }
Пример #2
0
        public PropertyBag(InfiniminerGame gameInstance)
        {
            // Initialize our network device.
            NetPeerConfiguration netConfig = new NetPeerConfiguration("InfiniminerPlus");

            netClient = new NetClient(netConfig);
            //netClient.SetMessageTypeEnabled(NetMessageType.ConnectionRejected, true);
            netConfig.EnableMessageType(NetIncomingMessageType.WarningMessage);

            //netClient.SimulatedMinimumLatency = 0.1f;
            //netClient.SimulatedLatencyVariance = 0.05f;
            //netClient.SimulatedLoss = 0.1f;
            //netClient.SimulatedDuplicates = 0.05f;
            netClient.Start();

            // Initialize engines.
            blockEngine     = new BlockEngine(gameInstance);
            interfaceEngine = new InterfaceEngine(gameInstance);
            playerEngine    = new PlayerEngine(gameInstance);
            skyplaneEngine  = new SkyplaneEngine(gameInstance);
            particleEngine  = new ParticleEngine(gameInstance);

            // Create a camera.
            playerCamera = new Camera(gameInstance.GraphicsDevice);
            UpdateCamera();

            // Load sounds.
            if (!gameInstance.NoSound)
            {
                soundList[InfiniminerSound.DigDirt]         = gameInstance.Content.Load <SoundEffect>("sounds/dig-dirt");
                soundList[InfiniminerSound.DigMetal]        = gameInstance.Content.Load <SoundEffect>("sounds/dig-metal");
                soundList[InfiniminerSound.Ping]            = gameInstance.Content.Load <SoundEffect>("sounds/ping");
                soundList[InfiniminerSound.ConstructionGun] = gameInstance.Content.Load <SoundEffect>("sounds/build");
                soundList[InfiniminerSound.Death]           = gameInstance.Content.Load <SoundEffect>("sounds/death");
                soundList[InfiniminerSound.CashDeposit]     = gameInstance.Content.Load <SoundEffect>("sounds/cash");
                soundList[InfiniminerSound.ClickHigh]       = gameInstance.Content.Load <SoundEffect>("sounds/click-loud");
                soundList[InfiniminerSound.ClickLow]        = gameInstance.Content.Load <SoundEffect>("sounds/click-quiet");
                soundList[InfiniminerSound.GroundHit]       = gameInstance.Content.Load <SoundEffect>("sounds/hitground");
                soundList[InfiniminerSound.Teleporter]      = gameInstance.Content.Load <SoundEffect>("sounds/teleport");
                soundList[InfiniminerSound.Jumpblock]       = gameInstance.Content.Load <SoundEffect>("sounds/jumpblock");
                soundList[InfiniminerSound.Explosion]       = gameInstance.Content.Load <SoundEffect>("sounds/explosion");
                soundList[InfiniminerSound.RadarHigh]       = gameInstance.Content.Load <SoundEffect>("sounds/radar-high");
                soundList[InfiniminerSound.RadarLow]        = gameInstance.Content.Load <SoundEffect>("sounds/radar-low");
                soundList[InfiniminerSound.RadarSwitch]     = gameInstance.Content.Load <SoundEffect>("sounds/switch");
            }
        }
Пример #3
0
        private void CheckForStandingInLava()
        {
            // Copied from TryToMoveTo; responsible for checking if lava has flowed over us.

            BlockEngine blockEngine = propertyBag.GetEngine <BlockEngine>("blockEngine");

            Vector3   movePosition   = propertyBag.PlayerContainer.PlayerPosition;
            Vector3   midBodyPoint   = movePosition + new Vector3(0, -0.7f, 0);
            Vector3   lowerBodyPoint = movePosition + new Vector3(0, -1.4f, 0);
            BlockType lowerBlock     = blockEngine.BlockAtPoint(lowerBodyPoint);
            BlockType midBlock       = blockEngine.BlockAtPoint(midBodyPoint);
            BlockType upperBlock     = blockEngine.BlockAtPoint(movePosition);

            if (upperBlock == BlockType.Lava || lowerBlock == BlockType.Lava || midBlock == BlockType.Lava)
            {
                propertyBag.KillPlayer(Defines.deathByLava);
            }
        }
Пример #4
0
 public PlayerEngine(InfiniminerGame gameInstance)
 {
     this.gameInstance = gameInstance;
     blockEngine       = gameInstance.propertyBag.GetEngine <BlockEngine>("blockEngine");
 }
Пример #5
0
 public DynamicVertexBufferTag(BlockEngine blockEngine, int texture, int region)
 {
     this.blockEngine = blockEngine;
     this.texture = texture;
     this.region = region;
 }
Пример #6
0
 public DynamicVertexBufferTag(BlockEngine blockEngine, int texture, int region)
 {
     this.blockEngine = blockEngine;
     this.texture     = texture;
     this.region      = region;
 }
Пример #7
0
        bool colorDirection = true; //increases when true

        #endregion Fields

        #region Constructors

        public PropertyBag(InfiniminerGame gameInstance)
        {
            // Initialize our network device.
            NetConfiguration netConfig = new NetConfiguration("InfiniminerPlus");

            netClient = new NetClient(netConfig);
            netClient.SetMessageTypeEnabled(NetMessageType.ConnectionRejected, true);

            //netClient.SimulatedMinimumLatency = 0.5f;
            //netClient.SimulatedLatencyVariance = 0.1f;
            //netClient.SimulatedLoss = 0.2f;
            //netClient.SimulatedDuplicates = 0.1f;
            for (int a = 0; a < 50; a++)
            {
                Content[a] = 0;
            }
            artifactActive = new int[3, 20];

            netClient.Start();

            // Initialize engines.
            blockEngine = new BlockEngine(gameInstance);
            interfaceEngine = new InterfaceEngine(gameInstance);
            playerEngine = new PlayerEngine(gameInstance);
            skyplaneEngine = new SkyplaneEngine(gameInstance);
            particleEngine = new ParticleEngine(gameInstance);
            // Create a camera.
            playerCamera = new Camera(gameInstance.GraphicsDevice);

            UpdateCamera();

            // Load sounds.
            if (!gameInstance.NoSound)
            {
                soundList[InfiniminerSound.DigDirt] = gameInstance.Content.Load<SoundEffect>("sounds/dig-dirt");
                soundList[InfiniminerSound.DigMetal] = gameInstance.Content.Load<SoundEffect>("sounds/dig-metal");
                soundList[InfiniminerSound.Ping] = gameInstance.Content.Load<SoundEffect>("sounds/ping");
                soundList[InfiniminerSound.ConstructionGun] = gameInstance.Content.Load<SoundEffect>("sounds/build");
                soundList[InfiniminerSound.Death] = gameInstance.Content.Load<SoundEffect>("sounds/death");
                soundList[InfiniminerSound.CashDeposit] = gameInstance.Content.Load<SoundEffect>("sounds/cash");
                soundList[InfiniminerSound.ClickHigh] = gameInstance.Content.Load<SoundEffect>("sounds/click-loud");
                soundList[InfiniminerSound.ClickLow] = gameInstance.Content.Load<SoundEffect>("sounds/click-quiet");
                soundList[InfiniminerSound.GroundHit] = gameInstance.Content.Load<SoundEffect>("sounds/hitground");
                soundList[InfiniminerSound.Teleporter] = gameInstance.Content.Load<SoundEffect>("sounds/teleport");
                soundList[InfiniminerSound.Jumpblock] = gameInstance.Content.Load<SoundEffect>("sounds/jumpblock");
                soundList[InfiniminerSound.Explosion] = gameInstance.Content.Load<SoundEffect>("sounds/explosion");
                soundList[InfiniminerSound.RadarHigh] = gameInstance.Content.Load<SoundEffect>("sounds/radar-high");
                soundList[InfiniminerSound.RadarLow] = gameInstance.Content.Load<SoundEffect>("sounds/radar-low");
                soundList[InfiniminerSound.RadarSwitch] = gameInstance.Content.Load<SoundEffect>("sounds/switch");
                soundList[InfiniminerSound.RockFall] = gameInstance.Content.Load<SoundEffect>("sounds/rockfall");
            }
        }
Пример #8
0
        public void UpdateNetwork(GameTime gameTime)
        {
            // Update the server with our status.
            timeSinceLastUpdate += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeSinceLastUpdate > 0.05)
            {
                timeSinceLastUpdate = 0;
                if (CurrentStateType == "Infiniminer.States.MainGameState")
                {
                    propertyBag.SendPlayerUpdate();
                }
            }

            // Recieve messages from the server.
            while ((msgBuffer = propertyBag.netClient.ReadMessage()) != null)
            {
                switch (msgBuffer.MessageType)
                {
                case NetIncomingMessageType.StatusChanged:
                {
                    if (propertyBag.netClient.ConnectionStatus == NetConnectionStatus.RespondedConnect)
                    {
                        anyPacketsReceived = true;
                    }
                    if (propertyBag.netClient.ConnectionStatus == NetConnectionStatus.Disconnected)
                    {
                        anyPacketsReceived = false;
                        try
                        {
                            string[] reason = msgBuffer.ReadString().Split(";".ToCharArray());
                            if (reason.Length < 2 || reason[0] == "VER")
                            {
                                System.Windows.Forms.MessageBox.Show("Error: client/server version incompability!\r\nServer: " + msgBuffer.ReadString() + "\r\nClient: " + Defines.INFINIMINER_VERSION);
                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("Error: you are banned from this server!");
                            }
                        }
                        catch { }
                        ChangeState("Infiniminer.States.ServerBrowserState");
                    }
                }
                break;

                case NetIncomingMessageType.Data:
                {
                    try
                    {
                        InfiniminerMessage dataType = (InfiniminerMessage)msgBuffer.ReadByte();
                        switch (dataType)
                        {
                        // TODO: Replace this entire switch statement with a call to the packet registry
                        case InfiniminerMessage.BlockBulkTransfer:
                        {
                            anyPacketsReceived = true;

                            BlockEngine blockEngine = propertyBag.GetEngine <BlockEngine>("blockEngine");

                            try
                            {
                                //This is either the compression flag or the x coordiante
                                byte isCompressed = msgBuffer.ReadByte();
                                byte x;
                                byte y;

                                //255 was used because it exceeds the map size - of course, bytes won't work anyway if map sizes are allowed to be this big, so this method is a non-issue
                                if (isCompressed == 255)
                                {
                                    var compressed       = msgBuffer.ReadBytes(msgBuffer.LengthBytes - (int)(msgBuffer.Position / 8));
                                    var compressedstream = new System.IO.MemoryStream(compressed);
                                    var decompresser     = new System.IO.Compression.GZipStream(compressedstream, System.IO.Compression.CompressionMode.Decompress);

                                    x = (byte)decompresser.ReadByte();
                                    y = (byte)decompresser.ReadByte();
                                    propertyBag.mapLoadProgress[x, y] = true;
                                    for (byte dy = 0; dy < 16; dy++)
                                    {
                                        for (byte z = 0; z < 64; z++)
                                        {
                                            BlockType blockType = (BlockType)decompresser.ReadByte();
                                            if (blockType != BlockType.None)
                                            {
                                                blockEngine.downloadList[x, y + dy, z] = blockType;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    x = isCompressed;
                                    y = msgBuffer.ReadByte();
                                    propertyBag.mapLoadProgress[x, y] = true;
                                    for (byte dy = 0; dy < 16; dy++)
                                    {
                                        for (byte z = 0; z < 64; z++)
                                        {
                                            BlockType blockType = (BlockType)msgBuffer.ReadByte();
                                            if (blockType != BlockType.None)
                                            {
                                                blockEngine.downloadList[x, y + dy, z] = blockType;
                                            }
                                        }
                                    }
                                }
                                bool downloadComplete = true;
                                for (x = 0; x < 64; x++)
                                {
                                    for (y = 0; y < 64; y += 16)
                                    {
                                        if (propertyBag.mapLoadProgress[x, y] == false)
                                        {
                                            downloadComplete = false;
                                            break;
                                        }
                                    }
                                }
                                if (downloadComplete)
                                {
                                    ChangeState("Infiniminer.States.TeamSelectionState");
                                    if (!NoSound)
                                    {
                                        MediaPlayer.Stop();
                                    }
                                    blockEngine.DownloadComplete();
                                }
                            }
                            catch (Exception e)
                            {
                                Console.OpenStandardError();
                                Console.Error.WriteLine(e.Message);
                                Console.Error.WriteLine(e.StackTrace);
                                Console.Error.Close();
                            }
                        }
                        break;

                        case InfiniminerMessage.SetBeacon:
                        {
                            Vector3    position = msgBuffer.ReadVector3();
                            string     text     = msgBuffer.ReadString();
                            PlayerTeam team     = (PlayerTeam)msgBuffer.ReadByte();

                            if (text == "")
                            {
                                if (propertyBag.BeaconList.ContainsKey(position))
                                {
                                    propertyBag.BeaconList.Remove(position);
                                }
                            }
                            else
                            {
                                Beacon newBeacon = new Beacon();
                                newBeacon.ID   = text;
                                newBeacon.Team = team;
                                propertyBag.BeaconList.Add(position, newBeacon);
                            }
                        }
                        break;

                        case InfiniminerMessage.TriggerConstructionGunAnimation:
                        {
                            propertyBag.PlayerContainer.ConstructionGunAnimation = msgBuffer.ReadFloat();
                            if (propertyBag.PlayerContainer.ConstructionGunAnimation <= -0.1)
                            {
                                propertyBag.PlaySound(InfiniminerSound.RadarSwitch);
                            }
                        }
                        break;

                        case InfiniminerMessage.ResourceUpdate:
                        {
                            // ore, cash, weight, max ore, max weight, team ore, red cash, blue cash, all uint
                            propertyBag.PlayerContainer.PlayerOre       = msgBuffer.ReadUInt32();
                            propertyBag.PlayerContainer.PlayerCash      = msgBuffer.ReadUInt32();
                            propertyBag.PlayerContainer.PlayerWeight    = msgBuffer.ReadUInt32();
                            propertyBag.PlayerContainer.PlayerOreMax    = msgBuffer.ReadUInt32();
                            propertyBag.PlayerContainer.PlayerWeightMax = msgBuffer.ReadUInt32();
                            propertyBag.teamOre      = msgBuffer.ReadUInt32();
                            propertyBag.teamRedCash  = msgBuffer.ReadUInt32();
                            propertyBag.teamBlueCash = msgBuffer.ReadUInt32();
                        }
                        break;

                        case InfiniminerMessage.BlockSet:
                        {
                            BlockEngine blockEngine = propertyBag.GetEngine <BlockEngine>("blockEngine");
                            // x, y, z, type, all bytes
                            byte      x         = msgBuffer.ReadByte();
                            byte      y         = msgBuffer.ReadByte();
                            byte      z         = msgBuffer.ReadByte();
                            BlockType blockType = (BlockType)msgBuffer.ReadByte();
                            if (blockType == BlockType.None)
                            {
                                if (blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
                                {
                                    blockEngine.RemoveBlock(x, y, z);
                                }
                            }
                            else
                            {
                                if (blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
                                {
                                    blockEngine.RemoveBlock(x, y, z);
                                }
                                blockEngine.AddBlock(x, y, z, blockType);
                                CheckForStandingInLava();
                            }
                        }
                        break;

                        case InfiniminerMessage.TriggerExplosion:
                        {
                            Vector3 blockPos = msgBuffer.ReadVector3();

                            // Play the explosion sound.
                            propertyBag.PlaySound(InfiniminerSound.Explosion, blockPos);

                            // Create some particles.
                            propertyBag.GetEngine <ParticleEngine>("particleEngine").CreateExplosionDebris(blockPos);

                            // Figure out what the effect is.
                            float distFromExplosive = (blockPos + 0.5f * Vector3.One - propertyBag.PlayerContainer.PlayerPosition).Length();
                            if (distFromExplosive < 3)
                            {
                                propertyBag.KillPlayer(Defines.deathByExpl);                //"WAS KILLED IN AN EXPLOSION!");
                            }
                            else if (distFromExplosive < 8)
                            {
                                // If we're not in explosion mode, turn it on with the minimum ammount of shakiness.
                                if (propertyBag.screenEffect != ScreenEffect.Explosion)
                                {
                                    propertyBag.screenEffect        = ScreenEffect.Explosion;
                                    propertyBag.screenEffectCounter = 2;
                                }
                                // If this bomb would result in a bigger shake, use its value.
                                propertyBag.screenEffectCounter = Math.Min(propertyBag.screenEffectCounter, (distFromExplosive - 2) / 5);
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerSetTeam:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.Team = (PlayerTeam)msgBuffer.ReadByte();
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerJoined:
                        {
                            uint   playerId    = msgBuffer.ReadUInt32();
                            string playerName  = msgBuffer.ReadString();
                            bool   thisIsMe    = msgBuffer.ReadBoolean();
                            bool   playerAlive = msgBuffer.ReadBoolean();
                            propertyBag.playerList[playerId]            = new Player(null, (Game)this);
                            propertyBag.playerList[playerId].Handle     = playerName;
                            propertyBag.playerList[playerId].ID         = playerId;
                            propertyBag.playerList[playerId].Alive      = playerAlive;
                            propertyBag.playerList[playerId].AltColours = customColours;
                            propertyBag.playerList[playerId].redTeam    = red;
                            propertyBag.playerList[playerId].blueTeam   = blue;
                            if (thisIsMe)
                            {
                                propertyBag.PlayerContainer.PlayerMyId = playerId;
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerLeft:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                propertyBag.playerList.Remove(playerId);
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerDead:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.Alive = false;
                                propertyBag.GetEngine <ParticleEngine>("particleEngine").CreateBloodSplatter(player.Position, player.Team == PlayerTeam.Red ? Color.Red : Color.Blue);
                                if (playerId != propertyBag.PlayerContainer.PlayerMyId)
                                {
                                    propertyBag.PlaySound(InfiniminerSound.Death, player.Position);
                                }
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerAlive:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.Alive = true;
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerUpdate:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.UpdatePosition(msgBuffer.ReadVector3(), gameTime.TotalGameTime.TotalSeconds);
                                player.Heading   = msgBuffer.ReadVector3();
                                player.Tool      = (PlayerTools)msgBuffer.ReadByte();
                                player.UsingTool = msgBuffer.ReadBoolean();
                                player.Score     = (uint)(msgBuffer.ReadUInt16() * 100);
                            }
                        }
                        break;

                        case InfiniminerMessage.GameOver:
                        {
                            propertyBag.teamWinners = (PlayerTeam)msgBuffer.ReadByte();
                        }
                        break;

                        case InfiniminerMessage.ChatMessage:
                        {
                            ChatMessageType chatType   = (ChatMessageType)msgBuffer.ReadByte();
                            string          chatString = Defines.Sanitize(msgBuffer.ReadString());
                            //Time to break it up into multiple lines
                            propertyBag.addChatMessage(chatString, chatType, 10);
                        }
                        break;

                        case InfiniminerMessage.PlayerPing:
                        {
                            uint playerId = (uint)msgBuffer.ReadInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                if (propertyBag.playerList[playerId].Team == propertyBag.PlayerContainer.PlayerTeam)
                                {
                                    propertyBag.playerList[playerId].Ping = 1;
                                    propertyBag.PlaySound(InfiniminerSound.Ping);
                                }
                            }
                        }
                        break;

                        case InfiniminerMessage.PlaySound:
                        {
                            InfiniminerSound sound       = (InfiniminerSound)msgBuffer.ReadByte();
                            bool             hasPosition = msgBuffer.ReadBoolean();
                            if (hasPosition)
                            {
                                Vector3 soundPosition = msgBuffer.ReadVector3();
                                propertyBag.PlaySound(sound, soundPosition);
                            }
                            else
                            {
                                propertyBag.PlaySound(sound);
                            }
                        }
                        break;
                        }
                    }
                    catch { }         //Error in a received message
                }
                break;
                }
            }

            // Make sure our network thread actually gets to run.
            Thread.Sleep(1);
        }