コード例 #1
0
ファイル: ClientSetup.cs プロジェクト: EBassie/Potato
 /// <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
     };
 }
コード例 #2
0
ファイル: Protocol.cs プロジェクト: EBassie/Potato
        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();
        }
コード例 #3
0
 public IProtocolSetupResult Setup(IProtocolSetup setup)
 {
     return this.SandboxedProtocol != null ? this.SandboxedProtocol.Setup(setup) : null;
 }
コード例 #4
0
 public IProtocolSetupResult Setup(IProtocolSetup setup) {
     return this.OnSetupHandler != null ? this.OnSetupHandler(setup) : null;
 }
コード例 #5
0
ファイル: MockProtocol.cs プロジェクト: EBassie/Potato
        public IProtocolSetupResult Setup(IProtocolSetup setup) {
            this.Options = setup;
            this.Client.Setup(ClientSetup.FromProtocolSetup(setup));

            return new ProtocolSetupResult();
        }
コード例 #6
0
ファイル: TestProtocolEight.cs プロジェクト: EBassie/Potato
 public IProtocolSetupResult Setup(IProtocolSetup setup) {
     throw new NotImplementedException();
 }