Ejemplo n.º 1
0
        public void DownloadAnchor()
        {
            LiveMessageDownload msg = new LiveMessageDownload();

            if (handler != null)
            {
                handler.SendMessage(msg.Serialize(), null);
            }
            waiting       = true;
            waitingString = "Waiting for download anchors...";
        }
Ejemplo n.º 2
0
    public static LiveMessage ParseMessage(byte[] bytes)
    {
        LiveMessage msg = null;

        if (bytes.Length == 0)
        {
            Debug.LogError("Error: Message length=0!");
            return(msg);
        }

        switch (bytes[0])
        {
        case LiveMessageConstant.BEV_MESSAGE_TYPE_START:
            msg = new LiveMessageStart();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_STOP:
            msg = new LiveMessageStop();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_DOWNLOAD_ANCHOR:
            msg = new LiveMessageDownload();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_SET_ANCHOR:
            msg = new LiveMessageSetAnchor();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_SYNCHRONIZE_ALL:
            msg = new LiveMessageSynchronizeAll();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_DOWNLOAD_ANCHOR_FINISH:
            msg = new LiveMessageDownloadFinish();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_SET_ANCHOR_FINISH:
            msg = new LiveMessageSetAnchorFinish();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_SAVE_ANCHOR:
            msg = new LiveMessageSaveAnchor();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_SAVE_ANCHOR_FINISH:
            msg = new LiveMessageSaveAnchorFinish();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_REQUEST_SPATIAL_MAPPING:
            msg = new LiveMessageRequestSpatialMapping();
            break;

        case LiveMessageConstant.BEV_MESSAGE_TYPE_RESPONSE_SPATIAL_MAPPING:
            msg = new LiveMessageResponseSpatialMapping();
            break;

        default:
            Debug.LogError("No such type message!");
            return(msg);
        }

        try
        {
            msg.Deserialize(bytes);
        }
        catch (Exception e)
        {
            msg = null;
            Debug.LogError("Parse Message Error! " + e);
        }

        return(msg);
    }