コード例 #1
0
    // PUBLIC METHODS

    public void ConnectVirtualControllerToGame(VirtualControllerHandler virtualControllerHandler)
    {
        this.virtualControllerHandler = virtualControllerHandler;

        UnityThreadHelper.Dispatcher.Dispatch(() => {
            listener = SocketHelper.CreateUDPServer(port, (endPoint, receivedBytes) =>
            {
                HandleGameCommand(receivedBytes);
            });
            UnityThreadHelper.CreateThread(() =>
            {
                IsVirtualControllerAlive();
            });
        });
    }
コード例 #2
0
    // UNITY-MONOBEHAVIOUR STANDARD METHODS

    void Start()
    {
        registerSocket = SocketHelper.CreateTCPServer((int)PORTS.REGISTER, (int)VERSION.SUPPORTED_REGISTER, (handler) => {
            if (SocketHelper.CheckVersion(handler, (int)VERSION.SUPPORTED_REGISTER))
            {
                HandleRegisterConnection(handler);
            }
        });

        pingSocket = SocketHelper.CreateUDPServer((int)PORTS.PING, (endPoint, receivedBytes) => {
            if (SocketHelper.CheckVersion(ref receivedBytes, (int)VERSION.SUPPORTED_PING))
            {
                HandlePingConnection(endPoint);
                AddVirtualControllerIP(endPoint);
            }
        });
    }