Пример #1
0
    public void spawnObject()
    {
        SyncPositionMessage positionMessage = QTUtils.getSyncPositionMessage(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
        SyncRotationMessage rotationMessage = QTUtils.getSyncRotationMessage(gameObject.transform.rotation.eulerAngles.x, gameObject.transform.rotation.eulerAngles.y, gameObject.transform.rotation.eulerAngles.z);

        ServerQTObject obj = (ServerQTObject)WorkerServerManager.instance.spawnManager.spawnObject(Guid.NewGuid().ToString(), prefabName, positionMessage, rotationMessage);
    }
Пример #2
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.REQUEST_SYNC:
            WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client;

            foreach (ServerQTObject obj in WorkerServerManager.instance.spawnManager.spawnedObjects.Values)
            {
                SpawnMessage spawnMessage = new SpawnMessage();
                spawnMessage.objectID      = obj.objectID;
                spawnMessage.prefabName    = obj.prefabName;
                spawnMessage.spawnPosition = QTUtils.getSyncPositionMessageFromObject(obj);
                spawnMessage.spawnRotation = QTUtils.getSyncRotationMessageFromObject(obj);
                spawnMessage.active        = obj.gameObject.activeSelf;
                qtRemoteClient.sendMessage(spawnMessage);

                foreach (BaseQTObjectComponent comp in obj.objectComponents.Values)
                {
                    comp.serverComponent.syncAllFields();
                }
            }
            break;
        }
    }
Пример #3
0
 public QTMessageLog(int _index, QTMessage _message, BaseQTClient _client)
 {
     index       = _index;
     type        = _message.messageType;
     messageSize = QTUtils.ObjectToByteArray(_message).Length;
     identity    = _client.getIP();
 }
Пример #4
0
        private void OpenMovie()
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new OpenMovieHandler(OpenMovie));
                    return;
                }
                QTControl.URL = this.currentlyPlaying;
                QTControl.SetSizing(QTSizingModeEnum.qtControlFitsMovie, true);
                QTControl.URL = this.currentlyPlaying;
                QTControl.Show();

                this.ClientSize = QTControl.Size;
                this.Height    += toolBar.Height;
            }
            catch (COMException ex)
            {
                QTUtils qtu = new QTUtils();
                Main.ShowExceptiowWindow("Unable to open movie.", ex + Environment.NewLine + qtu.QTErrorFromErrorCode(ex.ErrorCode));
            }
            catch (Exception ex)
            {
                Main.ShowExceptiowWindow("Unable to open movie.", ex.ToString());
            }
        }
Пример #5
0
    public void handleStream()
    {
        while (true)
        {
            try {
                byte[] sizeData       = new byte[4];
                int    sizeBytes      = stream.Read(sizeData, 0, sizeData.Length);
                int    nextPacketSize = BitConverter.ToInt32(sizeData, 0);
                if (nextPacketSize == 0)
                {
                    continue;
                }

                byte[] data  = new byte[nextPacketSize];
                int    bytes = stream.Read(data, 0, data.Length);
                debugRecieved(sizeData, data);
                QTMessage message = QTUtils.ByteArrayToMessage(data);

                qtClient.queuedMessages.Add(message);
            } catch (Exception e) {
                QTDebugger.instance.debugWarning(QTDebugger.debugType.NETWORK, "[" + qtClient.type.ToString() + "_thread] Error while reading the NetworkStream-");
                QTDebugger.instance.debugError(QTDebugger.debugType.NETWORK, e);

                qtClient.closeConnection();
                break;
            }
        }
    }
Пример #6
0
    public void setSyncedField(string fieldName, object fieldValue)
    {
        FieldInfo field = component.GetType().UnderlyingSystemType.GetField(fieldName);

        QTUtils.setCorrectSyncedObject(this, field, fieldValue);

        QTDebugger.instance.debug(QTDebugger.debugType.NETWORK, "Syncing value(" + fieldName + "=" + fieldValue + ")");
    }
Пример #7
0
    public void syncAllParameters()
    {
        foreach (AnimatorControllerParameter parameter in animator.parameters)
        {
            object latestValue = QTUtils.getParameterValueFromAnimator(animator, parameter);

            onParameterChanged(parameter.name, latestValue);
        }
    }
