Example #1
0
        // Used for holding enough info to handle receive completion
        internal IncomingMessageAcceptor(MessageCenter msgCtr, IPEndPoint here, SocketDirection socketDirection, MessageFactory messageFactory, SerializationManager serializationManager,
                                         ExecutorService executorService, ILoggerFactory loggerFactory)
            : base(executorService, loggerFactory)
        {
            this.loggerFactory = loggerFactory;
            Log                       = new LoggerWrapper <IncomingMessageAcceptor>(loggerFactory);
            MessageCenter             = msgCtr;
            listenAddress             = here;
            this.MessageFactory       = messageFactory;
            this.receiveEventArgsPool = new ConcurrentObjectPool <SaeaPoolWrapper>(() => this.CreateSocketReceiveAsyncEventArgsPoolWrapper());
            this.serializationManager = serializationManager;
            if (here == null)
            {
                listenAddress = MessageCenter.MyAddress.Endpoint;
            }

            AcceptingSocket = MessageCenter.SocketManager.GetAcceptingSocketForEndpoint(listenAddress);
            Log.Info(ErrorCode.Messaging_IMA_OpenedListeningSocket, "Opened a listening socket at address " + AcceptingSocket.LocalEndPoint);
            OpenReceiveSockets = new HashSet <Socket>();
            OnFault            = FaultBehavior.CrashOnFault;
            SocketDirection    = socketDirection;

            checkedOutSocketEventArgsCounter = CounterStatistic.FindOrCreate(StatisticNames.MESSAGE_ACCEPTOR_CHECKED_OUT_SOCKET_EVENT_ARGS, false);
            checkedInSocketEventArgsCounter  = CounterStatistic.FindOrCreate(StatisticNames.MESSAGE_ACCEPTOR_CHECKED_IN_SOCKET_EVENT_ARGS, false);

            IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_ACCEPTOR_IN_USE_SOCKET_EVENT_ARGS,
                                           () => checkedOutSocketEventArgsCounter.GetCurrentValue() - checkedInSocketEventArgsCounter.GetCurrentValue());
        }
Example #2
0
 public Socket(Node parent, Color type, SocketDirection direciton)
 {
     Parent = parent;
     Type = type;
     _boxRect.width = BonConfig.SocketSize;
     _boxRect.height = BonConfig.SocketSize;
     Direction = direciton;
 }
