Exemplo n.º 1
0
    void OnInstantiateHologram(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here.
        msg.ReadInt64();

        string modelName   = msg.ReadString();
        string instanceUid = msg.ReadString();

        InstantiateHologram(modelName, new Guid(instanceUid));
    }
Exemplo n.º 2
0
    void OnTexture2DReceived(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here.
        msg.ReadInt64();

        string instanceUid = msg.ReadString();

        if (!ActiveModelsDictionary.ContainsKey(new Guid(instanceUid)))
        {
            return;
        }

        int w = msg.ReadInt32();
        int h = msg.ReadInt32();

        uint len = (uint)msg.ReadInt32();

        byte[] data = new byte[len];

        msg.ReadArray(data, len);

        Texture2D texture = new Texture2D(w, h);

        texture.LoadImage(data);

        GameObject model = ActiveModelsDictionary[new Guid(instanceUid)];

        model.GetComponent <TexturePainter>().SetTexture(texture);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 收到 BeginGame 指令
    /// </summary>
    /// <param name="msg"></param>
    private void BeginGameCommandReceived(UserData userData, NetworkInMessage msg)
    {
        var participantsString = msg.ReadString();

        Participants = JsonUtility.FromJson <Dictionary <string, int> >(participantsString);
        OnParticipantsUpdated();
    }
    //handles command that is coming from the server
    void handleNetworkMessage(NetworkInMessage msg)
    {
        Debug.Log("handle command");
        msg.ReadInt64();                   // important! the id of the message.
        string command = msg.ReadString(); //the messages from the server;

        Debug.Log(command);
    }
Exemplo n.º 5
0
    void OnMessageReceived(NetworkInMessage msg)
    {
        msg.ReadInt64();
        string i = msg.ReadString();

        //  ReceivingString.text = i;
        Debug.Log("Receiving at " + i.ToString());
    }
    //handles command that is coming from the server
    void handleNetworkMessage(NetworkInMessage msg)
    {
        Debug.Log("handle command");
        msg.ReadInt64();                        // important! the id of the message.
        string message = msg.ReadString();
        string command = message.Split('+')[0]; //the messages from the server;

        Debug.Log("Command received - " + command);
        GameObject srf;

        switch (command)
        {
        case "play":
            play = true;
            CustomMessages.Instance.SendNetworkMessage("startedPlaying");
            break;

        case "pause":
            play = false;
            CustomMessages.Instance.SendNetworkMessage("stoppedPlaying");
            break;

        case "nosrfstatic":
        case "nosrfdynamic":
            srf = GameObject.Find("Static base");
            if (srf != null)
            {
                foreach (Renderer r in srf.GetComponentsInChildren <Renderer>())
                {
                    r.enabled = false;
                }
                CustomMessages.Instance.SendNetworkMessage("srfDisabled");
            }
            break;

        case "srfstatic":
        case "srfdynamic":
            srf = GameObject.Find("Static base");
            if (srf != null)
            {
                foreach (Renderer r in srf.GetComponentsInChildren <Renderer>())
                {
                    r.enabled = true;
                }
                CustomMessages.Instance.SendNetworkMessage("srfEnabled");
            }
            break;

        case "totalball":
            totalBall = Convert.ToInt32(message.Split('+')[1]);
            CustomMessages.Instance.SendNetworkMessage("totalBallUpdated");
            break;

        default:
            break;
        }
    }
Exemplo n.º 7
0
        public void ToggleMRIMessageReceived(NetworkInMessage msg)
        {
            msg.ReadInt64();

            string toggledMRI        = msg.ReadString();
            bool   isSectionSelected = msg.ReadByte() == 1;

            MRIManager.Instance.ProcessMRISelectionReceived(toggledMRI, isSectionSelected);
        }
Exemplo n.º 8
0
    public static byte[] ReadIRImageByString(NetworkInMessage msg)
    {
        byte[] tempImage;
        msg.ReadInt64();
        msg.ReadInt32();

        tempImage = System.Convert.FromBase64String(msg.ReadString());

        return(tempImage);
    }
Exemplo n.º 9
0
    private UserData ReadUserData(long userId, NetworkInMessage msg)
    {
        var userData = new UserData();

        userData.Id    = userId;
        userData.Name  = msg.ReadString();
        userData.Score = msg.ReadInt32();

        return(userData);
    }
Exemplo n.º 10
0
        public void ToggleHighlightMessageReceived(NetworkInMessage msg)
        {
            // This reads the user ID which we do not need
            msg.ReadInt64();

            string toggledStructure = msg.ReadString();

            Debug.Log("ToggleHighlight message received for " + this.name + " from " + toggledStructure);
            GameObject.Find(toggledStructure).GetComponent <HighlightAndLabelCommands>().ToggleLockedHighlight();
        }
Exemplo n.º 11
0
    void ToggleMessageReceived(NetworkInMessage msg)
    {
        // This reads the user ID which we do not need
        msg.ReadInt64();

        string s = msg.ReadString();

        Debug.Log("Toggle message was received: '" + s + "'");

        modelNameToTransform[s].GetComponent <HighlightAndLabelCommands>().ToggleLockedHighlight();
    }
 /// <summary>
 /// Called if the annotations have been updated by another participant of the shared session
 /// Reloads the annotations
 /// </summary>
 /// <param name="msg">The network message containing the ID of the sender and the model name</param>
 private void RemoteAnnotationsUpdated(NetworkInMessage msg)
 {
     Debug.Log("Received remote annotations update");
     if (msg.ReadInt64() != SharingStage.Instance.Manager.GetLocalUser().GetID())
     {
         string modelName = msg.ReadString();
         if (modelName == objectInfo.ModelName)
         {
             LoadAnnotations();
         }
     }
 }
Exemplo n.º 13
0
    /// <summary>
    /// Called when a remote user sends a head transform.
    /// </summary>
    /// <param name="msg"></param>
    private void SharedSticky(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        Vector3 StickyPos  = CustomMessages.Instance.ReadVector3(msg);
        string  message    = msg.ReadString();
        int     colorIndex = msg.ReadInt32();

        Debug.Log("colorIndex=" + colorIndex);
        MakeSticky(message, StickyPos, colorIndex);
    }
Exemplo n.º 14
0
    void OnClearPaint(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here.
        msg.ReadInt64();

        string instanceUid = msg.ReadString();

        if (!ActiveModelsDictionary.ContainsKey(new Guid(instanceUid)))
        {
            return;
        }
        ClearPaint(new Guid(instanceUid));
    }
Exemplo n.º 15
0
        private void UpdateTexture(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            string texture = msg.ReadString();

            byte[] b64_bytes = System.Convert.FromBase64String(texture);
            selfTexture = new Texture2D(1, 1);
            selfTexture.LoadImage(b64_bytes);

            GetComponent <Renderer>().material.mainTexture = selfTexture;
        }
Exemplo n.º 16
0
    /// <summary>
    /// 接受到生成物体的命令
    /// </summary>
    /// <param name="msg"></param>
    private void OnSpawnCommandsRecive(NetworkInMessage msg)
    {
        long    userID = msg.ReadInt64();
        XString xs     = msg.ReadString();

        Vector3 pos = CustomMessages.Instance.ReadVector3(msg);
        string  ss  = xs.ToString();

        string[] meg  = ss.Split('/');
        string   name = meg[0];
        string   id   = meg[1];

        AddobjectToWorld(name, id, pos);
    }
Exemplo n.º 17
0
    public void RemoteModelSpawned(NetworkInMessage msg)
    {
        Debug.Log("Received remote model spawn");
        long userId = msg.ReadInt64();

        if (userId != SharingStage.Instance.Manager.GetLocalUser().GetID())
        {
            string           modelName     = msg.ReadString();
            int              localBoxId    = msg.ReadInt32();
            BoundingBoxId    boundingBoxId = new BoundingBoxId(userId, localBoxId);
            Vector3          spawnPosition = CustomMessages.Instance.ReadVector3(msg);
            ModelLoadManager manager       = new ModelLoadManager(spawnPosition, worldAnchor, boundingBoxId, true);
            manager.Load(modelName);
        }
    }
Exemplo n.º 18
0
    /// <summary>
    /// 接受到删除命令
    /// </summary>
    /// <param name="msg"></param>
    private void OnDeletRecive(NetworkInMessage msg)
    {
        long    userID = msg.ReadInt64();
        XString str    = msg.ReadString();
        string  id     = str.ToString();

        if (maps.ContainsKey(id))
        {
            Destroy(maps[id].gameObject);
            maps.Remove(id);
        }
        else
        {
            Debug.Log("<color=red>删除物体错误,不包含该ID::" + id + "</color>");
        }
    }
Exemplo n.º 19
0
    /// <summary>
    /// 接受到位置更新消息
    /// </summary>
    /// <param name="msg"></param>
    private void OnUpdatePosReceive(NetworkInMessage msg)
    {
        long    userID = msg.ReadInt64();
        XString str    = msg.ReadString();
        string  id     = str.ToString();

        if (maps.ContainsKey(id))
        {
            maps[id].localPosition = CustomMessages.Instance.ReadVector3(msg);
            maps[id].localRotation = CustomMessages.Instance.ReadQuaternion(msg);
        }
        else
        {
            Debug.Log("<color=red>不包含该ID::" + id + "</color>");
        }
    }
Exemplo n.º 20
0
    /// <summary>
    /// 接受到颜色更改消息
    /// </summary>
    /// <param name="msg"></param>
    private void OnColorReceive(NetworkInMessage msg)
    {
        Debug.Log("接收到color消息");
        long    userID = msg.ReadInt64();
        XString xs     = msg.ReadString();

        string id = xs.ToString();

        if (maps.ContainsKey(id) && maps[id] != null)
        {
            Vector3 col = CustomMessages.Instance.ReadVector3(msg);

            Color c = new Color(col.x, col.y, col.z);
            maps[id].GetComponentInChildren <MeshRenderer>().material.color = c;
        }
    }
Exemplo n.º 21
0
    void OnPaintUV(NetworkInMessage msg)
    {
        long      userId    = msg.ReadInt64();
        P3D_Brush userBrush = BrushManager.Instance.GetGlobalBrush(userId);

        string instanceUid = msg.ReadString();
        Guid   uid         = new Guid(instanceUid);

        if (!ActiveModelsDictionary.ContainsKey(uid))
        {
            return;
        }
        GameObject model = ActiveModelsDictionary[uid];

        Vector3 uv = Messages.Instance.ReadVector3(msg);

        model.GetComponent <TexturePainter>().PaintUVCoordinates(uv, userBrush);
    }
Exemplo n.º 22
0
    private void OnMessageReceived(NetworkConnection connection, NetworkInMessage msg)
    {
        var    messageType = msg.ReadByte();
        var    userId      = msg.ReadInt64();
        string messageKey  = msg.ReadString();
        var    floatCount  = msg.ReadInt32();

        UnityEngine.Debug.Log($"message type: {messageType}, key:{messageKey}, count:{floatCount}");
        var floats = new List <float>();

        for (var i = 0; i < floatCount; i++)
        {
            floats.Add(msg.ReadFloat());
        }

        var functionToCall = _messageHandlers[(HoloMessageType)messageType];

        functionToCall?.Invoke(userId, messageKey, floats);
    }
Exemplo n.º 23
0
    void OnPaintbucket(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here.
        msg.ReadInt64();

        string instanceUid = msg.ReadString();

        if (!ActiveModelsDictionary.ContainsKey(new Guid(instanceUid)))
        {
            return;
        }
        float r = msg.ReadFloat();
        float g = msg.ReadFloat();
        float b = msg.ReadFloat();
        float a = msg.ReadFloat();

        GameObject model = ActiveModelsDictionary[new Guid(instanceUid)];

        model.GetComponent <TexturePainter>().Paintbucket(new Color(r, g, b, a));
    }
    //handles command that is coming from the server
    void handleNetworkMessage(NetworkInMessage msg)
    {
        msg.ReadInt64();                        // important! the id of the message.
        string message = msg.ReadString().ToString();
        string command = message.Split('+')[0]; //the messages from the server;

        Debug.Log("Command received - " + command);
        switch (command)
        {
        case "gameover":
            gameOver();
            break;

        case "hit":
            System.IO.File.AppendAllText(resourceFile + "-score-" + System.DateTime.Now.Ticks.ToString() + ".txt", message);
            break;

        default:
            break;
        }
    }
Exemplo n.º 25
0
        private void UpdateOverheadText(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            Vector3 overheadPos = CustomMessages.Instance.ReadVector3(msg);

            String overheadStr = msg.ReadString();

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            headInfo.Interjection.transform.localPosition = overheadPos;

            TextMesh tmpTxt = headInfo.Interjection.transform.GetComponent <TextMesh>();

            tmpTxt.text = overheadStr;

            GameObject tmpPlayer = GameObject.Find("Cube");

            headInfo.Interjection.transform.rotation = Quaternion.LookRotation(headInfo.Interjection.transform.position - Camera.main.transform.position);
            //MakeOverheadText(overheadPos, overheadStr);
        }
Exemplo n.º 26
0
    /// <summary>
    /// 接受到操作命令
    /// </summary>
    /// <param name="msg"></param>
    private void OnCommandsRecive(NetworkInMessage msg)
    {
        bool    turnon = true;
        long    userID = msg.ReadInt64();
        XString xs     = msg.ReadString();

        string[] ss = xs.ToString().Split('/');
        Debug.Log("<color=yellow>收到消息::::" + xs.ToString() + "</color>");

        string id = ss[0];

        if (ss.Length == 1)
        {
            //控制命令
            if (acts.ContainsKey(id))
            {
                acts[id]();
            }
            else
            {
                Debug.Log("未注册该命令!!!!!!!!!!");
            }
        }
    }
 public string ReadString1(NetworkInMessage msg)
 {
     return(msg.ReadString());
 }
 void handleStringMessage(NetworkInMessage msg)
 {
     Debug.Log(msg.ReadString());
 }
Exemplo n.º 29
0
 public void TryToReturnIsolatedStructureMessageReceived(NetworkInMessage msg)
 {
     // This reads the user ID which we do not need
     msg.ReadInt64();
     TryToReturnIsolatedStructure(msg.ReadString());
 }
Exemplo n.º 30
0
    public void SetPositionOfGazeMarkerMessageReceived(NetworkInMessage msg)
    {
        msg.ReadInt64();

        PlaceStudentMarker(customMessages.ReadVector3(msg), msg.ReadString());
    }