Пример #8
0
    public void checkStart()
    {
        Dictionary <string, string> args = QTUtils.getCommandLineArgs();

        if (args.ContainsKey("-port") && args.ContainsKey("-roomID"))
        {
            WorkerServerManager.instance.room    = new RoomInfo();
            WorkerServerManager.instance.room.id = args["-roomID"];

            WorkerServerManager.instance.setupServer(int.Parse(args["-port"]));
        }
    }
Пример #9
0
    public void processDespawn(string objectID)
    {
        BaseQTObject obj = spawnedObjects[objectID];

        foreach (BaseQTObjectComponent comp in obj.objectComponents.Values)
        {
            comp.CancelInvoke();
        }
        obj.CancelInvoke();

        QTUtils.despawnGameobject(obj.gameObject);
        spawnedObjects.Remove(objectID);
    }
Пример #10
0
    public override BaseQTObject spawnObject(string objectID, string prefabName, SyncPositionMessage spawnPosition, SyncRotationMessage spawnRotation)
    {
        GameObject     obj        = QTUtils.spawnGameobject(AppManager.instance.networkStorage.prefabs.Find(o => o.name == prefabName), spawnPosition, spawnRotation);
        ClientQTObject spawnedObj = obj.AddComponent <ClientQTObject>();

        spawnedObj.objectID   = objectID;
        spawnedObj.prefabName = prefabName;
        processSpawn(spawnedObj);

        QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Spawned " + prefabName + " with ID - " + objectID);

        return(spawnedObj);
    }
Пример #11
0
    public void onParameterChanged(string parameterName, object parameterValue)
    {
        if (parameterValue == null)
        {
            QTDebugger.instance.debugWarning(QTDebugger.debugType.NETWORK, "Setting to null -> " + parameterName);
            return;
        }

        AnimationParameterInfoMessage message = QTUtils.getSyncAnimationMessage(parameterName, parameterValue);

        message.objectID = obj.objectID;
        message.index    = index;
        WorkerServerManager.instance.sendMessageToAllReady(message);

        QTDebugger.instance.debug(QTDebugger.debugType.NETWORK, "Sending sync of value(" + parameterName + "=" + parameterValue + ")");
    }
Пример #12
0
    public void onSyncedFieldChanged(string fieldName, object fieldValue)
    {
        if (fieldValue == null)
        {
            QTDebugger.instance.debugWarning(QTDebugger.debugType.NETWORK, "Setting to null -> " + fieldName);
            return;
        }

        FieldInfoMessage message = QTUtils.getSyncFieldMessage(fieldName, fieldValue);

        message.objectID = component.obj.objectID;
        message.index    = component.index;
        WorkerServerManager.instance.sendMessageToAll(message);

        QTDebugger.instance.debug(QTDebugger.debugType.NETWORK, "Sending sync of value(" + fieldName + "=" + fieldValue + ")");
    }
Пример #13
0
    void Update()
    {
        foreach (KeyCode key in QTUtils.GetEnumList <KeyCode>())
        {
            if (Input.GetKeyDown(key))
            {
                onKeyDown(key);
            }
            else if (Input.GetKeyUp(key))
            {
                onKeyUp(key);
            }
        }

        onUpdate();
    }
Пример #14
0
    public void callNetworkFunction(string functionName, object[] parameters)
    {
        component.callFunction(functionName, parameters);

        List <FieldInfoMessage> parameterMessages = new List <FieldInfoMessage>();

        foreach (object parameter in parameters)
        {
            FieldInfoMessage fieldMessage = QTUtils.getSyncFieldMessage("parameter", parameter);
            parameterMessages.Add(fieldMessage);
        }

        CallFunctionMessage message = new CallFunctionMessage();

        message.objectID     = component.obj.objectID;
        message.index        = component.index;
        message.functionName = functionName;
        message.parameters   = parameterMessages.ToArray();
        WorkerServerManager.instance.sendMessageToAll(message);
    }
Пример #15
0
    public void syncFields()
    {
        foreach (FieldInfo fi in component.GetType().UnderlyingSystemType.GetFields().Where(fi => Attribute.IsDefined(fi, typeof(QTSynced))))
        {
            object latestValue = fi.GetValue(component);

            if (lastFields.ContainsKey(fi.Name) == false)
            {
                lastFields.Add(fi.Name, latestValue);

                onSyncedFieldChanged(fi.Name, lastFields[fi.Name]);
            }
            else if (QTUtils.hasSyncedFieldChanged(this, fi, lastFields[fi.Name]))
            {
                lastFields[fi.Name] = latestValue;

                onSyncedFieldChanged(fi.Name, lastFields[fi.Name]);
            }
        }
    }
