protected override void StartAccept() { _log.Debug($"Started accepting socket"); _listenSocket.Listen(10); SocketAsyncEventArgs acceptEventArg; if (_acceptEventArgsPool.Count > 1) { try { acceptEventArg = _acceptEventArgsPool.Pop(); } catch { acceptEventArg = CreateNewSocketAsyncEventArgs(_acceptEventArgsPool); } } else { acceptEventArg = CreateNewSocketAsyncEventArgs(_acceptEventArgsPool); } _maxConnectedClients.WaitOne(); bool willRaiseEvent = _listenSocket.AcceptAsync(acceptEventArg); if (!willRaiseEvent) { ProcessAccept(acceptEventArg); } }
protected void InitializeCommunicationChannel(Socket socket) { ICommunicationChannel communicationChannel = _communicationChannelsPool.Pop(); Int32 numberOfConnectedSockets = Interlocked.Increment(ref _connectedSockets); _log.Info($"Initializing communication channel for IP {socket.LocalEndPoint}, total concurrent accepted sockets is {numberOfConnectedSockets}"); try { communicationChannel.AcceptSocket(socket); _clientConnectedList.Add(communicationChannel); } catch (Exception ex) { _log.Error($"Failed to accept connection by communication channel", ex); ReleaseClientHandler(communicationChannel); } }
void StartReceive() { try { if (this.socket == null) { return; } SocketAsyncEventArgs arg = socketArgsPool.Pop(); arg.SetBuffer(arg.Buffer, 0, arg.Buffer.Length); if (!socket.ReceiveFromAsync(arg)) { IO_Complete(this, arg); } } catch (ObjectDisposedException) { return; } }
public override void RenderRoom(Room room) { for (int i = 1; i <= 2; i++) { this.ground.Pop(new Vector3(-i, 1)); this.groundFiller.Pop(new Vector3(-i, 0)); this.ground.Pop(new Vector3(room.Width - 1 + i, 1)); this.groundFiller.Pop(new Vector3(room.Width - 1 + i, 0)); } foreach (Tile tile in room.Tiles) { GenericPool pool = room.TileAt(tile.x, tile.y + 1) ? this.groundFiller : this.ground; pool.Pop(new Vector3(tile.x, tile.y)); if (room.Symmetric) { pool.Pop(new Vector3(room.Width - tile.x - 1, tile.y)); } } foreach (Platform platform in room.Platforms) { Vector3 position = new Vector3(platform.start.x - 0.25f, platform.start.y - 0.25f); this.leftPlatform.Pop(position); position.x += 0.5f; for (int x = 0; x < platform.size; x++, position.x += 0.5f) { this.mainPlatform.Pop(position); } this.rightPlaform.Pop(position); // TODO: Symmetric } if (room is MonoRoom) { ((MonoRoom)room).CustomRender(); } }
public AnimationManager.BlowPieceAnimation PopBlowAnimation() { return(_blowAnimPool.Pop()); }
public AnimationManager.MovePieceAnimation PopMoveAnimation() { return(_moveAnimPool.Pop()); }
public HexagonMatch PopMatch() { return(_matchPool.Pop()); }
public HexagonBomb PopBomb() { return(_bombPool.Pop()); }
public HexagonPiece PopPiece() { return(_piecePool.Pop()); }