当前位置: 首页>>代码示例>>C#>>正文


C# NetState.Dispose方法代码示例

本文整理汇总了C#中Server.Network.NetState.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NetState.Dispose方法的具体用法?C# NetState.Dispose怎么用?C# NetState.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Network.NetState的用法示例。


在下文中一共展示了NetState.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DecodeBundledPacket

        public static void DecodeBundledPacket(NetState state, PacketReader pvSrc)
        {
            int packetID = pvSrc.ReadByte();

            PacketHandler ph = GetHandler(packetID);

            if (ph != null)
            {
                if (ph.Ingame && state.Mobile == null)
                {
                    Utility.PushColor(ConsoleColor.DarkRed);
                    Console.WriteLine("Client: {0}: Sent ingame packet (0xF0x{1:X2}) before having been attached to a mobile", state, packetID);
                    Utility.PopColor();
                    state.Dispose();
                }
                else if (ph.Ingame && state.Mobile.Deleted)
                {
                    state.Dispose();
                }
                else
                {
                    ph.OnReceive(state, pvSrc);
                }
            }
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:25,代码来源:ProtocolExtensions.cs

示例2: RejectNoEncryption

        public void RejectNoEncryption(NetState ns)
        {
            // Log it on the console
            Console.WriteLine("Client: {0}: Unencrypted client detected, disconnected", ns);

            // Send the client the typical "Bad communication" packet and also a sysmessage stating the error
            ns.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, "System", "Unencrypted connections are not allowed on this server."));
            ns.Send(new AccountLoginRej(ALRReason.BadComm));

            // Disconnect the client
            ns.Dispose(true);
        }
开发者ID:zerodowned,项目名称:JustUO-merged-with-EC-Support,代码行数:12,代码来源:Encryption.cs

