Example #1
0
 /// <summary>
 /// Creates a ClientSetup object from a protocol setup interface
 /// </summary>
 public static IClientSetup FromProtocolSetup(IProtocolSetup setup)
 {
     return new ClientSetup() {
         Hostname = setup.Hostname,
         Port = setup.Port
     };
 }
Example #2
0
        public virtual IProtocolSetupResult Setup(IProtocolSetup setup)
        {
            this.Options = setup;
            this.Client.Setup(ClientSetup.FromProtocolSetup(setup));

            // Handle client events, most of which are proxies to events we fire.
            this.Client.PacketReceived += (sender, wrapper) => {
                this.PacketDispatcher.Dispatch(wrapper);

                // Alert the deferrer that we have a new packet that's been dispatched
                this.WaitingActions.Mark(wrapper.Packet);

                this.OnClientEvent(ClientEventType.ClientPacketReceived, new ClientEventData() {
                    Packets = new List<IPacket>() {
                        wrapper.Packet
                    }
                });
            };

            this.Client.ConnectionStateChanged += (sender, state) => {
                this.OnClientEvent(ClientEventType.ClientConnectionStateChange);

                this.State.Settings.Current.ConnectionState = state;

                IProtocolStateDifference difference = new ProtocolStateDifference() {
                    Modified = {
                        Settings = this.State.Settings
                    }
                };

                this.ApplyProtocolStateDifference(difference);

                this.OnProtocolEvent(ProtocolEventType.ProtocolSettingsUpdated, difference);

                if (state == ConnectionState.ConnectionReady) {
                    this.Login(this.Options.Password);
                }
            };

            this.Client.PacketSent += (sender, wrapper) => this.OnClientEvent(ClientEventType.ClientPacketSent, new ClientEventData() {
                Packets = new List<IPacket>() {
                    wrapper.Packet
                }
            });

            this.Client.SocketException += (sender, se) => this.OnClientEvent(ClientEventType.ClientSocketException, new ClientEventData() {
                Exceptions = new List<String>() {
                    se.ToString()
                }
            });

            this.Client.ConnectionFailure += (sender, exception) => this.OnClientEvent(ClientEventType.ClientConnectionFailure, new ClientEventData() {
                Exceptions = new List<String>() {
                    exception.ToString()
                }
            });

            return new ProtocolSetupResult();
        }
 public IProtocolSetupResult Setup(IProtocolSetup setup)
 {
     return this.SandboxedProtocol != null ? this.SandboxedProtocol.Setup(setup) : null;
 }
 public IProtocolSetupResult Setup(IProtocolSetup setup) {
     return this.OnSetupHandler != null ? this.OnSetupHandler(setup) : null;
 }
Example #5
0
        public IProtocolSetupResult Setup(IProtocolSetup setup) {
            this.Options = setup;
            this.Client.Setup(ClientSetup.FromProtocolSetup(setup));

            return new ProtocolSetupResult();
        }
Example #6
0
 public IProtocolSetupResult Setup(IProtocolSetup setup) {
     throw new NotImplementedException();
 }