public static NetworkEvent Map(PacketFlowMessage message)
        {
            switch (message.payloadType)
            {
            case (NODE_ADDED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <NodeAddedEventTransport>(message.payload).ToNetworkEvent());

            case (LINK_ADDED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <LinkAddedEventTransport>(message.payload).ToNetworkEvent());

            case (PACKET_ADDED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PacketAddedEventTransport>(message.payload).ToNetworkEvent());

            case (PACKET_ENQUEUED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PacketEnqueuedEventTransport>(message.payload).ToNetworkEvent());

            case (PORT_ASSIGNED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PortAssignedEventTransport>(message.payload).ToNetworkEvent());

            case (PACKET_TYPE_DIRECTION_CHANGED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PacketTypeDirectionChangedEventTransport>(message.payload).ToNetworkEvent());

            case (PACKET_TRANSMISSION_STARTED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PacketTransmissionStartedEventTransport>(message.payload).ToNetworkEvent());

            case (PACKET_TRANSMISSION_FINISHED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PacketTransmissionFinishedEventTransport>(message.payload).ToNetworkEvent());

            case (PACKET_DEQUEUED_EVENT_TYPE_ID):
                return(JsonUtility.FromJson <PacketDequeuedEventTransport>(message.payload).ToNetworkEvent());

            default:
                throw new NotImplementedException();
            }
        }
        public NetworkCommand Map(PacketFlowMessage message)
        {
            switch ((TransportCommandPayloadType)message.payloadType)
            {
            case TransportCommandPayloadType.AddGatewayNode:                                return(GetCommandForAddGatewayNodePayload(message.payload));

            case TransportCommandPayloadType.AddRouterNode:                                 return(GetCommandForAddRouterNodePayload(message.payload));

            case TransportCommandPayloadType.AddConsumerNode:                               return(GetCommandForAddConsumerNodePayload(message.payload));

            case TransportCommandPayloadType.LinkNodes:                                             return(GetCommandForLinkNodesPayload(message.payload));

            case TransportCommandPayloadType.AddPacket:                                             return(GetCommandForAddPacketPayload(message.payload));

            case TransportCommandPayloadType.IncrementPacketTypeDirection:  return(GetCommandForIncrementPacketTypeDirectionPayload(message.payload));

            case TransportCommandPayloadType.ProcessNodeQueue:                              return(GetCommandForProcessNodeQueuePayload(message.payload));

            default:                                                                                                                throw new System.Exception("Taylor messed up a mapper... maybe. Or someone else made a breaking change. Someone.");
            }
        }
Example #3
0
 public void Dispatch(PacketFlowMessage message)
 {
     Debug.Log("Client received message: " + message.payload);
 }
 public void Dispatch(PacketFlowMessage message)
 {
     Debug.Log(message.payload);
 }