/// <summary> Closes this <see cref="Connection"/>, sends a <see cref="CloseRequest"/> to the remote <see cref="Connection"/>, and writes all remaining queued <see cref="Packet"/> s to the network (they are received before the <see cref="CloseRequest"/> will be handled). </summary> /// <param name="closeReason"> The reason for the <see cref="Connection"/> closing. </param> /// <param name="callCloseEvent"> If this <see cref="Connection"/> instance should call its <see cref="Connection"/> event. </param> public void Close(CloseReason closeReason, bool callCloseEvent = false) { //Check if this connection is already dead. If so, there is no need to //handle an exception or anything else. if (!IsAlive) { return; } try { Send(new CloseRequest(closeReason)); WriteSubWork(); //Force to write the remaining packets. } catch (Exception exception) { Logger.Log($"Couldn't send a close-message '{closeReason.ToString()}' to the endpoint.", exception, LogLevel.Warning); } // always inform the internal network lib about the lost connection. networkConnectionClosed?.Invoke(closeReason, this); if (callCloseEvent) { connectionClosed?.Invoke(closeReason, this); } // close all sockets (throw an exception during any read or write operation) CloseSocket(); // singal all threads to exit their routine. threadCancellationTokenSource.Cancel(); }
private void appServer_NewSessionClosed(AppSession session, CloseReason aaa) { LogHelper.Log.Info($"服务端 失去 来自客户端的连接" + session.SessionID + aaa.ToString()); var count = appServer.GetAllSessions().Count(); LogHelper.Log.Info("连接数量 " + count); }
//客户端断开 void app_SessionClosed(MySession session, CloseReason value) { this.Dispatcher.BeginInvoke(new Action(() => { txbReceive.AppendText($"客户端{session.SessionID}已断开,原因:{value.ToString()}" + '\n'); })); }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { try { // TraceIn TraceEventSource.Log.TraceIn(); // Trace Open Partition TraceEventSource.Log.ClosePartition(context.EventHubPath, context.ConsumerGroupName, context.Lease.PartitionId, reason.ToString()); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } } catch (Exception ex) { // Trace Exception TraceEventSource.Log.TraceError(ex.Message, ex.InnerException?.Message ?? string.Empty); } finally { // TraceOut TraceEventSource.Log.TraceOut(); } }
/// <summary> /// Closes this <see cref="Connection"/>, sends a <see cref="CloseRequest"/> to the remote <see cref="Connection"/>, /// and writes all remaining queued <see cref="Packet"/>s to the network (they are received before the <see cref="CloseRequest"/> /// will be handled). /// </summary> /// <param name="closeReason">The reason for the <see cref="Connection"/> closing.</param> /// <param name="callCloseEvent">If this <see cref="Connection"/> instance should call its <see cref="Connection"/> event.</param> public void Close(CloseReason closeReason, bool callCloseEvent = false) { //Check if this connection is already dead. If so, there is no need to //handle an exception or anything else. if (!IsAlive) { return; } try { Send(new CloseRequest(closeReason), true); WriteSubWork(); //Force to write the remaining packets. } catch (Exception exception) { Logger.Log($"Couldn't send a close-message '{closeReason.ToString()}' to the endpoint.", exception, LogLevel.Warning); } if (callCloseEvent) { connectionClosed?.Invoke(closeReason, this); } writeStreamThread.AbortSave(); readStreamThread.AbortSave(); invokePacketThread.AbortSave(); CloseSocket(); }
protected override void OnSessionClosed(PlayerSession session, CloseReason reason) { base.OnSessionClosed(session, reason); if (!session.IsLogin) { return; } var package = new G2G_ToGameDisconnect() { Reason = reason.ToString() }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, package); var packageData = ms.ToArray(); var converter = EndianBitConverter.Big; byte[] sendData = new byte[packageData.Length + 4]; converter.CopyBytes((int)CMD_G2G.ToGameDisconnect, sendData, 0); Buffer.BlockCopy(packageData, 0, sendData, 4, packageData.Length); Push2GameServer(session, sendData); } PlayerSession savedSession; ManagedSessionByNetHandle.TryRemove(session.NetHandle, out savedSession); }
private static void OnClosed(WebSocketSession session, CloseReason value) { Log.Info("Device Closed [ ID:" + session.SessionID + " Reason:" + value.ToString() + " ]"); Console.Title = ("Online " + SessionPool.DevicesCount() + " User"); Login.LoginOut(session.UserId); SessionPool.Remove(session); }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { Trace.TraceInformation(string.Format("EventProcessor Shuting Down. Partition '{0}', Reason: '{1}'.", this.partitionContext.Lease.PartitionId, reason.ToString())); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
public Task CloseAsync(PartitionContext context, CloseReason reason) { // signal cancellation for any in progress executions _cts.Cancel(); _logger.LogDebug(GetOperationDetails(context, $"CloseAsync, {reason.ToString()}")); return(Task.CompletedTask); }
void OnClosed(ClientSession session, CloseReason reason) { MainLogger.Info(string.Format("세션 번호 {0} 접속해제: {1}", session.SessionID, reason.ToString())); //TODO:로그인을 성공한 경우라면 게임서버에 통보해야 한다. ClientSessionMgr.ColesdSession(session); }
void OnClosed(ClientSession session, CloseReason reason) { MainLogger.Info(string.Format("세션 번호 {0} 접속해제: {1}", session.SessionID, reason.ToString())); var packet = ServerPacketData.MakeNTFInConnectOrDisConnectClientPacket(false, session.SessionID); Distribute(packet); }
async Task IEventProcessor.CloseAsync(PartitionContext context, CloseReason reason) { Console.WriteLine(string.Format("Processor Shuting Down. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason.ToString())); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { if (!WebJobsHelper.RunAsWebJobs) Console.WriteLine(string.Format("Processor Shuting Down. Partition '{0}', Reason: '{1}'.", partitionContext.Lease.PartitionId, reason.ToString())); if (reason == CloseReason.Shutdown) await context.CheckpointAsync(); }
void OnClosed(NetworkSession session, CloseReason reason) { Console.WriteLine("{0} SessionID {1} DisconnectReason : {2} thdID({3})", session.Address().ToString(), session.SessionID, reason.ToString(), Thread.CurrentThread.ManagedThreadId); // NetServer 내부적으로 관리를 위해 클라이언트 연결종료시점에 필요한 작업 net.OnLeave(session); }
public Task CloseAsync(PartitionContext context, CloseReason reason) { Trace.TraceInformation("Processor Shuting Down. Partition '{0}', Reason: '{1}'.", this.Context.Lease.PartitionId, reason.ToString()); this.IsClosed = true; this.OnProcessorClosed(); return context.CheckpointAsync(); }
void appServer_SessionClosed(ProtocolSession session, CloseReason value) { Console.Write(DateTime.Now.ToString() + " "); Console.WriteLine("断开了 " + session.SessionID + " " + value.ToString()); dic.Remove(session.SessionID); ReceiveController.SessionClose(session.SessionID); testIds.Remove(session.SessionID); }
async Task IEventProcessor.CloseAsync(PartitionContext context, CloseReason reason) { _logger.EventProcessorStopped(reason.ToString(), context.EventHubPath, context.ConsumerGroupName, context.Lease.PartitionId, context.Lease.Offset, context.Lease.Epoch); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); _logger.EventProcessorCheckpointed(context.EventHubPath, context.ConsumerGroupName, context.Lease.PartitionId, context.Lease.Offset, context.Lease.Epoch); } }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { Trace.TraceWarning("SimpleEventProcessor CloseAsync. Partition '{0}', Reason: '{1}'.", this.partitionContext.Lease.PartitionId, reason.ToString()); _run = false; if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { Console.WriteLine(string.Format("StorageProcessor closing. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason.ToString())); _account = null; if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
void OnClosed(ClientSession session, CloseReason reason) { WriteLog(string.Format("세션 번호 {0} 접속해제: {1}", session.SessionID, reason.ToString()), LOG_LEVEL.INFO); var packet = ServerPacketData.MakeNTFInConnectOrDisConnectClientPacket(false, session.SessionID, session.SessionIndex); Distributor.DistributeCommon(false, packet); session.FreeSessionIndex(session.SessionIndex); }
public virtual async Task CloseAsync(PartitionContext context, CloseReason reason) { Trace.WriteLine(string.Format("Processor Shuting Down. Partition '{0}', Reason: '{1}'." , this.PartitionContext.Lease.PartitionId , reason.ToString())); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
Task IEventProcessor.CloseAsync(PartitionContext context, CloseReason reason) { var props = new Dictionary <string, string> { { "Partition", context.Lease.PartitionId }, { "Offset", context.Lease.Offset }, { "Reason", reason.ToString() } }; _logger.LogInformation("EventHubReader/Closed", props); return(Task.FromResult <object>(null)); }
//session关闭到达这里 protected override void OnSessionClosed(CloseReason reason) { this.isSessionAlive = false; Console.WriteLine(TAG + "OnSessionClosed " + reason.ToString()); //如果该session已经链接并且是controlsession,只要session断掉之后 //就进行初始化 if (isSessionOnline && isSessionLogin) { MyAppServer.onSessionClosed(); } base.OnSessionClosed(reason); }
public Task CloseAsync(PartitionContext context, CloseReason reason) { this.telemetry.TrackTrace( $"ClosePartition {context.Lease.PartitionId}: {reason}", SeverityLevel.Information, new Dictionary<string, string> { { "PartitionId", context.Lease.PartitionId }, { "Reason", reason.ToString() } }); this.perfCounters.EventHub_Processors.Decrement(); return Task.FromResult(true); }
public Task CloseAsync(PartitionContext context, CloseReason reason) { this.telemetry.TrackTrace( $"ClosePartition {context.Lease.PartitionId}: {reason}", SeverityLevel.Information, new Dictionary <string, string> { { "PartitionId", context.Lease.PartitionId }, { "Reason", reason.ToString() } }); this.perfCounters.EventHub_Processors.Decrement(); return(Task.FromResult(true)); }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { try { // Trace Open Partition ServiceEventSource.Current.ClosePartition(context.EventHubPath, context.ConsumerGroupName, context.Lease.PartitionId, reason.ToString()); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } } catch (Exception ex) { // Trace Exception ServiceEventSource.Current.Message(ex.Message); } }
protected override void OnSessionClosed(PlayerSession session, CloseReason reason) { base.OnSessionClosed(session, reason); var package = new G2G_ToGameDisconnect() { Reason = reason.ToString() }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, package); var packageData = ms.ToArray(); var converter = EndianBitConverter.Big; byte[] sendData = new byte[packageData.Length + 4]; converter.CopyBytes((int)CMD_G2G.ToGameDisconnect, sendData, 0); Buffer.BlockCopy(packageData, 0, sendData, 4, packageData.Length); Push2GameServer(session, sendData); } #if Log Console.WriteLine("{0}:one session close", DateTime.Now); #endif }
static void appServer_SessionClosed(WebSocketSession session, CloseReason reason) { Console.WriteLine("Somebody left " + reason.ToString()); }
static void wsServer_SessionClosed(WebSocketSession session, CloseReason value) { Console.WriteLine("wsServer_SessionClosed. SessionCount=[" + session.AppServer.SessionCount.ToString() + "] CloseReason=[" + value.ToString() + "]"); }
void OnClosed(NetworkSession2 session, CloseReason reason) { DevLog.Write(string.Format("세션 번호 {0} 접속해제: {1}", session.SessionID, reason.ToString()), LOG_LEVEL.INFO); }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { Trace.TraceWarning(string.Format("SimpleVehicleEventConsumer CloseAsync. Partition '{0}', Reason: '{1}'.", this.partitionContext.Lease.PartitionId, reason.ToString())); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
void OnClosed(ClientSession session, CloseReason reason) { MainLogger.Info(string.Format("세션 번호 {0} 접속해제: {1}", session.SessionID, reason.ToString())); }
public async Task CloseAsync(PartitionContext context, CloseReason reason) { Console.WriteLine(string.Format("Processor close. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason.ToString())); if (reason == CloseReason.Shutdown) { await context.CheckpointAsync(); } }
public Task CloseAsync(PartitionContext context, CloseReason reason) { Console.WriteLine(string.Format("EntityProcessor closing. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason.ToString())); return Task.FromResult<object>(null); }
private static void AppServer_SessionClosed(AppSession session, CloseReason value) { Console.WriteLine(string.Format("{0}断开连接", session.SessionID)); session.Send(value.ToString()); }
public async Task CloseAsync(CloseReason reason) { ProcessorEventSource.Log.PartitionPumpCloseStart(this.Host.HostName, this.PartitionContext.PartitionId, reason.ToString()); this.PumpStatus = PartitionPumpStatus.Closing; try { this.cancellationTokenSource.Cancel(); await this.OnClosingAsync(reason).ConfigureAwait(false); if (this.Processor != null) { using (await this.ProcessingAsyncLock.LockAsync().ConfigureAwait(false)) { // When we take the lock, any existing ProcessEventsAsync call has finished. // Because the client has been closed, there will not be any more // calls to onEvents in the future. Therefore we can safely call CloseAsync. ProcessorEventSource.Log.PartitionPumpInvokeProcessorCloseStart(this.Host.HostName, this.PartitionContext.PartitionId, reason.ToString()); await this.Processor.CloseAsync(this.PartitionContext, reason).ConfigureAwait(false); ProcessorEventSource.Log.PartitionPumpInvokeProcessorCloseStop(this.Host.HostName, this.PartitionContext.PartitionId); } } } catch (Exception e) { ProcessorEventSource.Log.PartitionPumpCloseError(this.Host.HostName, this.PartitionContext.PartitionId, e.ToString()); // If closing the processor has failed, the state of the processor is suspect. // Report the failure to the general error handler instead. this.Host.EventProcessorOptions.NotifyOfException(this.Host.HostName, this.PartitionContext.PartitionId, e, "Closing Event Processor"); } if (reason != CloseReason.LeaseLost) { // Since this pump is dead, release the lease. try { await this.Host.LeaseManager.ReleaseLeaseAsync(this.PartitionContext.Lease).ConfigureAwait(false); } catch (Exception e) { // Log and ignore any failure since expired lease will be picked by another host. this.Host.EventProcessorOptions.NotifyOfException(this.Host.HostName, this.PartitionContext.PartitionId, e, EventProcessorHostActionStrings.ReleasingLease); } } this.PumpStatus = PartitionPumpStatus.Closed; ProcessorEventSource.Log.PartitionPumpCloseStop(this.Host.HostName, this.PartitionContext.PartitionId); }
// Websocket server events private void _appServer_SessionClosed(WebSocketSession session, CloseReason reason) { // Stop keepalive message timer KeepAliveDMYMsgTimer keepaliveMsgTimer = (KeepAliveDMYMsgTimer)session.Items["KeepAliveTimer"]; keepaliveMsgTimer.Stop(); IPAddress destinationAddress = session.RemoteEndPoint.Address; logger.Info("Session closed from : " + destinationAddress.ToString() + " Reason :" + reason.ToString()); }
public void OnDisconnect(WebSocketSession session, CloseReason reason) { string address = session.RemoteEndPoint.Address + ":" + session.RemoteEndPoint.Port; Player toRemove = GetPlayerByIP (address); if (toRemove != null) { //Did the player get as far as logging in? MainGame.entityHandler.RemoveEnt (toRemove); Logger.LogMsg (toRemove.name + " disconnected from the server. Reason " + reason.ToString ()); } }
public Task CloseAsync(PartitionContext context, CloseReason reason) { Console.WriteLine(string.Format("EntityProcessor closing. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason.ToString())); return(Task.FromResult <object>(null)); }
private static void MyServer_SessionClosed(MySession session, CloseReason closeReason) { var count = session.AppServer.SessionCount; LogHelper.Log.Info($"服务端 失去 来自客户端的连接,sessionID:" + session.SessionID + " closeReason:" + closeReason.ToString() + " count:" + count); }