Beispiel #1
0
    void HandleRegisterConnection(Socket handler)
    {
        VirtualController virtualController = new VirtualController(UDP_PORT, CONTROLLER_ID);

        virtualControllers.Add(virtualController);

        if (controllerManager != null && controllerManager.AddNewVirtualController(virtualController))
        {
            byte[] portData = BitConverter.GetBytes(Convert.ToUInt16(UDP_PORT));

            MemoryStream memoryStream = new MemoryStream();
            memoryStream.WriteByte((byte)COMMAND.REGISTER_SUCCESS);
            memoryStream.Write(portData, 0, portData.Length);

            handler.Send(memoryStream.ToArray());

            memoryStream.Close();
            UDP_PORT++;
            CONTROLLER_ID++;
        }
        else
        {
            handler.Send(new byte[] { (byte)COMMAND.NO_PORT_AVALAIBLE });
        }
    }