Example #1
0
        public void ReadMessages()
        {
            try
            {
                bool connected = true;
                do
                {
                    int recebimento = stream.ReadByte();
                    switch (recebimento)
                    {
                    case MessageType.SERVER_INFORMATION:
                        serverInformation = Serializer.DeserializeWithLengthPrefix <ServerInformation>(stream, PrefixStyle.Base128);
                        LoginReturn();
                        break;

                    case MessageType.MAP_RESPONSE:
                        UpdateMap(Serializer.DeserializeWithLengthPrefix <MapResponse>(stream, PrefixStyle.Base128));
                        break;

                    case MessageType.MAP_UPDATE:
                        UpdateMap(Serializer.DeserializeWithLengthPrefix <MapUpdate>(stream, PrefixStyle.Base128));
                        break;

                    case 1:
                        connected = false;
                        break;

                    case -1:
                        connected = false;
                        break;

                    default:
                        Messages.AddLogMessage("Mensagem não tratada. Código =" + recebimento);
                        EmptyMessage message = Serializer.DeserializeWithLengthPrefix <EmptyMessage>(stream, PrefixStyle.Base128);
                        break;
                    }
                } while (connected);
            }
            catch (IOException ex)
            {
                editor.timerConnect.Enabled = false;
                editor.CloseMap();
                MessageBox.Show("Você foi desconectado, seu mapa foi fechado!");
            }
            catch (Exception ex)
            {
                editor.timerConnect.Enabled = false;
                MessageBox.Show("ReadMessages: " + ex.Message);
                editor.CloseMap();
            }
        }
Example #2
0
        public bool CloseMapCommand()
        {
            if (!MapIsLoad())
            {
                return(false);
            }

            bool result = mapeditor.CloseMap();

            if (result)
            {
                mapcreate.Visibility = Visibility.Collapsed;
                mapEditorGrid.Children.Clear();
                startpage.Visibility = Visibility.Visible;
                startpage.LastOpenFIleRefresh();

                mapeditor.Scenario.AllWindowClose();
            }
            SetWindowName();
            return(result);
        }