Пример #16
0
    public override BaseQTObject spawnObject(string objectID, string prefabName, SyncPositionMessage spawnPosition, SyncRotationMessage spawnRotation)
    {
        GameObject obj = QTUtils.spawnGameobject(AppManager.instance.networkStorage.prefabs.Find(o => o.name == prefabName), spawnPosition, spawnRotation);

        ServerQTObject spawnedObj = obj.AddComponent <ServerQTObject>();

        spawnedObj.objectID   = objectID;
        spawnedObj.prefabName = prefabName;
        processSpawn(spawnedObj);

        SpawnMessage message = new SpawnMessage();

        message.objectID      = spawnedObj.objectID;
        message.prefabName    = prefabName;
        message.spawnPosition = spawnPosition;
        message.spawnRotation = spawnRotation;
        WorkerServerManager.instance.sendMessageToAllReady(message);

        QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Spawned " + prefabName + " with ID - " + objectID);

        return(spawnedObj);
    }
Пример #17
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.INPUT:
            InputMessage inputMessage = (InputMessage)message;

            if (inputMessage.active)
            {
                onClientKeyDown(inputMessage.keyCode);
            }
            else
            {
                onClientKeyUp(inputMessage.keyCode);
            }
            break;

        case QTMessage.type.INPUT_AXIS:
            InputAxisMessage inputAxisMessage = (InputAxisMessage)message;
            updateAxisState(inputAxisMessage.axis, inputAxisMessage.value);
            break;

        case QTMessage.type.VR_ACTION:
            VRActionMessage actionMessage = (VRActionMessage)message;
            updateVRAction(actionMessage.actionName, QTUtils.getValueFromVRActionMessage(actionMessage));
            break;

        case QTMessage.type.SYNC_VR_POSITION:
            SyncVRPositionMessage positionMessage = (SyncVRPositionMessage)message;
            updateVRPosition(positionMessage.source, new Vector3(positionMessage.posX, positionMessage.posY, positionMessage.posZ));
            break;

        case QTMessage.type.SYNC_VR_ROTATION:
            SyncVRRotationMessage rotationMessage = (SyncVRRotationMessage)message;
            updateVRRotation(rotationMessage.source, new Vector3(rotationMessage.rotX, rotationMessage.rotY, rotationMessage.rotZ));
            break;
        }
    }
Пример #18
0
    public void sync()
    {
        if (syncParameters)
        {
            foreach (AnimatorControllerParameter parameter in animator.parameters)
            {
                object latestValue = QTUtils.getParameterValueFromAnimator(animator, parameter);

                if (lastParameters.ContainsKey(parameter.name) == false)
                {
                    lastParameters.Add(parameter.name, latestValue);

                    onParameterChanged(parameter.name, lastParameters[parameter.name]);
                }
                else if (lastParameters[parameter.name].Equals(latestValue) == false)
                {
                    lastParameters[parameter.name] = latestValue;

                    onParameterChanged(parameter.name, lastParameters[parameter.name]);
                }
            }
        }
    }