Example #3
0
 public Socket(Node parent, Color type, SocketDirection direciton)
 {
     Parent         = parent;
     Type           = type;
     boxRect.width  = BonConfig.SocketSize;
     boxRect.height = BonConfig.SocketSize;
     Direction      = direciton;
 }
            internal PerSocketDirectionStats(bool sendOrReceive, SocketDirection direction)
            {
                StatisticNameFormat batchSizeStatName = sendOrReceive ? StatisticNames.MESSAGING_SENT_BATCH_SIZE_PER_SOCKET_DIRECTION : StatisticNames.MESSAGING_RECEIVED_BATCH_SIZE_PER_SOCKET_DIRECTION;
                StatisticNameFormat batchHistogramStatName = sendOrReceive ? StatisticNames.MESSAGING_SENT_BATCH_SIZE_BYTES_HISTOGRAM_PER_SOCKET_DIRECTION : StatisticNames.MESSAGING_RECEIVED_BATCH_SIZE_BYTES_HISTOGRAM_PER_SOCKET_DIRECTION;

                averageBatchSize = AverageValueStatistic.FindOrCreate(new StatisticName(batchSizeStatName, Enum.GetName(typeof(SocketDirection), direction)));
                batchSizeBytesHistogram = ExponentialHistogramValueStatistic.Create_ExponentialHistogram(
                    new StatisticName(batchHistogramStatName, Enum.GetName(typeof(SocketDirection), direction)), 
                    NUM_MSG_SIZE_HISTOGRAM_CATEGORIES);
            }
            internal PerSocketDirectionStats(bool sendOrReceive, SocketDirection direction)
            {
                StatisticNameFormat batchSizeStatName      = sendOrReceive ? StatisticNames.MESSAGING_SENT_BATCH_SIZE_PER_SOCKET_DIRECTION : StatisticNames.MESSAGING_RECEIVED_BATCH_SIZE_PER_SOCKET_DIRECTION;
                StatisticNameFormat batchHistogramStatName = sendOrReceive ? StatisticNames.MESSAGING_SENT_BATCH_SIZE_BYTES_HISTOGRAM_PER_SOCKET_DIRECTION : StatisticNames.MESSAGING_RECEIVED_BATCH_SIZE_BYTES_HISTOGRAM_PER_SOCKET_DIRECTION;

                averageBatchSize        = AverageValueStatistic.FindOrCreate(new StatisticName(batchSizeStatName, Enum.GetName(typeof(SocketDirection), direction)));
                batchSizeBytesHistogram = ExponentialHistogramValueStatistic.Create_ExponentialHistogram(
                    new StatisticName(batchHistogramStatName, Enum.GetName(typeof(SocketDirection), direction)),
                    NUM_MSG_SIZE_HISTOGRAM_CATEGORIES);
            }
        /// <summary> Adds a socket to this node </summary>
        /// <param name="socketName"> The name of the socket (if null or empty, it will be auto-generated) </param>
        /// <param name="direction"> The socket direction (Input/Output) </param>
        /// <param name="connectionMode"> The socket connection mode (Multiple/Override) </param>
        /// <param name="connectionPoints"> The socket connection points locations (if null or empty, it will automatically add two connection points to the left of and the right of the socket) </param>
        /// <param name="valueType"> The serialized class that holds additional socket values </param>
        /// <param name="canBeDeleted"> Determines if this socket is a special socket that cannot be deleted </param>
        /// <param name="canBeReordered"> Determines if this socket is a special socket that cannot be reordered </param>
        private Socket AddSocket(string socketName, SocketDirection direction, ConnectionMode connectionMode, List <Vector2> connectionPoints, Type valueType, bool canBeDeleted, bool canBeReordered = true)
        {
            if (connectionPoints == null)
            {
                connectionPoints = new List <Vector2>(GetLeftAndRightConnectionPoints());
            }
            if (connectionPoints.Count == 0)
            {
                connectionPoints.AddRange(GetLeftAndRightConnectionPoints());
            }
            var socketNames = new List <string>();
            int counter;

            switch (direction)
            {
            case SocketDirection.Input:
                foreach (Socket socket in InputSockets)
                {
                    socketNames.Add(socket.SocketName);
                }
                counter = 0;
                if (string.IsNullOrEmpty(socketName))
                {
                    socketName = Socket.DEFAULT_INPUT_SOCKET_NAME_PREFIX + counter;
                }
                while (socketNames.Contains(socketName))
                {
                    socketName = Socket.DEFAULT_INPUT_SOCKET_NAME_PREFIX + counter++;
                }
                var inputSocket = new Socket(this, socketName, direction, connectionMode, connectionPoints, valueType, canBeDeleted, canBeReordered);
                InputSockets.Add(inputSocket);
                return(inputSocket);

            case SocketDirection.Output:
                foreach (Socket socket in OutputSockets)
                {
                    socketNames.Add(socket.SocketName);
                }
                counter = 0;
                if (string.IsNullOrEmpty(socketName))
                {
                    socketName = Socket.DEFAULT_OUTPUT_SOCKET_NAME_PREFIX + counter;
                }
                while (socketNames.Contains(socketName))
                {
                    socketName = Socket.DEFAULT_OUTPUT_SOCKET_NAME_PREFIX + counter++;
                }
                var outputSocket = new Socket(this, socketName, direction, connectionMode, connectionPoints, valueType, canBeDeleted, canBeReordered);
                OutputSockets.Add(outputSocket);
                return(outputSocket);

            default: throw new ArgumentOutOfRangeException("direction", direction, null);
            }
        }
 // Used for holding enough info to handle receive completion
 internal IncomingMessageAcceptor(MessageCenter msgCtr, IPEndPoint here, SocketDirection socketDirection)
 {
     MessageCenter = msgCtr;
     listenAddress = here;
     if (here == null)
         listenAddress = MessageCenter.MyAddress.Endpoint;
     
     AcceptingSocket = SocketManager.GetAcceptingSocketForEndpoint(listenAddress);
     Log.Info(ErrorCode.Messaging_IMA_OpenedListeningSocket, "Opened a listening socket at address " + AcceptingSocket.LocalEndPoint);
     OpenReceiveSockets = new HashSet<Socket>();
     OnFault = FaultBehavior.CrashOnFault;
     SocketDirection = socketDirection;
 }
