コード例 #1
0
ファイル: Client.cs プロジェクト: simpuid/model-viewer
    private void Update()
    {
        if (hudPoint.enable && currentTransform != null)
        {
            hudPoint.SetPoint(currentTransform.TransformPoint(localPos));
        }
        if (client == null)
        {
            return;
        }
        if (!client.Connected)
        {
            Error.ShowError(startScene, "Server Disconnected");
            return;
        }

        Telepathy.Message msg;
        while (client.GetNextMessage(out msg))
        {
            switch (msg.eventType)
            {
            case Telepathy.EventType.Connected:
                break;

            case Telepathy.EventType.Data:
                SetPosition setPosition = DataParser.DeserializeObject <SetPosition>(msg.data);
                if (setPosition != null)
                {
                    process(setPosition);
                    break;
                }
                SetModel setModel = DataParser.DeserializeObject <SetModel>(msg.data);
                if (setModel != null)
                {
                    process(setModel);
                    break;
                }
                FileObject fileObject = DataParser.DeserializeObject <FileObject>(msg.data);
                if (fileObject != null)
                {
                    process(fileObject);
                    break;
                }

                break;

            case Telepathy.EventType.Disconnected:
                Error.ShowError(startScene, "Server Disconnected");
                break;
            }
        }
    }
コード例 #2
0
ファイル: testing.cs プロジェクト: simpuid/model-viewer
    // Start is called before the first frame update
    void Start()
    {
        FileObject file = FileReader.ReadFile("C:\\Users\\Prathamesh\\Desktop\\test\\datafile");

        byte[] bytesArray = DataParser.ObjecttoByteArray <FileObject>(file);
        Debug.Log(bytesArray);
        FileObject obj1 = DataParser.DeserializeObject <FileObject>(bytesArray);

        if (obj1 != null)
        {
            Debug.Log("Success");
            for (int i = 0; i < obj1.names.Length; i++)
            {
                Debug.Log(obj1.names[i]);
            }
        }
    }
コード例 #3
0
    private void Update()
    {
        if (Client.client == null)
        {
            return;
        }
        if (!Client.client.Connected)
        {
            return;
        }
        if (!receiveMessage)
        {
            return;
        }

        Telepathy.Message msg;
        while (receiveMessage && Client.client.GetNextMessage(out msg))
        {
            switch (msg.eventType)
            {
            case Telepathy.EventType.Connected:
                break;

            case Telepathy.EventType.Data:
                FileObject file = DataParser.DeserializeObject <FileObject>(msg.data);
                if (file != null)
                {
                    receiveMessage = false;
                    StartCoroutine(Load(file));
                }
                break;

            case Telepathy.EventType.Disconnected:
                Error.ShowError(startScene, "Server Disconnected");
                break;
            }
        }
    }