예제 #1
0
파일: Server.cs 프로젝트: gormel/SeaBattle
		private void PackageActions(User user, BasePackage package)
		{
			PackageProcessor.ProcessPackage(user, package).ContinueWith(t =>
			{
				if (t.IsFaulted)
				{
					Console.WriteLine("Error while processing pacage: \r\n" + t.Exception);
				}
			});
		}
예제 #2
0
		public async Task Send(User user, BasePackage package)
		{
			var builder = new StringBuilder();
			mSerializer.Serialize(new StringWriter(builder), package );
			var bytes = Encoding.UTF8.GetBytes(builder.ToString());
			using (await user.Lock.LockAsync())
			{
				await SendBytes(user.Socket, BitConverter.GetBytes(bytes.Length));
				await SendBytes(user.Socket, bytes);
			}
		}
예제 #3
0
		public async Task ProcessPackage(User user, BasePackage pack)
		{
			dynamic p = pack;
			ProcessPackage(user, p);
		}