Пример #1
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.WORKER_READY: {
            MasterServerQTClient qtRemoteClient     = (MasterServerQTClient)client;
            WorkerReadyMessage   workerReadyMessage = (WorkerReadyMessage)message;

            qtRemoteClient.remoteType = QTClient.clientType.WORKER_SERVER;
            MasterServerWorker worker = MasterServerManager.instance.workersManager.workers[workerReadyMessage.id];

            RoomInfoMessage roomInfoMessage = new RoomInfoMessage();
            roomInfoMessage.room = worker.room;
            qtRemoteClient.sendMessage(roomInfoMessage);

            worker.onWorkerReady();
            break;
        }

        case QTMessage.type.WORKER_INFO: {
            MasterServerQTClient qtRemoteClient    = (MasterServerQTClient)client;
            WorkerInfoMessage    workerInfoMessage = (WorkerInfoMessage)message;
            MasterServerWorker   worker            = MasterServerManager.instance.workersManager.workers[workerInfoMessage.id];

            worker.room.ip = workerInfoMessage.ip;

            QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Recieved info from Worker(" + worker.room.id + ")...");
            break;
        }
        }
    }
Пример #2
0
    public void onSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (state == componentState.RUNNING && scene.name == ServerSettings.instance.serverScene)
        {
            onServerSceneLoad();

            WorkerServerConnectionsManager workerConnection = (WorkerServerConnectionsManager)connections;
            WorkerReadyMessage             readyMessage     = new WorkerReadyMessage();
            readyMessage.id = room.id;
            workerConnection.masterClient.sendMessage(readyMessage);

            QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Sending worker ready message...");
        }
    }