Пример #19
0
    public void sendMessage(QTMessage message)
    {
        lock (sendLock) {
            try {
                if (client.Connected == false)
                {
                    return;
                }

                byte[] bytes     = QTUtils.MessageToByteArray(message);
                byte[] sizeBytes = BitConverter.GetBytes(bytes.Length);

                try {
                    debugSent(sizeBytes, bytes);

                    thread.stream.Write(sizeBytes, 0, sizeBytes.Length);
                    thread.stream.Write(bytes, 0, bytes.Length);
                } catch (Exception e) {
                    QTDebugger.instance.debugWarning(QTDebugger.debugType.NETWORK, "[" + type + "_base] Error while writing the NetworkStream-");
                    QTDebugger.instance.debugError(QTDebugger.debugType.NETWORK, e);

                    closeConnection();
                }

                var responsableValid = message as QTResponsableMessage;
                if (responsableValid != null)
                {
                    QTResponsableMessage responseMessage = (QTResponsableMessage)message;
                    awaitingResponse.Add(responseMessage.responseID, responseMessage);
                }

                onMessageSent(message);
            } catch (Exception e) {
                Debug.LogWarning(e);
            }
        }
    }
        static void Main(string[] args)
        {
            int arguments = args.Length;
            int i;
            // parse the command-line arguments
            for (i = 0; i < arguments; i++)
            {
                if ((0 == args[i].CompareTo("-i")) && i + 1 < arguments)
                    inFile = args[++i];
                if ((0 == args[i].CompareTo("-o")) && i + 1 < arguments)
                    outFile = args[++i];
                if ((0 == args[i].CompareTo("-codec")) && i + 1 < arguments)
                    codec = args[++i];
                if ((0 == args[i].CompareTo("-promptForSettings")) && i + 1 <= arguments)
                    promptForSettings = true;
                if ((0 == args[i].CompareTo("-saveSettings")) && i + 1 <= arguments)
                {
                    saveSettings = true;
                    saveSettingsFile = args[++i];
                }
                if ((0 == args[i].CompareTo("-loadSettings")) && i + 1 <= arguments)
                {
                    loadSettings = true;
                    loadSettingsFile = args[++i];
                }
            }

            // check for command usage errors
            if (null == inFile || null == outFile || ((promptForSettings == false) && (null == codec))
                || ((saveSettings == true) && (promptForSettings == false)))
            {
                PrintUsage();
                return;
            }

            // create a new Form - the QTControl must be hosted on a Form or Window
            frm = new Form1();

            try
            {
                // retrieve the instance of the QTControl object from the Form
                qtc = frm.QTControl;

                // specify that any errors generated will raise an exception
                qtc.ErrorHandling = (int) QTErrorHandlingOptionsEnum.qtErrorHandlingRaiseException;

                // use a QTEvent handler to display export progress information
                qtc.QTEvent += new AxQTOControlLib._IQTControlEvents_QTEventEventHandler(OnQTEvent);

                // get the source movie for the export operation
                qtc.URL = inFile;
                Console.WriteLine("Input file  : " + inFile);
                Console.WriteLine("Output file : " + outFile);

                if (qtc.Movie != null)
                {
                    // get the QuickTime object from the QTControl
                    QTOLibrary.QTQuickTime qt = qtc.QuickTime;

                    if (qt != null)
                    {
                        // must first add an exporter to the collection
                        if (qt.Exporters.Count == 0)
                            qt.Exporters.Add();

                        // retrieve the QTExporter object from the collection
                        QTExporter qtexp = qt.Exporters[1];

                        if (qtexp != null)
                        {
                            qtexp.SetDataSource(qtc.Movie);
                            // export our movie to specified format
                            // (can be overriden by load settings)
                            qtexp.TypeName = codec;
                            // dont show the progress dialog
                            qtexp.ShowProgressDialog = false;
                            // specify destination file for the export operation
                            qtexp.DestinationFileName = outFile;
                            // optionally load exporter settings from a file if one is specified
                            if (loadSettings)
                            {
                                // first check if settings file actually exists
                                if (File.Exists(loadSettingsFile))
                                {
                                    StreamReader reader = new StreamReader(loadSettingsFile);
                                    CFObject settingsObject = new CFObject();
                                    string xml = reader.ReadToEnd();    // read settings file as an XML string
                                    settingsObject.XML = xml;   // load XML settings string into a CFObject
                                    qtexp.Settings = settingsObject;    // set the XML onto the exporter
                                    reader.Close();
                                    Console.WriteLine("Settings loaded from: " + loadSettingsFile);
                                }
                            }
                            // we'll show the settings dialog if the user asks for it
                            if (promptForSettings)
                            {
                                // show the exporter settings dialog
                                qtexp.ShowSettingsDialog();

                                // Optionally save the exporter settings to a file
                                if (saveSettings)
                                {
                                    StreamWriter writer = new StreamWriter(saveSettingsFile, false);
                                    writer.Write(qtexp.Settings.XML);   // write the settings as XML
                                    writer.Close();
                                    Console.WriteLine("Settings saved to: " + saveSettingsFile);
                                }
                            }
                            // we want export progress events
                            qtexp.EventListeners.Add(QTEventClassesEnum.qtEventClassProgress, QTEventIDsEnum.qtEventExportProgress, 0, 0);

                            Console.WriteLine("Export started...");

                            exportProgress = 0;

                            // do the export!
                            qtexp.BeginExport();

                            Console.WriteLine("\nExport done.");
                        }
                    }
                }
            }
            catch(COMException ex)
            {
                QTUtils qtu = new QTUtils();
                Console.WriteLine("Error occurred: " + ex.ErrorCode.ToString("x") + " " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString());
            }
            qtc.URL = "";
            frm.Dispose();
        }
