/// <summary>
		/// Parsuje wiadomość.
		/// </summary>
		/// <param name="msg">Wiadomość.</param>
		public PlayerDisconnected(Message msg)
		{
			if (msg.Type != (MessageType)GameMessageType.PlayerDisconnected)
			{
				throw new InvalidCastException("Cannot convert this message to PlayerDisconnected");
			}
			BinarySerializer s = new BinarySerializer(msg.Data);
			this.UserId = s.GetUInt32();
			this.Reason = (DisconnectionReason)s.GetByte();
		}
Exemplo n.º 2
0
 internal void HandleDisconnection(DisconnectionReason reason)
 {
     if (isConnected)
     {
         var args = new DisconnectionEventArgs(reason);
         if (DisconnectionReason.DeviceRemoved != reason && OnDisconnecting != null)
             OnDisconnecting(this, args);
         if (OnDisconnected != null)
             OnDisconnected(this, args);
         isConnected = false;
     }
 }
		/// <summary>
		/// Tworzy nową wiadomość.
		/// </summary>
		/// <param name="uid">Identyfikator gracza.</param>
		public PlayerDisconnected(uint uid, DisconnectionReason reason)
		{
			this.UserId = uid;
			this.Reason = reason;
		}
Exemplo n.º 4
0
		internal static void OnDisconnected(RUDPSocket rudp, DisconnectionReason reason)
		{
			if (rudp._status == RUDPSocketStatus.Closed)
				return;

			//---- Reset
			rudp._outgoingPacketsLock.EnterWriteLock();
			rudp._outgoingPackets.Clear();
			rudp._outgoingPacketsLock.ExitWriteLock();
			rudp.Reset(RUDPSocketStatus.Closed);

			//---- Notify
			if (reason != DisconnectionReason.ConnectionClosed)
			{
				RUDPSocketError error = RUDPSocketError.ConnectionReset;
				if (reason == DisconnectionReason.SocketError)
					error = RUDPSocketError.SocketError;
				if (reason == DisconnectionReason.TimeOut)
					error = RUDPSocketError.ConnectionReset;

				rudp._physical.OnDisconnected(rudp, error);
			}
		}
		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="Skahal.Infrastructure.Framework.Net.Messaging.DisconnectedEventArgs"/> class.
		/// </summary>
		/// <param name="reason">Reason.</param>
		public DisconnectedEventArgs (DisconnectionReason reason)
		{
			Reason = reason;
		}
Exemplo n.º 6
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Reason = (DisconnectionReason)reader.ReadByte ();
 }
Exemplo n.º 7
0
 public DisconnectMessage(DisconnectionReason reason)
     : this()
 {
     Reason = reason;
 }
Exemplo n.º 8
0
		public async Task DisconnectAsync (IUserInfo user, DisconnectionReason reason)
		{
			if (user == null)
				throw new ArgumentNullException ("user");

			IConnection c = Manager.GetConnection (user);
			if (c == null)
				return;

			Manager.Disconnect (c);

			if (c.IsConnected) {
				await c.SendAsync (new DisconnectMessage (reason)).ConfigureAwait (false);
				await c.DisconnectAsync().ConfigureAwait (false);
			}

			List<Task> tasks = new List<Task>();
			foreach (IConnection connection in Manager.GetConnections())
				tasks.Add (connection.SendAsync (new UserDisconnectedMessage (user.UserId)));

			await Task.WhenAll (tasks).ConfigureAwait (false);
		}