Example #1
0
        RemoteSceneManager(std::shared_ptr<OSSIA::Device> ptr):
            m_dev{ptr}
        {
            setupGlobal();
            setupListener();
            setupSources();

            on_sourceAdded(new OSSIA::String("ASound"));
            auto node = getNode(m_sourcesListNode, "ASound");

            auto enabled = getNode(node, "enabled");
            enabled->getAddress()->pushValue(new OSSIA::Bool(true));

            auto file = getNode(node, "file");
            file->getAddress()->pushValue(new OSSIA::String("snd1.wav"));

            /*
            new std::thread([&] ()
            {
                while(true)
                {
                    std::this_thread::sleep_for(std::chrono::milliseconds(10));
                    auto pos = m_scene.listener().Position();
                    pos[1] += 5;
                    qDebug() << pos.y();

                    m_scene.listener().Position(pos);
                }
            });
            */
        }
Example #2
0
bool EvtTimeListener::performTriggerAction(EvtContext *c) {
  bool returnval = (*triggerAction)(this, c);
  if(multiFire) {
    // On multifire, setup to receive the event again
    setupListener();
    // On multifire, we shouldn't stop the event chain no matter what, since we are just restarting in this context
    return false;
  } else {
    return returnval;
  }
}
Example #3
0
void answerToClient(AnswerDataSet data) //AnswerDataSet = List<Client*> * list, sf::Mutex * listMutex, int port
{
    sf::TcpListener listener;
    setupListener(&listener, data.port);
    
    
    sf::TcpSocket * acceptSocket; // always keep one allocated
    allocateNewSocket(&acceptSocket);

    while(1)
    {
        data.container->containerMutex->lock();
        bool isFull = (data.container->list->getSize() == data.maxClient);
        data.container->containerMutex->unlock();
        if(isFull)
        {
            while(listenerAccept(&listener,acceptSocket))
            {
                logger.printDebug("Refusing");
                sendFullMessage(acceptSocket);
                acceptSocket->disconnect();
            }
        }
        else
        {
            while(listenerAccept(&listener,acceptSocket))
            {
                prepareClient(data.container,&acceptSocket);
                
                data.container->containerMutex->lock();
                isFull = (data.container->list->getSize() == data.maxClient);
                data.container->containerMutex->unlock();
                if(isFull) // stops accepting if full
                {
                    break;
                }
            }
            
        }    
        

        if(checkStopThreads())
        {
            return;
        }
        
        
        sf::sleep(sf::milliseconds(10));
    }
}
Example #4
0
int main(){
    int pid;
	SOCKET socketfd;
    socklen_t length;
    static struct sockaddr_in clientAddress;

	setLogLevel(LOG_WARN);
	setAppName("WEB");
	setLogToFile(TRUE);

    signal(SIGCHLD, SIG_IGN); /* ignore child death */
	signal(SIGINT,  sigHandler);	// Trap Ctrl-C in case we are running interactively
	signal(SIGTERM, sigHandler);	// Trap termination requests from the system

    readDbConfig();

    listener = setupListener();

    while (1){
        length = sizeof(clientAddress);

        socketfd = accept(listener, (struct sockaddr *) &clientAddress, &length);
   		
        if (socketfd < 0){
            logMsg(LOG_ERR, "accept() returned %d, %s", socketfd, strerror(errno));
        } else {
            pid = fork();
            //TODO drop privs after fork
            if (pid == 0){
             // We are in the child process
                close(listener);
                web(socketfd);

            } else if (pid > 0){
             // We are still in the parent process
                close(socketfd);

            } else {
                logMsg(LOG_ERR, "fork() returned %d, %s", pid, strerror(errno));
                exit(1);
            }
        }
    }

    return 0;
}
void Wormhole3ContinuousOutputs::setup()
{
	setupParams();

	mReceived = vec3(1);
	mCamera.setPerspective(60.0f, getWindowAspectRatio(), 0.1f, 10.f);
	mCamera.lookAt(vec3(0, kEyeDepth, 0), vec3(), vec3(0, 1, 0));

	mShader = gl::GlslProg::create(loadAsset("shaders/wormhole.vert"), loadAsset("shaders/wormhole.frag"));

	auto mesh = gl::VboMesh::create(geom::Torus().center(vec3()).radius(0.5f, 0.49f).subdivisionsAxis(64).subdivisionsHeight(4));
	geom::BufferLayout attribs;
	attribs.append(geom::CUSTOM_0, 4, sizeof(Ring), offsetof(Ring, Tint), 1);
	attribs.append(geom::CUSTOM_1, 3, sizeof(Ring), offsetof(Ring, Position), 1);
	attribs.append(geom::CUSTOM_2, 2, sizeof(Ring), offsetof(Ring, Size), 1);

	mRings.push_back(Ring(Color(1, 0, 0), vec2(mReceived.x, mReceived.y)));
	mData = gl::Vbo::create(GL_ARRAY_BUFFER, mRings, GL_DYNAMIC_DRAW);
	mesh->appendVbo(attribs, mData);

	mDraw = gl::Batch::create(mesh, mShader, { {geom::CUSTOM_0, "i_Tint"},{ geom::CUSTOM_1, "i_Position" },{ geom::CUSTOM_2, "i_Size" } });

	setupListener();
}