Пример #21
0
    public void spawnPlayer(BaseQTClient client)
    {
        QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Spawning player for Client(" + client.getIP() + ")...");

        ServerQTObject obj = (ServerQTObject)WorkerServerManager.instance.spawnManager.spawnObject(Guid.NewGuid().ToString(), "Player", QTUtils.getSyncPositionMessage(0f, 3f, 0f), QTUtils.getSyncRotationMessage());

        obj.setServerOwner(client.session.id);

        players.Add(client.session.id, obj);
    }
Пример #22
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.SYNC_POSITION: {
            SyncPositionMessage syncMessage = (SyncPositionMessage)message;
            if (ClientManager.instance.spawnManager.spawnedObjects.ContainsKey(syncMessage.objectID) == false)
            {
                return;
            }

            ClientQTObject clientObject  = (ClientQTObject)ClientManager.instance.spawnManager.spawnedObjects[syncMessage.objectID];
            SyncGameobject syncComponent = (SyncGameobject)clientObject.objectComponents[syncMessage.index];
            syncComponent.syncedPosition = new Vector3(syncMessage.posX, syncMessage.posY, syncMessage.posZ);
            break;
        }

        case QTMessage.type.SYNC_ROTATION: {
            SyncRotationMessage syncMessage = (SyncRotationMessage)message;
            if (ClientManager.instance.spawnManager.spawnedObjects.ContainsKey(syncMessage.objectID) == false)
            {
                return;
            }

            ClientQTObject clientObject  = (ClientQTObject)ClientManager.instance.spawnManager.spawnedObjects[syncMessage.objectID];
            SyncGameobject syncComponent = (SyncGameobject)clientObject.objectComponents[syncMessage.index];
            syncComponent.syncedRotation = new Vector3(syncMessage.rotX, syncMessage.rotY, syncMessage.rotZ);
            break;
        }

        case QTMessage.type.SYNC_ACTIVE: {
            SyncActiveMessage syncMessage = (SyncActiveMessage)message;
            if (ClientManager.instance.spawnManager.spawnedObjects.ContainsKey(syncMessage.objectID) == false)
            {
                return;
            }

            ClientQTObject clientObject  = (ClientQTObject)ClientManager.instance.spawnManager.spawnedObjects[syncMessage.objectID];
            SyncGameobject syncComponent = (SyncGameobject)clientObject.objectComponents[syncMessage.index];
            syncComponent.gameObject.SetActive(syncMessage.value);
            break;
        }

        case QTMessage.type.SYNC_FIELD: {
            FieldInfoMessage syncMessage = (FieldInfoMessage)message;
            if (ClientManager.instance.spawnManager.spawnedObjects.ContainsKey(syncMessage.objectID) == false)
            {
                return;
            }

            ClientQTObject        clientObject = (ClientQTObject)ClientManager.instance.spawnManager.spawnedObjects[syncMessage.objectID];
            BaseQTObjectComponent component    = clientObject.objectComponents[syncMessage.index];

            component.clientComponent.setSyncedField(syncMessage.fieldName, QTUtils.getValueFromSyncFieldMessage(syncMessage));
            break;
        }

        case QTMessage.type.SYNC_ANIMATION: {
            AnimationParameterInfoMessage syncMessage = (AnimationParameterInfoMessage)message;
            if (ClientManager.instance.spawnManager.spawnedObjects.ContainsKey(syncMessage.objectID) == false)
            {
                return;
            }

            ClientQTObject clientObject = (ClientQTObject)ClientManager.instance.spawnManager.spawnedObjects[syncMessage.objectID];
            SyncAnimation  component    = (SyncAnimation)clientObject.objectComponents[syncMessage.index];

            QTUtils.applySyncAnimationMessageToAnimator(component.animator, syncMessage);
            break;
        }

        case QTMessage.type.CALL_FUNCTION: {
            try {
                CallFunctionMessage callMessage = (CallFunctionMessage)message;
                if (ClientManager.instance.spawnManager.spawnedObjects.ContainsKey(callMessage.objectID) == false)
                {
                    return;
                }

                ClientQTObject        clientObject = (ClientQTObject)ClientManager.instance.spawnManager.spawnedObjects[callMessage.objectID];
                BaseQTObjectComponent component    = clientObject.objectComponents[callMessage.index];

                List <object> parameters = new List <object>();
                if (callMessage.parameters != null)
                {
                    foreach (FieldInfoMessage fieldMessage in callMessage.parameters)
                    {
                        parameters.Add(QTUtils.getValueFromSyncFieldMessage(fieldMessage));
                    }
                }

                component.callFunction(callMessage.functionName, parameters.ToArray());
            } catch (Exception e) {
                Debug.LogError(e);
            }
            break;
        }
        }
    }