Example #8
0
        protected void DrawAddSocketButton(SocketDirection direction, ConnectionMode connectionMode, Type valueType)
        {
            var area = new Rect(6, DynamicHeight, Node.GetWidth() - 12, NodySettings.Instance.SocketHeight);

            DynamicHeight += area.height; //Update HEIGHT

            if (ZoomedBeyondSocketDrawThreshold)
            {
                return;
            }

            bool  isInput   = direction == SocketDirection.Input;
            Color iconColor = DGUI.Colors.IconColor(isInput ? DGUI.Colors.GetDColor(DGUI.Colors.NodyInputColorName) : DGUI.Colors.GetDColor(DGUI.Colors.NodyOutputColorName)).WithAlpha(NodySettings.Instance.NormalOpacity);


            var iconRect = new Rect(area.x + area.width / 2 - NodySettings.Instance.NodeAddSocketButtonSize / 2,
                                    area.y + area.height / 2 - NodySettings.Instance.NodeAddSocketButtonSize / 2,
                                    NodySettings.Instance.NodeAddSocketButtonSize,
                                    NodySettings.Instance.NodeAddSocketButtonSize);
            var hoveredIconRect = new Rect(iconRect.x - iconRect.width * 0.4f / 2,
                                           iconRect.y - iconRect.height * 0.4f / 2,
                                           iconRect.width * 1.4f,
                                           iconRect.height * 1.4f);

            bool mouseIsOverButton = hoveredIconRect.Contains(Event.current.mousePosition);

            if (mouseIsOverButton)
            {
                iconColor.a = NodySettings.Instance.HoverOpacity;
            }


            Color color = GUI.color;

            GUI.color = iconColor;
            if (GUI.Button(mouseIsOverButton ? hoveredIconRect : iconRect, GUIContent.none, NodeIconPlus))
            {
                Undo.RecordObject(Node, "Add " + direction + " Socket");
                if (isInput)
                {
                    Node.AddInputSocket(connectionMode, valueType, true, true);
                }
                else
                {
                    Node.AddOutputSocket(connectionMode, valueType, true, true);
                }
                GraphEvent.Send(GraphEvent.EventType.EVENT_SOCKET_CREATED, Node.Id);
            }

            GUI.color = color;
        }
        // Used for holding enough info to handle receive completion
        internal IncomingMessageAcceptor(MessageCenter msgCtr, IPEndPoint here, SocketDirection socketDirection)
        {
            MessageCenter = msgCtr;
            listenAddress = here;
            if (here == null)
            {
                listenAddress = MessageCenter.MyAddress.Endpoint;
            }

            AcceptingSocket = SocketManager.GetAcceptingSocketForEndpoint(listenAddress);
            Log.Info(ErrorCode.Messaging_IMA_OpenedListeningSocket, "Opened a listening socket at address " + AcceptingSocket.LocalEndPoint);
            OpenReceiveSockets = new HashSet <Socket>();
            OnFault            = FaultBehavior.CrashOnFault;
            SocketDirection    = socketDirection;
        }
