示例#1
0
 private void ToolStripMenuItem_Infos_Click(object sender, EventArgs e)
 {
     if (WindowManager.ActiveChildrens.FirstOrDefault <Form>((Func <Form, bool>)(f => f.GetType() == typeof(InfosForm))) != null)
     {
         return;
     }
     WindowManager.AddChildrenForm((Form) new InfosForm());
 }
示例#2
0
        private void OnServerDataReceived(object sender, SimpleClient.DataReceivedEventArgs e)
        {
            BigEndianReader bigEndianReader = new BigEndianReader(e.Data.Data);
            NetworkMessage  msg             = MessageReceiver.BuildMessage((uint)e.Data.MessageId.Value, (IDataReader)bigEndianReader);

            if (msg == null)
            {
                this.Send(e.Data, NetworkDestinationEnum.Client);
            }
            else
            {
                switch (msg.MessageId)
                {
                case 1:
                    if (!this.Game)
                    {
                        this.Send(e.Data, NetworkDestinationEnum.Client);
                        this.Window      = new UserForm(this);
                        this.Window.Text = "Nouveau client";
                        WindowManager.AddChildrenForm((Form)this.Window);
                        break;
                    }
                    break;

                case 22:
                    this.Window.Text = ((IdentificationSuccessMessage)msg).Login;
                    this.Send(e.Data, NetworkDestinationEnum.Client);
                    break;

                case 42:
                    SelectedServerDataMessage serverDataMessage = (SelectedServerDataMessage)msg;
                    TicketsManager.RegisterTicket(serverDataMessage.Address, (ushort)serverDataMessage.Ports[0], this.Instance, this.Window);
                    this.Send((NetworkMessage) new SelectedServerDataMessage(serverDataMessage.ServerId, "127.0.0.1", Configuration.GamePort, serverDataMessage.CanCreateNewCharacter, serverDataMessage.Ticket), NetworkDestinationEnum.Client);
                    this.Register = true;
                    break;

                case 101:
                    this.Send((NetworkMessage) new AuthenticationTicketMessage(this.Lang, this.Ticket), NetworkDestinationEnum.Server);
                    break;

                case 153:
                    CharacterSelectedSuccessMessage selectedSuccessMessage = (CharacterSelectedSuccessMessage)msg;
                    UserForm window = this.Window;
                    window.Text = window.Text + " (" + selectedSuccessMessage.Infos.Name + ")";
                    this.Send(e.Data, NetworkDestinationEnum.Client);
                    break;

                case 6253:
                    this.RDM = ((RawDataMessage)msg).Content;
                    this.Window.Button_SaveRDM.Enabled = true;
                    this.Send(e.Data, NetworkDestinationEnum.Client);
                    break;

                case 6469:
                    SelectedServerDataExtendedMessage dataExtendedMessage = (SelectedServerDataExtendedMessage)msg;
                    TicketsManager.RegisterTicket(dataExtendedMessage.Address, (ushort)dataExtendedMessage.Ports[0], this.Instance, this.Window);
                    this.Send((NetworkMessage) new SelectedServerDataExtendedMessage(dataExtendedMessage.ServerId, "127.0.0.1", Configuration.GamePort, dataExtendedMessage.CanCreateNewCharacter, dataExtendedMessage.Ticket, dataExtendedMessage.Servers), NetworkDestinationEnum.Client);
                    this.Register = true;
                    break;

                default:
                    this.Send(e.Data, NetworkDestinationEnum.Client);
                    break;
                }
                this.OnMessageReceived(new SyncClient.MessageReceivedEventArgs(msg, e.Data));
            }
        }