示例3: DecodeBundledPacket

        public static void DecodeBundledPacket( NetState state, PacketReader pvSrc )
        {
            int packetID = pvSrc.ReadByte();

            PacketHandler ph = GetHandler( packetID );

            if ( ph != null )
            {
                if ( ph.Ingame && state.Mobile == null )
                {
                    log.Warn(String.Format("Client: {0}: Sent ingame packet (0xF0x{1:X2}) before having been attached to a mobile",
                                           state, packetID));
                    state.Dispose();
                }
                else if ( ph.Ingame && state.Mobile.Deleted )
                {
                    state.Dispose();
                }
                else
                {
                    ph.OnReceive( state, pvSrc );
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:24,代码来源:ProtocolExtensions.cs

示例4: DisplayGumpResponse

		public static void DisplayGumpResponse( NetState state, PacketReader pvSrc ) {
			int serial = pvSrc.ReadInt32();
			int typeID = pvSrc.ReadInt32();
			int buttonID = pvSrc.ReadInt32();

			foreach ( Gump gump in state.Gumps ) {
				if ( gump.Serial == serial && gump.TypeID == typeID ) {
					int switchCount = pvSrc.ReadInt32();

					if ( switchCount < 0 || switchCount > gump.m_Switches ) {
						state.WriteConsole( "Invalid gump response, disconnecting..." );
						state.Dispose();
						return;
					}

					int[] switches = new int[switchCount];

					for ( int j = 0; j < switches.Length; ++j )
						switches[j] = pvSrc.ReadInt32();

					int textCount = pvSrc.ReadInt32();

					if ( textCount < 0 || textCount > gump.m_TextEntries ) {
						state.WriteConsole( "Invalid gump response, disconnecting..." );
						state.Dispose();
						return;
					}

					TextRelay[] textEntries = new TextRelay[textCount];

					for ( int j = 0; j < textEntries.Length; ++j ) {
						int entryID = pvSrc.ReadUInt16();
						int textLength = pvSrc.ReadUInt16();

						if ( textLength > 239 ) {
							state.WriteConsole( "Invalid gump response, disconnecting..." );
							state.Dispose();
							return;
						}

						string text = pvSrc.ReadUnicodeStringSafe( textLength );
						textEntries[j] = new TextRelay( entryID, text );
					}

					state.RemoveGump( gump );

					GumpProfile prof = GumpProfile.Acquire( gump.GetType() );

					if ( prof != null ) {
						prof.Start();
					}

					gump.OnResponse( state, new RelayInfo( buttonID, switches, textEntries ) );

					if ( prof != null ) {
						prof.Finish();
					}

					return;
				}
			}

			if ( typeID == 461 ) { // Virtue gump
				int switchCount = pvSrc.ReadInt32();

				if ( buttonID == 1 && switchCount > 0 ) {
					Mobile beheld = World.FindMobile( pvSrc.ReadInt32() );

					if ( beheld != null ) {
						EventSink.InvokeVirtueGumpRequest( new VirtueGumpRequestEventArgs( state.Mobile, beheld ) );
					}
				} else {
					Mobile beheld = World.FindMobile( serial );

					if ( beheld != null ) {
						EventSink.InvokeVirtueItemRequest( new VirtueItemRequestEventArgs( state.Mobile, beheld, buttonID ) );
					}
				}
			}
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:80,代码来源:PacketHandlers.cs

示例5: ExtendedCommand

		public static void ExtendedCommand( NetState state, PacketReader pvSrc )
		{
			int packetID = pvSrc.ReadUInt16();

			PacketHandler ph = GetExtendedHandler( packetID );

			if ( ph != null )
			{
				if ( ph.Ingame && state.Mobile == null )
				{
					Console.WriteLine( "Client: {0}: Sent ingame packet (0xBFx{1:X2}) before having been attached to a mobile", state, packetID );
					state.Dispose();
				}
				else if ( ph.Ingame && state.Mobile.Deleted )
				{
					state.Dispose();
				}
				else
				{
					ph.OnReceive( state, pvSrc );
				}
			}
			else
			{
				pvSrc.Trace( state );
			}
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:27,代码来源:PacketHandlers.cs

示例6: PlayCharacter

		public static void PlayCharacter( NetState state, PacketReader pvSrc )
		{
			pvSrc.ReadInt32(); // 0xEDEDEDED

			/*string name = */pvSrc.ReadString( 30 );

			pvSrc.Seek( 2, SeekOrigin.Current );
			int flags = pvSrc.ReadInt32();
			pvSrc.Seek( 24, SeekOrigin.Current );

			int charSlot = pvSrc.ReadInt32();
			/*int clientIP = */pvSrc.ReadInt32();

			IAccount a = state.Account;

			if ( a == null || charSlot < 0 || charSlot >= a.Length )
			{
				state.Dispose();
			}
			else
			{
				Mobile m = a[charSlot];

				// Check if anyone is using this account
				for ( int i = 0; i < a.Length; ++i )
				{
					Mobile check = a[i];

					if ( check != null && check.Map != Map.Internal && check != m )
					{
						log.InfoFormat("Login: {0}: Account in use", state);
						state.Send( new PopupMessage( PMMessage.CharInWorld ) );
						return;
					}
				}

				if ( m == null )
				{
					state.Dispose();
				}
				else
				{
					if ( m.NetState != null )
						m.NetState.Dispose();

					NetState.ProcessDisposedQueue();

					state.Send( new ClientVersionReq() );

					state.BlockAllPackets = true;

					state.Flags = flags;

					state.Mobile = m;
					m.NetState = state;

					new LoginTimer( state, m ).Start();
				}
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:60,代码来源:PacketHandlers.cs

示例7: AccountLogin

        public static void AccountLogin( NetState state, PacketReader pvSrc )
        {
            if ( state.SentFirstPacket )
            {
                state.Dispose();
                return;
            }

            state.SentFirstPacket = true;

            string username = pvSrc.ReadString( 30 );
            string password = pvSrc.ReadString( 30 );

            AccountLoginEventArgs e = new AccountLoginEventArgs( state, username, password );

            try {
                EventSink.InvokeAccountLogin(e);
            } catch (Exception ex) {
                Console.WriteLine("Exception disarmed in AccountLogin {0}: {1}",
                                  username, ex);
            }

            if ( e.Accepted )
                AccountLogin_ReplyAck( state );
            else
                AccountLogin_ReplyRej( state, e.RejectReason );
        }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:27,代码来源:PacketHandlers.cs

示例8: LoginServerSeed

		public static void LoginServerSeed( NetState state, PacketReader pvSrc )
		{
			state.m_Seed = pvSrc.ReadInt32();
			state.Seeded = true;

			if ( state.m_Seed == 0 )
			{
				Console.WriteLine("Login: {0}: Invalid client detected, disconnecting", state);
				state.Dispose();
				return;
			}

			int clientMaj = pvSrc.ReadInt32();
			int clientMin = pvSrc.ReadInt32();
			int clientRev = pvSrc.ReadInt32();
			int clientPat = pvSrc.ReadInt32();

			state.Version = new ClientVersion( clientMaj, clientMin, clientRev, clientPat );
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:19,代码来源:PacketHandlers.cs

示例9: AccountLogin_ReplyAck

		public static void AccountLogin_ReplyAck( NetState state )
		{
			ServerListEventArgs e = new ServerListEventArgs( state, state.Account );

			EventSink.InvokeServerList( e );

			if ( e.Rejected )
			{
				state.Account = null;
				state.Send( new AccountLoginRej( ALRReason.BadComm ) );
				state.Dispose();
			}
			else
			{
				ServerInfo[] info = e.Servers.ToArray();

				state.ServerInfo = info;

				state.Send( new AccountLoginAck( info ) );
			}
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:21,代码来源:PacketHandlers.cs

示例10: AccountLogin_ReplyAck

		public static void AccountLogin_ReplyAck( NetState state )
		{
			ServerListEventArgs e = new ServerListEventArgs( state, state.Account );

			try {
				EventSink.InvokeServerList(e);
			} catch (Exception ex) {
				log.Fatal("Exception disarmed in ServerList", ex);
				e.Rejected = true;
			}

			if ( e.Rejected )
			{
				state.Account = null;
				state.Send( new AccountLoginRej( ALRReason.BadComm ) );
				state.Dispose();
			}
			else
			{
				ServerInfo[] info = (ServerInfo[])e.Servers.ToArray( typeof( ServerInfo ) );

				state.ServerInfo = info;

				state.Send( new AccountLoginAck( info ) );
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:26,代码来源:PacketHandlers.cs

示例11: GameLogin

		public static void GameLogin( NetState state, PacketReader pvSrc )
		{
			if ( state.SentFirstPacket )
			{
				state.Dispose();
				return;
			}

			state.SentFirstPacket = true;

			int authID = pvSrc.ReadInt32();

			if ( m_AuthIDWindow.ContainsKey( authID ) ) {
				AuthIDPersistence ap = m_AuthIDWindow[authID];
				m_AuthIDWindow.Remove( authID );

				state.Version = ap.Version;
			} else if ( m_ClientVerification ) {
				Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
				state.Dispose();
				return;
			}
			
			if ( state.m_AuthID != 0 && authID != state.m_AuthID )
			{
				Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
				state.Dispose();
				return;
			}
			else if ( state.m_AuthID == 0 && authID != state.m_Seed )
			{
				Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
				state.Dispose();
				return;
			}

			string username = pvSrc.ReadString( 30 );
			string password = pvSrc.ReadString( 30 );

			GameLoginEventArgs e = new GameLoginEventArgs( state, username, password );

			EventSink.InvokeGameLogin( e );

			if ( e.Accepted )
			{
				state.CityInfo = e.CityInfo;
				state.CompressionEnabled = true;

				state.Send( SupportedFeatures.Instantiate( state ) );

				if ( state.NewCharacterList ) {
					state.Send( new CharacterList( state.Account, state.CityInfo ) );
				} else {
					state.Send( new CharacterListOld( state.Account, state.CityInfo ) );
				}
			}
			else
			{
				state.Dispose();
			}
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:61,代码来源:PacketHandlers.cs

示例12: PlayServer

		public static void PlayServer( NetState state, PacketReader pvSrc )
		{
			int index = pvSrc.ReadInt16();
			ServerInfo[] info = state.ServerInfo;
			IAccount a = state.Account;

			if ( info == null || a == null || index < 0 || index >= info.Length )
			{
				state.Dispose();
			}
			else
			{
				ServerInfo si = info[index];

				if (state.Username != null && state.Password != null &&
					Core.Config.Features["quick-local-connect"] &&
					si.Address.ToString() == state.Socket.LocalEndPoint.ToString()) {
					/* local connect to this game server which is
					   login server at the same time: re-use this
					   connection, emulate a GameLogin packet */
					GameLoginInternal(state, state.Username, state.Password, false);
					return;
				}

				// send relay packet to client

				state.m_AuthID = PlayServerAck.m_AuthID = GenerateAuthID();

				state.SentFirstPacket = false;
				state.Send( new PlayServerAck( si ) );
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:32,代码来源:PacketHandlers.cs

示例13: AccountLogin

		public static void AccountLogin( NetState state, PacketReader pvSrc )
		{
			if ( state.SentFirstPacket )
			{
				state.Dispose();
				return;
			}

			state.SentFirstPacket = true;

			string username = pvSrc.ReadString( 30 );
			string password = pvSrc.ReadString( 30 );

			AccountLoginEventArgs e = new AccountLoginEventArgs( state, username, password );

			try {
				EventSink.InvokeAccountLogin(e);
			} catch (Exception ex) {
				log.Fatal(String.Format("Exception disarmed in AccountLogin {0}",
										username), ex);
			}

			if (e.Accepted && Core.Config.Features["quick-local-connect"]) {
				/* we have to remember username+password, because it
				   is required to emulate a GameLogin packet */
				state.Username = username;
				state.Password = password;
			}

			if ( e.Accepted )
				AccountLogin_ReplyAck( state );
			else
				AccountLogin_ReplyRej( state, e.RejectReason );
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:34,代码来源:PacketHandlers.cs

示例14: GameLogin

		public static void GameLogin( NetState state, PacketReader pvSrc )
		{
			if ( state.SentFirstPacket )
			{
				state.Dispose();
				return;
			}

			state.SentFirstPacket = true;

			int authID = pvSrc.ReadInt32();

			if (Core.Config.Login.IgnoreAuthID)
				AddAuthID(authID);

			if ( !IsValidAuthID( authID ) )
			{
				log.WarnFormat("Login: {0}: Invalid client detected, disconnecting", state);
				state.Dispose();
				return;
			}
			else if ( state.m_AuthID != 0 && authID != state.m_AuthID )
			{
				log.WarnFormat("Login: {0}: Invalid client detected, disconnecting", state);
				state.Dispose();
				return;
			}
			else if ( state.m_AuthID == 0 && authID != state.m_Seed )
			{
				log.WarnFormat("Login: {0}: Invalid client detected, disconnecting", state);
				state.Dispose();
				return;
			}

			string username = pvSrc.ReadString( 30 );
			string password = pvSrc.ReadString( 30 );

			GameLoginInternal(state, username, password, true);
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:39,代码来源:PacketHandlers.cs

示例15: GameLoginInternal

		private static void GameLoginInternal(NetState state, string username, string password,
											  bool compressionEnabled)
		{
			GameLoginEventArgs e = new GameLoginEventArgs( state, username, password );

			try {
				EventSink.InvokeGameLogin(e);
			} catch (Exception ex) {
				log.Fatal(String.Format("Exception disarmed in GameLogin {0}",
										username), ex);
			}

			if ( e.Accepted )
			{
				if (state.Account == null) {
					log.ErrorFormat("BUG: GameLogin state.Account==null (username {0})",
									username);
					state.Dispose();
					return;
				}

				state.CityInfo = e.CityInfo;
				state.CompressionEnabled = compressionEnabled;

				if ( Core.AOS )
					state.Send( SupportedFeatures.Instantiate( state.Account ) );

				state.Send( new CharacterList( state.Account, state.CityInfo ) );
			}
			else
			{
				state.Dispose();
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:34,代码来源:PacketHandlers.cs


注:本文中的Server.Network.NetState.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。