Example #10
0
 /// <summary> Construct a new socket </summary>
 /// <param name="node"> The node it belongs to </param>
 /// <param name="socketName"> The socket name. Needs to be unique on the node </param>
 /// <param name="direction"> Input or Output socket </param>
 /// <param name="connectionMode"> Can establish multiple connections OR can establish only one connection </param>
 /// <param name="connectionPoints"> The connection points positions available for this socket </param>
 /// <param name="valueType"> Serialized data type used by this socket </param>
 /// <param name="canBeDeleted"> This is used to make sure important sockets cannot be deleted by the developer and break the node settings / graph functionality / user experience </param>
 /// <param name="canBeReordered"> This is used to prevent special sockets from being reordered </param>
 public Socket(Node node, string socketName, SocketDirection direction, ConnectionMode connectionMode, List <Vector2> connectionPoints, Type valueType, bool canBeDeleted, bool canBeReordered)
 {
     GenerateNewId();
     m_nodeId                 = node.Id;
     m_socketName             = socketName;
     m_direction              = direction;
     m_connectionMode         = connectionMode;
     m_connectionPoints       = connectionPoints;
     m_valueType              = valueType;
     m_canBeDeleted           = canBeDeleted;
     m_canBeReordered         = canBeReordered;
     m_valueTypeQualifiedName = valueType.AssemblyQualifiedName;
     m_value         = JsonUtility.ToJson(Activator.CreateInstance(ValueType));
     m_connections   = new List <Connection>();
     m_curveModifier = 0;
 }
Example #11
0
        /// <summary> Returns the socket of the type and index.</summary>
        /// <param name="type"> The type of the socket.</param>
        /// <param name="direction"> The input or output direction of the socket.</param>
        /// <param name="index"> The index of sockets of this type.
        /// You can have multiple sockets of the same type.</param>
        /// <returns>The socket of the type with the index or null.</returns>
        public Socket GetSocket(Color type, SocketDirection direction, int index)
        {
            var searchIndex = -1;

            foreach (var socket in Sockets)
            {
                if (socket.Type == type && socket.Direction == direction)
                {
                    searchIndex++;
                    if (searchIndex == index)
                    {
                        return(socket);
                    }
                }
            }
            return(null);
        }
Example #12
0
        // Used for holding enough info to handle receive completion
        internal IncomingMessageAcceptor(MessageCenter msgCtr, IPEndPoint here, SocketDirection socketDirection)
        {
            MessageCenter = msgCtr;
            listenAddress = here;
            if (here == null)
            {
                listenAddress = MessageCenter.MyAddress.Endpoint;
            }

            AcceptingSocket = SocketManager.GetAcceptingSocketForEndpoint(listenAddress);
            Log.Info(ErrorCode.Messaging_IMA_OpenedListeningSocket, "Opened a listening socket at address " + AcceptingSocket.LocalEndPoint);
            OpenReceiveSockets = new HashSet <Socket>();
            OnFault            = FaultBehavior.CrashOnFault;
            SocketDirection    = socketDirection;

            checkedOutSocketEventArgsCounter = CounterStatistic.FindOrCreate(StatisticNames.MESSAGE_ACCEPTOR_CHECKED_OUT_SOCKET_EVENT_ARGS, false);
            checkedInSocketEventArgsCounter  = CounterStatistic.FindOrCreate(StatisticNames.MESSAGE_ACCEPTOR_CHECKED_IN_SOCKET_EVENT_ARGS, false);

            IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_ACCEPTOR_IN_USE_SOCKET_EVENT_ARGS,
                                           () => checkedOutSocketEventArgsCounter.GetCurrentValue() - checkedInSocketEventArgsCounter.GetCurrentValue());
        }
Example #13
0
 /// <summary> Create a deep copy of another socket </summary>
 /// <param name="other"> The other socket we are copying data from </param>
 public Socket(Socket other)
 {
     m_id               = other.Id;
     m_nodeId           = other.m_nodeId;
     m_socketName       = other.m_socketName;
     m_direction        = other.m_direction;
     m_connectionMode   = other.m_connectionMode;
     m_connectionPoints = new List <Vector2>(other.ConnectionPoints);
     m_x         = other.m_x;
     m_y         = other.m_y;
     m_width     = other.m_width;
     m_height    = other.m_height;
     m_valueType = other.m_valueType;
     m_valueTypeQualifiedName = other.m_valueTypeQualifiedName;
     m_value          = other.Value;
     m_canBeDeleted   = other.CanBeDeleted;
     m_canBeReordered = other.m_canBeReordered;
     m_connections    = new List <Connection>();
     foreach (Connection connection in other.m_connections)
     {
         m_connections.Add(new Connection(connection));
     }
     m_curveModifier = other.m_curveModifier;
 }
