private void process() throws IOException, InterruptedException {
        if (!handshake()) {
            return;
        }

        int x = (int) (Math.random() * Codes.FIELD_WIDTH);
        int y = (int) (Math.random() * Codes.FIELD_HEIGHT);

        color = RAND.nextInt() & 0x00FFFFFF;

        logger.info("Color is {}", Integer.toHexString(color));

        for (int i = 0; i < snake.length; i++) {
            snake[i] = new Point(x, y);
        }

        canvas.getCells()[y][x] = color;

        while (true) {

            canvas.repaint();

            Thread.sleep(Codes.SLEEP_TIME);

            synchronized (locker) {

                x = snake[0].x;
                y = snake[0].y;

                int[] visibleCells = new int[]{
                        getCell(x, y - 1),
                        getCell(x + 1, y),
                        getCell(x, y + 1),
                        getCell(x - 1, y)
                };
                for (int cell : visibleCells)
                outputStream.write(cell);
                outputStream.flush();


                if (bye()) {
                    return;
                }

                int nextStep = reader.read();

                logger.debug("Snake.process nextStep equals {}", nextStep);

                switch (nextStep) {
                    case 0 : step(x, y - 1);
                        break;
                    case 1 : step(x + 1, y);
                        break;
                    case 2 : step(x, y + 1);
                        break;
                    case 3 : step(x - 1, y);
                        break;
                    default: return;
                }

            }

        }

    }