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


C# Internals.Send方法代码示例

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


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

示例1: HandleClient

		/// <summary>
		/// Obsługa normalnego działania.
		/// </summary>
		/// <param name="client"></param>
		private void HandleClient(Internals.ServerClient client)
		{
			if (DateTime.Now - client.LastAction > this.MaxClientIdleTime)
			{
				client.Send(new Message(MessageType.TimeOut, null));
				client.CloseSocket();
				client.Status = ClientStatus.NotResponding;
				Logger.Info("Client {0}:{1} - connection closed, client is not responding", client.RemoteEndpoint.Address, client.RemoteEndpoint.Port);
			}
			else
			{
				client.Receive();
			}
		}
开发者ID:jakubfijalkowski,项目名称:Kingdoms-Clash.NET,代码行数:18,代码来源:TcpServer.cs

示例2: HandleWelcomeSequence

		/// <summary>
		/// Obsługa sekwencji powitalnej.
		/// </summary>
		/// <param name="client"></param>
		/// <param name="i"></param>
		private void HandleWelcomeSequence(Internals.ServerClient client, ref int i)
		{
			client.Receive();
			if (client.Messages.Count > 0)
			{
				if (client.Messages[0].Type == MessageType.Welcome) //Odebraliśmy wiadomość powitalną
				{
					Messages.ClientWelcome msg;
					try
					{
						msg = new Messages.ClientWelcome(client.Messages[0]);
					}
					catch //Błędna
					{
						client.Send(new Message(MessageType.InvalidSequence, null));
						client.CloseSocket();
						Logger.Info("Client {0}:{1} rejected, reason: invalid welcome sequence", client.RemoteEndpoint.Address, client.RemoteEndpoint.Port);
						this._ClientsCollection.RemoveAt(i--);
						return;
					}
					client.Messages.RemoveAt(0);
					if (msg.Version == this.Version) //Wszystko ok
					{
						client.Send(new Message(MessageType.AllOk, null));
						client.Status = ClientStatus.Ok;
						Logger.Info("Client {0}:{1} - welcome sequence went well", client.RemoteEndpoint.Address, client.RemoteEndpoint.Port);
					}
					else //Niepoprawna wersja
					{
						client.Send(new Message(MessageType.IncompatibleVersion, null));
						client.CloseSocket();
						Logger.Info("Client {0}:{1} rejected, reason: incompatible version", client.RemoteEndpoint.Address, client.RemoteEndpoint.Port);
						this._ClientsCollection.RemoveAt(i--);
					}
				}
				else if (client.Messages[0].Type == MessageType.IncompatibleVersion ||
					client.Messages[0].Type == MessageType.InvalidSequence) //Klient ma inną wersję niż my
				{
					client.CloseSocket();
					Logger.Info("Client {0}:{1} closed the connection, reason: incompatible version", client.RemoteEndpoint.Address, client.RemoteEndpoint.Port);
					this._ClientsCollection.RemoveAt(i--);
				}
				else //Błędna sekwencja ze strony klienta
				{
					client.Send(new Message(MessageType.InvalidSequence, null));
					client.CloseSocket();
					Logger.Info("Client {0}:{1} rejected, reason: invalid welcome sequence", client.RemoteEndpoint.Address, client.RemoteEndpoint.Port);
					this._ClientsCollection.RemoveAt(i--);
				}
			}
		}
开发者ID:jakubfijalkowski,项目名称:Kingdoms-Clash.NET,代码行数:56,代码来源:TcpServer.cs


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