Example #14
0
 internal static void OnMessageBatchReceive(SocketDirection socketDirection, int numMsgsInBatch, int totalBytes)
 {
     perSocketDirectionStatsReceive[(int)socketDirection].OnMessage(numMsgsInBatch, totalBytes);
 }
Example #15
0
 internal static void OnMessageBatchSend(SiloAddress targetSilo, Message.Directions direction, int numTotalBytes, int headerBytes, SocketDirection socketDirection, int numMsgsInBatch)
 {
     if (numTotalBytes < 0)
     {
         throw new ArgumentException(String.Format("OnMessageBatchSend(numTotalBytes={0})", numTotalBytes), "numTotalBytes");
     }
     OnMessageSend_Impl(targetSilo, direction, numTotalBytes, headerBytes, numMsgsInBatch);
     perSocketDirectionStatsSend[(int)socketDirection].OnMessage(numMsgsInBatch, numTotalBytes);
 }
Example #16
0
 internal static void OnMessageSend(SiloAddress targetSilo, Message.Directions direction, int numTotalBytes, int headerBytes, SocketDirection socketDirection)
 {
     if (numTotalBytes < 0)
     {
         throw new ArgumentException(String.Format("OnMessageSend(numTotalBytes={0})", numTotalBytes), "numTotalBytes");
     }
     OnMessageSend_Impl(targetSilo, direction, numTotalBytes, headerBytes, 1);
 }
Example #17
0
 /// <summary> Returns the socket of the type and index.</summary>
 /// <param name="type"> The type of the socket.</param>
 /// <param name="direction"> The input or output direction of the socket.</param>
 /// <param name="index"> The index of sockets of this type.
 /// You can have multiple sockets of the same type.</param>
 /// <returns>The socket of the type with the index or null.</returns>
 public Socket GetSocket(Color type, SocketDirection direction, int index)
 {
     var searchIndex = -1;
     foreach (var socket in Sockets)
     {
         if (socket.Type == type && socket.Direction == direction)
         {
             searchIndex++;
             if (searchIndex == index) return socket;
         }
     }
     return null;
 }
 internal static void OnMessageBatchReceive(SocketDirection socketDirection, int numMsgsInBatch, int totalBytes)
 {
     perSocketDirectionStatsReceive[(int)socketDirection].OnMessage(numMsgsInBatch, totalBytes);
 }
 internal static void OnMessageBatchSend(SiloAddress targetSilo, Message.Directions direction, int numTotalBytes, int headerBytes, SocketDirection socketDirection, int numMsgsInBatch)
 {
     if (numTotalBytes < 0)
         throw new ArgumentException(String.Format("OnMessageBatchSend(numTotalBytes={0})", numTotalBytes), "numTotalBytes");
     OnMessageSend_Impl(targetSilo, direction, numTotalBytes, headerBytes, numMsgsInBatch);
     perSocketDirectionStatsSend[(int)socketDirection].OnMessage(numMsgsInBatch, numTotalBytes);
 }
 internal static void OnMessageSend(SiloAddress targetSilo, Message.Directions direction, int numTotalBytes, int headerBytes, SocketDirection socketDirection)
 {
     if (numTotalBytes < 0)
         throw new ArgumentException(String.Format("OnMessageSend(numTotalBytes={0})", numTotalBytes), "numTotalBytes");
     OnMessageSend_Impl(targetSilo, direction, numTotalBytes, headerBytes, 1);
 }
Example #21
0
 public SocketEventArgs(IClient client)
 {
     FromClient      = client;
     SocketDirection = SocketDirection.NotDefined;
 }