本文整理汇总了C#中LeaveReason类的典型用法代码示例。如果您正苦于以下问题:C# LeaveReason类的具体用法?C# LeaveReason怎么用?C# LeaveReason使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LeaveReason类属于命名空间,在下文中一共展示了LeaveReason类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RaiseSessionDisconnectedEvent
internal static void RaiseSessionDisconnectedEvent( [NotNull] Player player, LeaveReason leaveReason )
{
if ( player == null )
throw new ArgumentNullException( "player" );
var h = SessionDisconnected;
if ( h != null )
h( null, new SessionDisconnectedEventArgs( player, leaveReason ) );
}
示例2: IoLoop
void IoLoop()
{
try {
Server.RaiseSessionConnectedEvent( this );
// try to log the player in, otherwise die.
if( !LoginSequence() ) return;
BandwidthUseMode = Info.BandwidthUseMode;
// set up some temp variables
Packet packet = new Packet();
int pollCounter = 0,
pingCounter = 0;
// main i/o loop
while( canSend ) {
int packetsSent = 0;
// detect player disconnect
if( pollCounter > SocketPollInterval ) {
if( !client.Connected ||
(client.Client.Poll( 1000, SelectMode.SelectRead ) && client.Client.Available == 0) ) {
if( Info != null ) {
Logger.Log( LogType.Debug,
"Player.IoLoop: Lost connection to player {0} ({1}).", Name, IP );
} else {
Logger.Log( LogType.Debug,
"Player.IoLoop: Lost connection to unidentified player at {0}.", IP );
}
LeaveReason = LeaveReason.ClientQuit;
return;
}
if( pingCounter > PingInterval ) {
writer.WritePing();
BytesSent++;
pingCounter = 0;
MeasureBandwidthUseRates();
}
pingCounter++;
pollCounter = 0;
if( IsUsingWoM ) {
MessageNowPrefixed( "", "^detail.user=" + InfoCommands.GetCompassString( Position.R ) );
}
}
pollCounter++;
if( DateTime.UtcNow.Subtract( lastMovementUpdate ) > movementUpdateInterval ) {
UpdateVisibleEntities();
lastMovementUpdate = DateTime.UtcNow;
}
// send output to player
while( canSend && packetsSent < Server.MaxSessionPacketsPerTick ) {
if( !priorityOutputQueue.Dequeue( ref packet ) )
if( !outputQueue.Dequeue( ref packet ) ) break;
if( IsDeaf && packet.OpCode == OpCode.Message ) continue;
writer.Write( packet.Data );
BytesSent += packet.Data.Length;
packetsSent++;
if( packet.OpCode == OpCode.Kick ) {
writer.Flush();
if( LeaveReason == LeaveReason.Unknown ) LeaveReason = LeaveReason.Kick;
return;
}
if( DateTime.UtcNow.Subtract( lastMovementUpdate ) > movementUpdateInterval ) {
UpdateVisibleEntities();
lastMovementUpdate = DateTime.UtcNow;
}
}
// check if player needs to change worlds
if( canSend ) {
lock( joinWorldLock ) {
if( forcedWorldToJoin != null ) {
while( priorityOutputQueue.Dequeue( ref packet ) ) {
writer.Write( packet.Data );
BytesSent += packet.Data.Length;
packetsSent++;
if( packet.OpCode == OpCode.Kick ) {
writer.Flush();
if( LeaveReason == LeaveReason.Unknown ) LeaveReason = LeaveReason.Kick;
return;
}
}
if( !JoinWorldNow( forcedWorldToJoin, useWorldSpawn, worldChangeReason ) ) {
Logger.Log( LogType.Warning,
"Player.IoLoop: Player was asked to force-join a world, but it was full." );
KickNow( "World is full.", LeaveReason.ServerFull );
}
forcedWorldToJoin = null;
}
}
if( DateTime.UtcNow.Subtract( lastMovementUpdate ) > movementUpdateInterval ) {
//.........这里部分代码省略.........
示例3: KickSynchronously
internal void KickSynchronously([NotNull] string message, LeaveReason reason) {
if (message == null) throw new ArgumentNullException("message");
lock (kickSyncLock) {
useSyncKick = true;
Kick(message, reason);
}
syncKickWaiter.WaitOne();
Server.UnregisterPlayer(this);
}
示例4: PlayerDisconnectedEventArgs
internal PlayerDisconnectedEventArgs( [NotNull] Player player, LeaveReason leaveReason, bool isFake ) {
if( player == null ) throw new ArgumentNullException( "player" );
Player = player;
LeaveReason = leaveReason;
}
示例5: PlayerKickedEventArgs
internal PlayerKickedEventArgs( [NotNull] Player player, [NotNull] Player kicker, [CanBeNull] string reason,
bool announce, bool recordToPlayerDB, LeaveReason context ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( kicker == null ) throw new ArgumentNullException( "kicker" );
Player = player;
Kicker = kicker;
Reason = reason;
Announce = announce;
RecordToPlayerDB = recordToPlayerDB;
Context = context;
}
示例6: RaisePlayerDisconnectedEvent
static void RaisePlayerDisconnectedEvent( [NotNull] Player player, LeaveReason leaveReason ) {
if( player == null ) throw new ArgumentNullException( "player" );
var h = Disconnected;
if( h != null ) h( null, new PlayerDisconnectedEventArgs( player, leaveReason, false ) );
}
示例7: Kick
/// <summary>
/// Kick (asynchronous). Immediately blocks all client input, but waits
/// until client thread sends the kick packet.
/// </summary>
public void Kick( string message, LeaveReason leaveReason ) {
LeaveReason = leaveReason;
CanReceive = false;
CanQueue = false;
// clear all pending output to be written to client (it won't matter after the kick)
ClearBlockUpdateQueue();
ClearPriorityOutputQueue();
// bypassing Send() because canQueue is false
priorityOutputQueue.Enqueue( PacketWriter.MakeDisconnect( message ) );
}
示例8: KickNow
/// <summary> Kick (synchronous). Immediately sends the kick packet.
/// Can only be used from IoThread (this is not thread-safe). </summary>
void KickNow( [NotNull] string message, LeaveReason leaveReason ) {
if( message == null ) throw new ArgumentNullException( "message" );
if( !Enum.IsDefined( typeof( LeaveReason ), leaveReason ) ) {
throw new ArgumentOutOfRangeException( "leaveReason" );
}
if( Thread.CurrentThread != ioThread ) {
throw new InvalidOperationException( "KickNow may only be called from player's own thread." );
}
State = SessionState.PendingDisconnect;
LeaveReason = leaveReason;
canQueue = false;
canReceive = false;
canSend = false;
SendNow( PacketWriter.MakeDisconnect( message ) );
writer.Flush();
}
示例9: PlayerBeingKickedEventArgs
internal PlayerBeingKickedEventArgs( Player player, Player kicker, string reason, bool isSilent, bool recordToPlayerDB, LeaveReason context )
: base( player, kicker, reason, isSilent, recordToPlayerDB, context ) {
}
示例10: ShowPlayerDisconnectedMsg
static void ShowPlayerDisconnectedMsg([NotNull] Player player, LeaveReason leaveReason)
{
if (player == null) throw new ArgumentNullException("player");
string message = String.Format("{0}&SPlayer {1}&S left the server ({2})",
BoldCode,
player.ClassyName,
(player.usedquit ? player.quitmessage : leaveReason.ToString()));
SendChannelMessage(message);
}
示例11: PlayerBeingKickedEventArgs
internal PlayerBeingKickedEventArgs( [NotNull] Player player, [NotNull] Player kicker, [CanBeNull] string reason,
bool announce, bool recordToPlayerDB, LeaveReason context )
: base( player, kicker, reason, announce, recordToPlayerDB, context ) {
}
示例12: RaiseSessionDisconnectedEvent
internal static void RaiseSessionDisconnectedEvent( Session session, LeaveReason leaveReason ) {
var h = SessionDisconnected;
if( h != null ) h( null, new SessionDisconnectedEventArgs( session, leaveReason ) );
}
示例13: PlayerSendingMessageEventArgs
/*internal static bool RaisePlayerSendingMessageEvent( ChatMessage message ) {
var h = PlayerSendingMessage;
if( h == null ) return false;
var e = new PlayerSendingMessageEventArgs( message );
h( null, e );
return e.Cancel;
}
internal static void RaisePlayerSentMessageEvent( ChatMessage message ) {
var h = PlayerSentMessage;
if( h != null ) h( null, new PlayerSentMessageEventArgs( message ) );
}*/
internal static void RaisePlayerDisconnectedEventArgs( Player player, LeaveReason leaveReason ) {
var h = PlayerDisconnected;
if( h != null ) h( null, new PlayerDisconnectedEventArgs( player, leaveReason ) );
}
示例14: KickNow
/// <summary>
/// Kick (synchronous). Immediately sends the kick packet.
/// Can only be used from IoThread (this is not thread-safe).
/// </summary>
public void KickNow( string message, LeaveReason leaveReason ) {
LeaveReason = leaveReason;
CanQueue = false;
CanReceive = false;
CanSend = false;
SendNow( PacketWriter.MakeDisconnect( message ) );
writer.Flush();
}
示例15: ShowPlayerDisconnectedMsg
static void ShowPlayerDisconnectedMsg([NotNull] Player player, LeaveReason leaveReason) {
if (player == null) throw new ArgumentNullException("player");
string message = String.Format("{0}&S* {1}&S left the server ({2})",
BoldCode,
player.ClassyName,
leaveReason);
SendAction(message);
}