Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 public static void GetTableValues()
 {
     // Current username output.
     ConnectionReference.GetValueAsync().ContinueWith(task =>
     {
         // Task completed?
         if (task.IsFaulted) // Yes with error.
         {
             // Output error.
             Debug.Log("Get value task error!");
         }
         else if (task.IsCompleted) // Yes successfully.
         {
             // It's not working correctly.
             var snapshot = task.Result;
             int i        = 0;
             foreach (var children in snapshot.Children)
             {
                 Debug.Log(children.Child(i.ToString()).Child(LeadersAttributeName.EMAIL).Value);
                 Debug.Log(children.Child(i.ToString()).Child(LeadersAttributeName.SCORE).Value);
                 i++;
             }
         }
     });
 }
 public void AddConnection(long id, ConnectionReference connectionReference)
 {
     if (!_connectionReferences.TryAdd(id, connectionReference))
     {
         throw new ArgumentException("Unable to add connection.", nameof(id));
     }
 }
    public void AddConnection(long id, KestrelConnection connection)
    {
        var connectionReference = new ConnectionReference(id, connection, this);

        if (!_connectionReferences.TryAdd(id, connectionReference))
        {
            throw new ArgumentException("Unable to add specified id.", nameof(id));
        }

        _connectionManager.AddConnection(id, connectionReference);
    }
        public override void Open()
        {
            if (connectionState == ConnectionState.Open)
            {
                throw new InvalidOperationException("Connection is already open.");
            }

            connectionReference = connectionManager.GetConnectionReference(ConnectionString);

            connectionState = ConnectionState.Open;
        }
Exemple #5
0
        /// <summary>
        /// Draws all connections
        /// </summary>
        public void DrawConnections()
        {
            Vector2 mousePos = Event.current.mousePosition;
            List <RerouteReference> selection = preBoxSelectionReroute != null ? new List <RerouteReference>(preBoxSelectionReroute) : new List <RerouteReference>();

            hoveredReroute    = new RerouteReference();
            hoveredConnection = new ConnectionReference();

            Color col = GUI.color;

            foreach (XNode.Node node in graph.nodes)
            {
                //If a null node is found, return. This can happen if the nodes associated script is deleted. It is currently not possible in Unity to delete a null asset.
                if (node == null)
                {
                    continue;
                }

                // Draw full connections and output > reroute
                foreach (XNode.NodePort output in node.Outputs)
                {
                    //Needs cleanup. Null checks are ugly
                    if (!_portConnectionPoints.TryGetValue(output, out Rect fromRect))
                    {
                        continue;
                    }

                    Color connectionColor = graphEditor.GetPortColor(output);

                    for (int k = 0; k < output.ConnectionCount; k++)
                    {
                        XNode.NodePort input = output.GetConnection(k);

                        // Error handling
                        if (input == null)
                        {
                            continue;                             //If a script has been updated and the port doesn't exist, it is removed and null is returned. If this happens, return.
                        }

                        if (!input.IsConnectedTo(output))
                        {
                            input.Connect(output);
                        }

                        if (!_portConnectionPoints.TryGetValue(input, out Rect toRect))
                        {
                            continue;
                        }

                        List <Vector2> reroutePoints = output.GetReroutePoints(k);

                        List <Vector2> gridPoints = new List <Vector2>
                        {
                            fromRect.center
                        };
                        gridPoints.AddRange(reroutePoints);
                        gridPoints.Add(toRect.center);
                        DrawNoodle(connectionColor, gridPoints, output, input);

                        // Loop through reroute points again and draw the points
                        for (int i = 0; i < reroutePoints.Count; i++)
                        {
                            RerouteReference rerouteRef = new RerouteReference(output, k, i);
                            // Draw reroute point at position
                            Rect rect = new Rect(reroutePoints[i], new Vector2(12, 12));
                            rect.position = new Vector2(rect.position.x - 6, rect.position.y - 6);
                            rect          = GridToWindowRect(rect);

                            // Draw selected reroute points with an outline
                            if (selectedReroutes.Contains(rerouteRef))
                            {
                                GUI.color = NodeEditorPreferences.GetSettings().highlightColor;
                                GUI.DrawTexture(rect, NodeEditorResources.dotOuter);
                            }

                            GUI.color = connectionColor;
                            GUI.DrawTexture(rect, NodeEditorResources.dot);
                            if (rect.Overlaps(selectionBox))
                            {
                                selection.Add(rerouteRef);
                            }

                            if (rect.Contains(mousePos))
                            {
                                hoveredReroute = rerouteRef;
                                hoveredConnection.outputPort = null;
                            }
                        }
                    }
                }
            }
            GUI.color = col;
            if (Event.current.type != EventType.Layout && currentActivity == NodeActivity.DragGrid)
            {
                selectedReroutes = selection;
            }
        }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <param name="callback"></param>
 public static void RemoveItem(string id, Action <string> callback = null)
 {
     ConnectionReference.Child(TABLE_NAME).Child(id).RemoveValueAsync();
 }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <param name="attributeName"></param>
 /// <param name="newValue"></param>
 /// <param name="callback"></param>
 public static void UpdateAttribute(string id, string attributeName, string newValue, Action <string> callback = null)
 {
     ConnectionReference.Child(TABLE_NAME).Child(id).Child(attributeName).SetValueAsync(newValue);
 }