Пример #23
0
        // Open a movie
        private void OpenMovie(string url)
        {
            string errMsg = "";

            try
            {
                axQTControl1.Sizing = QTSizingModeEnum.qtControlFitsMovie;
                axQTControl1.URL = url;
                axQTControl1.Sizing = QTSizingModeEnum.qtMovieFitsControl;
                addMovieEventListeners(axQTControl1.Movie);
                axQTControl1.Show();
                if (movInfo != null)
                {
                    if (movInfo.Created && movInfo.Visible)
                    {
                        // show movie info. window
                        movInfo.SetInfoMovie(axQTControl1.Movie);
                    }
                }
            }
            catch(COMException ex)
            {
                // catch COM exceptions from QT control
                errMsg = "Error Code: " + ex.ErrorCode.ToString("X") + "\n";
                QTUtils qtu = new QTUtils();
                errMsg += "QT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString();
            }
            catch(Exception ex)
            {
                // catch any exception
                errMsg = ex.ToString();
            }

            if (errMsg != "")
            {
                string msg = "Unable to open movie:\n\n";
                msg += url + "\n\n";
                msg += errMsg;
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #24
0
    public async Task handleRequests()
    {
        while (true)
        {
            HttpListenerContext ctx = await server.GetContextAsync();

            HttpListenerRequest  req  = ctx.Request;
            HttpListenerResponse resp = ctx.Response;
            //loadHTML();

            int    totalRecieved = 0;
            int    totalSent     = 0;
            string html          = htmlData[htmlDataType.INDEX];
            string packetItems   = "";

            List <QTMessageLog> logs = manager.messageLog.GetRange(Mathf.Clamp(manager.messageLog.Count - 100, 0, manager.messageLog.Count), Mathf.Clamp(manager.messageLog.Count, 0, 100));
            logs.Reverse();

            foreach (QTMessageLog log in logs)
            {
                string packetItem = htmlData[htmlDataType.PACKETITEM];
                packetItem = packetItem.Replace("//ID//", log.index.ToString());
                packetItem = packetItem.Replace("//TYPE//", log.type.ToString());
                packetItem = packetItem.Replace("//SIZE//", log.messageSize.ToString() + "B");
                packetItem = packetItem.Replace("//IDENTITY//", log.identity);
                packetItem = packetItem.Replace("//ICON_SRC//", (log.direction == QTMessageLog.messageDirection.CLIENTTOSERVER ? "https://files.catbox.moe/ws9x00.png" : "https://files.catbox.moe/6q6uf1.png"));
                packetItem = packetItem.Replace("//ICON_CLASS//", (log.direction == QTMessageLog.messageDirection.CLIENTTOSERVER ? "packetDir1" : "packetDir2"));

                packetItems += packetItem;
            }

            foreach (QTMessageLog log in manager.messageLog.ToList())
            {
                if (log.direction == QTMessageLog.messageDirection.CLIENTTOSERVER)
                {
                    totalRecieved += log.messageSize;
                }
                else
                {
                    totalSent += log.messageSize;
                }
            }

            string clientItems = "";
            foreach (ServerQTClient client in manager.connections.clients.ToList())
            {
                string clientItem = htmlData[htmlDataType.CLIENTITEM];
                clientItem = clientItem.Replace("//ID//", client.thread.thread.ManagedThreadId.ToString());
                clientItem = clientItem.Replace("//IDENTITY//", ((IPEndPoint)(client.client.Client.RemoteEndPoint)).Address.ToString());
                clientItem = clientItem.Replace("//PING//", client.ping + "ms");

                clientItems += clientItem;
            }

            html = html.Replace("//PACKET_ITEMS//", packetItems);
            html = html.Replace("//CLIENT_ITEMS//", clientItems);

            html = html.Replace("//TOTAL_SENT//", QTUtils.FormatBytes(totalSent));
            html = html.Replace("//TOTAL_RECIEVED//", QTUtils.FormatBytes(totalRecieved));
            html = html.Replace("//TOTAL_MESSAGES//", manager.messageLog.Count.ToString());

            byte[] data = Encoding.UTF8.GetBytes(html);
            resp.ContentType     = "text/html";
            resp.ContentEncoding = Encoding.UTF8;
            resp.ContentLength64 = data.LongLength;

            await resp.OutputStream.WriteAsync(data, 0, data.Length);

            resp.Close();
        }
    }
Пример #25
0
        // Save menu
        private void menuItem2_Click(object sender, System.EventArgs e)
        {
            if (axQTControl1.Movie == null) return;
            if (axQTControl1.URL == "") return;

            saveFileDialog1.FileName = "SavedMovie.mov";

            // ask the user to save the movie file to disk
            if(saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string errMsg = "";

                try
                {
                    // save the movie as self-contained
                    axQTControl1.Movie.SaveSelfContained(saveFileDialog1.FileName,true);
                }
                catch(COMException ex)
                {
                    // catch COM exceptions from QT control
                    errMsg = "Error Code: " + ex.ErrorCode.ToString("X") + "\n";
                    QTUtils qtu = new QTUtils();
                    errMsg += "QT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString();
                }
                catch(Exception ex)
                {
                    // catch any exception
                    errMsg = ex.ToString();
                }
                if (errMsg != "")
                {
                    string msg = "Unable to save movie:\n\n";
                    msg += errMsg;
                    MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #26
0
        // Create a movie from a sequence of images
        private void CreateMovieFromImages(string fileSeqPathName)
        {
            string errMsg = "";

            try
            {
                axQTControl1.Sizing = QTSizingModeEnum.qtControlFitsMovie;

                // create movie from images in our project folder
                axQTControl1.CreateNewMovieFromImages(fileSeqPathName,30,true);
                if (axQTControl1.Movie != null)
                {
                    axQTControl1.Sizing = QTSizingModeEnum.qtMovieFitsControl;
                    // prepare and play the movie
                    axQTControl1.Movie.Preroll();
                    axQTControl1.Movie.Play(1.0);
                }
            }
            catch(COMException ex)
            {
                // catch COM exceptions from QT control
                errMsg = "Error Code: " + ex.ErrorCode.ToString("X") + "\n";
                QTUtils qtu = new QTUtils();
                errMsg += "QT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString();
            }
            catch(Exception ex)
            {
                // catch any exception
                errMsg = ex.ToString();
            }
            if (errMsg != "")
            {
                string msg = "Unable to create movie:\n\n";
                msg += errMsg;
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #27
0
        ///<summary>
        ///This is a command line application that combines video files and exports it.
        ///This application takes two arguments - source folderpath (or text file with a file paths) and destination path.
        ///</summary>
        ///<param name="args"></param>
        static void Main(string[] args)
        {
            //initiate a timer to check the elapsed time
            Stopwatch timer = new Stopwatch();

            timer.Start();


            //retry flag
            bool retry = true;

            while (retry)
            {
                //create a type of quick time
                Type QtType = Type.GetTypeFromProgID("QuickTimePlayerLib.QuickTimePlayerApp");
                //use Activator to create an instance of quicktime
                dynamic qtPlayerApp = Activator.CreateInstance(QtType);


                try
                {
                    string sourcePath = args[0];
                    string destPath   = args[1];

                    Thread.Sleep(5000);

                    //Create two quick timeplayers from the app
                    var qtPlayerSrc = qtPlayerApp.Players[1];
                    qtPlayerApp.Players.Add();
                    var qtPlayerDest = qtPlayerApp.Players(qtPlayerApp.Players.Count);


                    //Create a new empty movie in dest player
                    qtPlayerDest.QTControl.CreateNewMovie(true);

                    //empty list of strings to hold the movie urls
                    List <string> movies = new List <string>();

                    //check for sourcePath as txt file or folder
                    if (sourcePath.EndsWith(".txt"))
                    {
                        using (StreamReader reader = new StreamReader(sourcePath))
                        {
                            string line;

                            while ((line = reader.ReadLine()) != null)
                            {
                                movies.Add(line);
                            }
                        }
                    }
                    else
                    {
                        //get all the .mov files from the souce folder
                        string[] mov_list = Directory.GetFiles(sourcePath, "*.mov");


                        foreach (string file in mov_list)
                        {
                            movies.Add(file);
                        }
                    }

                    int count = 0;

                    //iterate over the files
                    foreach (string mov in movies)
                    {
                        count++;
                        Console.WriteLine("Copying " + mov);

                        char[] charToTrim = { '"', '\'' };

                        if (mov.StartsWith("\"") || mov.StartsWith("'"))
                        {
                            qtPlayerSrc.QTControl.URL = mov.Trim(charToTrim);
                        }
                        else
                        {
                            qtPlayerSrc.QTControl.URL = mov;
                        }

                        //select the whole file to copy
                        if (qtPlayerSrc.QTControl.Movie != null)
                        {
                            qtPlayerSrc.QTControl.Movie.SelectAll();
                        }

                        //Use InsertSegment() to copy the movie over to qtPlayer1
                        qtPlayerDest.QTControl.Movie.InsertSegment(qtPlayerSrc.QTControl.Movie,
                                                                   qtPlayerSrc.QTControl.Movie.SelectionStart,
                                                                   qtPlayerSrc.QTControl.Movie.SelectionEnd,
                                                                   qtPlayerDest.QTControl.Movie.Duration);
                    }

                    Console.WriteLine("Combined " + count + " video files");

                    //Rewind the movie in qtPlayer1 and set the SelectionDuraion to 0
                    qtPlayerDest.QTControl.Movie.Rewind();
                    qtPlayerDest.QTControl.Movie.SelectionDuraion = 0;


                    //Export the destination movie and close the player
                    QTQuickTime qt = new QTQuickTime();
                    qt = qtPlayerDest.QTControl.QuickTime;
                    qt.Exporters.Add();

                    QTExporter exp = qt.Exporters[1];

                    //Define the settings for the exporter - source, destination, type
                    exp.SetDataSource(qtPlayerDest.QTControl.Movie);
                    exp.TypeName            = "QuickTime Movie";
                    exp.DestinationFileName = destPath;


                    //Export begins
                    Console.WriteLine("Exporting...");
                    exp.BeginExport();

                    qtPlayerDest.Close();

                    //Quit QuickTime
                    qtPlayerApp.Quit();
                    Console.WriteLine("Exported to destination: " + destPath);

                    //if execution is successful, set retry flag to false.
                    retry = false;
                }
                catch (COMException ce)
                {
                    string  msg;
                    QTUtils qtu = new QTUtils();

                    msg  = "Error Occurred !";
                    msg += "\nError Code: " + ce.ErrorCode;
                    msg += "\nQT Error Code: " + qtu.QTErrorFromErrorCode(ce.ErrorCode);
                    msg += ce;
                    Console.WriteLine(msg);

                    Console.WriteLine("\nRestarting...");
                    //if execution fails, set retry flag to true
                    retry = true;
                }
            }

            Console.WriteLine("Execution Time: " + timer.Elapsed);
        }
Пример #28
0
    public void spawnPack()
    {
        ServerQTObject spawnedObj = (ServerQTObject)WorkerServerManager.instance.spawnManager.spawnObject(Guid.NewGuid().ToString(), "HealthPack", QTUtils.getSyncPositionMessageFromObject(obj), QTUtils.getSyncRotationMessageFromObject(obj));

        spawnedObject = spawnedObj;
    }
Пример #29
0
        private void OpenMovie()
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new OpenMovieHandler(OpenMovie));
                    return;
                }
                QTControl.URL = this.currentlyPlaying;
                QTControl.SetSizing(QTSizingModeEnum.qtControlFitsMovie, true);
                QTControl.URL = this.currentlyPlaying;
                QTControl.Show();

                this.ClientSize = QTControl.Size;
                this.Height += toolBar.Height;
            }
            catch (COMException ex)
            {
                QTUtils qtu = new QTUtils();
                Main.ShowExceptiowWindow("Unable to open movie.", ex + Environment.NewLine + qtu.QTErrorFromErrorCode(ex.ErrorCode));
            }
            catch (Exception ex)
            {
                Main.ShowExceptiowWindow("Unable to open movie.", ex.ToString());
            }
        }