示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
 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;
     }
 }
示例#4
0
    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();
        }
    }
示例#5
0
 public AnimationManager.BlowPieceAnimation PopBlowAnimation()
 {
     return(_blowAnimPool.Pop());
 }
示例#6
0
 public AnimationManager.MovePieceAnimation PopMoveAnimation()
 {
     return(_moveAnimPool.Pop());
 }
示例#7
0
 public HexagonMatch PopMatch()
 {
     return(_matchPool.Pop());
 }
示例#8
0
 public HexagonBomb PopBomb()
 {
     return(_bombPool.Pop());
 }
示例#9
0
 public HexagonPiece PopPiece()
 {
     return(_piecePool.Pop());
 }