コード例 #1
0
        /// <summary>
        /// Invoke an MmMethod with parameter: Vector3.
        /// </summary>
        /// <param name="mmMethod">MmMethod Identifier - <see cref="MmMethod"/></param>
        /// <param name="param">MmMethod parameter: Vector3.</param>
        /// <param name="metadataBlock">Object defining the routing of
        /// Mmessages through MercuryMessaging Hierarchies. <see cref="MmMetadataBlock"/></param>
        public virtual void MmInvoke(MmMethod mmMethod,
                                     Vector3 param,
                                     MmMetadataBlock metadataBlock = null)
        {
            MmMessage msg = new MmMessageVector3(param, mmMethod, metadataBlock);

            MmInvoke(MmMessageType.MmVector3, msg);
        }
コード例 #2
0
        /// <summary>
        /// Message copy method
        /// </summary>
        /// <returns>Duplicate of MmMessage</returns>
        public override MmMessage Copy()
        {
            MmMessageVector3 newMessage = new MmMessageVector3(this);

            newMessage.value = value;

            return(newMessage);
        }
コード例 #3
0
        /// <summary>
        /// Process a message and send it to the associated object.
        /// </summary>
        /// <param name="netMsg">UNET network message</param>
        public virtual void ReceivedMessage(NetworkMessage netMsg)
        {
            MmMessageType mmMessageType = (MmMessageType)netMsg.msgType;

            try
            {
                switch (mmMessageType)
                {
                case MmMessageType.MmVoid:
                    MmMessage msg = netMsg.ReadMessage <MmMessage>();
                    MmRelayNodes[msg.NetId].MmInvoke(mmMessageType, msg);
                    break;

                case MmMessageType.MmInt:
                    MmMessageInt msgInt = netMsg.ReadMessage <MmMessageInt>();
                    MmRelayNodes[msgInt.NetId].MmInvoke(mmMessageType, msgInt);
                    break;

                case MmMessageType.MmBool:
                    MmMessageBool msgBool = netMsg.ReadMessage <MmMessageBool>();
                    MmRelayNodes[msgBool.NetId].MmInvoke(mmMessageType, msgBool);
                    break;

                case MmMessageType.MmFloat:
                    MmMessageFloat msgFloat = netMsg.ReadMessage <MmMessageFloat>();
                    MmRelayNodes[msgFloat.NetId].MmInvoke(mmMessageType, msgFloat);
                    break;

                case MmMessageType.MmVector3:
                    MmMessageVector3 msgVector3 = netMsg.ReadMessage <MmMessageVector3>();
                    MmRelayNodes[msgVector3.NetId].MmInvoke(mmMessageType, msgVector3);
                    break;

                case MmMessageType.MmVector4:
                    MmMessageVector4 msgVector4 = netMsg.ReadMessage <MmMessageVector4>();
                    MmRelayNodes[msgVector4.NetId].MmInvoke(mmMessageType, msgVector4);
                    break;

                case MmMessageType.MmString:
                    MmMessageString msgString = netMsg.ReadMessage <MmMessageString>();
                    MmRelayNodes[msgString.NetId].MmInvoke(mmMessageType, msgString);
                    break;

                case MmMessageType.MmByteArray:
                    MmMessageByteArray msgByteArray = netMsg.ReadMessage <MmMessageByteArray>();
                    MmRelayNodes[msgByteArray.NetId].MmInvoke(mmMessageType, msgByteArray);
                    break;

                case MmMessageType.MmTransform:
                    MmMessageTransform msgTransform = netMsg.ReadMessage <MmMessageTransform>();
                    MmRelayNodes[msgTransform.NetId].MmInvoke(mmMessageType, msgTransform);
                    break;

                case MmMessageType.MmTransformList:
                    MmMessageTransformList msgTransformList = netMsg.ReadMessage <MmMessageTransformList>();
                    MmRelayNodes[msgTransformList.NetId].MmInvoke(mmMessageType, msgTransformList);
                    break;

                case MmMessageType.MmSerializable:
                    MmMessageSerializable msgSerializable = netMsg.ReadMessage <MmMessageSerializable>();
                    MmRelayNodes[msgSerializable.NetId].MmInvoke(mmMessageType, msgSerializable);
                    break;

                case MmMessageType.MmGameObject:
                    MmMessageGameObject msgGameObject = netMsg.ReadMessage <MmMessageGameObject>();
                    MmRelayNodes[msgGameObject.NetId].MmInvoke(mmMessageType, msgGameObject);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                MmLogger.LogError(e.Message);
            }
        }
コード例 #4
0
 /// <summary>
 /// Duplicate an MmMessage
 /// </summary>
 /// <param name="message">Item to duplicate</param>
 public MmMessageVector3(MmMessageVector3 message) : base(message)
 {
 }
コード例 #5
0
 /// <summary>
 /// Handle MmMethod: MessageVector3
 /// Override this to handle Mercury's Vector3 messages.
 /// </summary>
 /// <param name="message"><see cref="MmMessageVector3"/></param>
 protected virtual void ReceivedMessage(MmMessageVector3 message)
 {
 }
コード例 #6
0
        /// <summary>
        /// Process a message and send it to the associated object.
        /// </summary>
        /// <param name="photonEvent">Photon RaiseEvent message data</param>
        public virtual void ReceivedMessage(EventData photonEvent)
        {
            short eventCode = (short)photonEvent.Code;

            if (eventCode != 1)
            {
                return;
            }
            MmMessageType mmMessageType = (MmMessageType)(eventCode);

            object[]  data = (object[])photonEvent.CustomData;
            MmMessage msg  = new MmMessage();

            msg.Deserialize(data);
            try
            {
                switch (msg.MmMessageType)
                {
                case MmMessageType.MmVoid:
                    MmRelayNode.MmInvoke(msg);
                    break;

                case MmMessageType.MmInt:
                    MmMessageInt msgInt = new MmMessageInt();
                    msgInt.Deserialize(data);
                    MmRelayNode.MmInvoke(msgInt);
                    break;

                case MmMessageType.MmBool:
                    MmMessageBool msgBool = new MmMessageBool();
                    msgBool.Deserialize(data);
                    MmRelayNode.MmInvoke(msgBool);
                    break;

                case MmMessageType.MmFloat:
                    MmMessageFloat msgFloat = new MmMessageFloat();
                    msgFloat.Deserialize(data);
                    MmRelayNode.MmInvoke(msgFloat);
                    break;

                case MmMessageType.MmVector3:
                    MmMessageVector3 msgVector3 = new MmMessageVector3();
                    msgVector3.Deserialize(data);
                    MmRelayNode.MmInvoke(msgVector3);
                    break;

                case MmMessageType.MmVector4:
                    MmMessageVector4 msgVector4 = new MmMessageVector4();
                    msgVector4.Deserialize(data);
                    MmRelayNode.MmInvoke(msgVector4);
                    break;

                case MmMessageType.MmString:
                    MmMessageString msgString = new MmMessageString();
                    msgString.Deserialize(data);
                    MmRelayNode.MmInvoke(msgString);
                    break;

                case MmMessageType.MmByteArray:
                    MmMessageByteArray msgByteArray = new MmMessageByteArray();
                    msgByteArray.Deserialize(data);
                    MmRelayNode.MmInvoke(msgByteArray);
                    break;

                case MmMessageType.MmTransform:
                    MmMessageTransform msgTransform = new MmMessageTransform();
                    msgTransform.Deserialize(data);
                    MmRelayNode.MmInvoke(msgTransform);
                    break;

                case MmMessageType.MmTransformList:
                    MmMessageTransformList msgTransformList = new MmMessageTransformList();
                    msgTransformList.Deserialize(data);
                    MmRelayNode.MmInvoke(msgTransformList);
                    break;

                case MmMessageType.MmSerializable:
                    MmMessageSerializable msgSerializable = new MmMessageSerializable();
                    msgSerializable.Deserialize(data);
                    MmRelayNode.MmInvoke(msgSerializable);
                    break;

                case MmMessageType.MmGameObject:
                    MmMessageGameObject msgGameObject = new MmMessageGameObject();
                    msgGameObject.Deserialize(data);
                    MmRelayNode.MmInvoke(msgGameObject);
                    break;

                default:
                    Debug.Log(eventCode);
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                MmLogger.LogError(e.Message);
            }
        }