Ejemplo n.º 1
0
        public ErlConnection Connection(ErlAtom toNode, ErlAtom?cookie = null)
        {
            ErlConnection c;

            if (m_Connections.TryGetValue(toNode, out c))
            {
                return(c);
            }

            var peer = new ErlRemoteNode(this, toNode, cookie);

            //try to append config to remote node
            TryAppendConfigToRemoteNode(peer);

            lock (m_Connections)
            {
                if (m_Connections.TryGetValue(toNode, out c))
                {
                    return(c);
                }

                try
                {
                    c = new ErlConnection(this, peer, true);
                }
                catch
                {
                    return(null);
                }

                m_Connections.TryAdd(toNode, c);

                return(c);
            }
        }
Ejemplo n.º 2
0
 internal void UnhandledMsg(ErlConnection conn, ErlMsg msg)
 {
     if (m_OnUnhandledMsg != null)
     {
         m_OnUnhandledMsg(conn, msg);
     }
 }
Ejemplo n.º 3
0
        internal ErlConnection Connection(string toNode, IConfigSectionNode config,
                                          ErlAtom?cookie = null)
        {
            var peer = new ErlRemoteNode(this, toNode);

            // This will convert toNode to a valid ErlAtom

            lock (m_Connections)
            {
                ErlConnection c;

                if (m_Connections.TryGetValue(peer.NodeName, out c))
                {
                    return(c);
                }

                peer.Configure(config); // Fetch all proper TCP and other settings

                try
                {
                    c = new ErlConnection(this, peer, true);
                }
                catch
                {
                    return(null);
                } // TODO: maybe add return reason for connection failure?

                m_Connections.TryAdd(peer.NodeName, c);

                return(c);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a connection to collection
        /// </summary>
        /// <returns>Returns false if this connection was already previously added</returns>
        public bool Add(ErlConnection conn)
        {
            var res = m_Connections.TryAdd(conn.Name, conn);

            if (res)
            {
                OnNodeStatusChange(conn.Name, true, null);
            }
            return(res);
        }
Ejemplo n.º 5
0
 protected internal virtual void OnUnhandledMsg(ErlConnection conn, ErlMsg msg, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
 {
     if (UnhandledMsg != null)
     {
         UnhandledMsg(this, conn, msg);
     }
     if (LogUnhandledMsgs)
     {
         Log(MessageType.TraceErl,
             "OnUnhandledMsg",
             "Connection {0} couldn't find mbox for: {1}".Args(conn.Name, msg),
             file: file, line: line);
     }
 }
Ejemplo n.º 6
0
 protected internal virtual void OnUnhandledMsg(ErlConnection conn, ErlMsg msg)
 {
     if (UnhandledMsg != null)
     {
         UnhandledMsg(this, conn, msg);
     }
     if (LogUnhandledMsgs)
     {
         App.Log.Write(new NFX.Log.Message
         {
             Type  = Log.MessageType.TraceErl,
             Topic = CoreConsts.ERLANG_TOPIC,
             From  = this.ToString(),
             Text  = "Connection {0} couldn't find mbox for: {1}".Args(conn.Name, msg)
         });
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Remove a connection from collection
        /// </summary>
        public void Remove(ErlConnection conn)
        {
            ErlConnection value;

            m_Connections.TryRemove(conn.Name, out value);
        }
Ejemplo n.º 8
0
 internal void UnhandledMsg(ErlConnection conn, ErlMsg msg)
 {
     if (m_OnUnhandledMsg != null)
         m_OnUnhandledMsg(conn, msg);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Remove a connection from collection
 /// </summary>
 public void Remove(ErlConnection conn)
 {
     ErlConnection value;
     m_Connections.TryRemove(conn.Name, out value);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Add a connection to collection
 /// </summary>
 /// <returns>Returns false if this connection was already previously added</returns>
 public bool Add(ErlConnection conn)
 {
     var res = m_Connections.TryAdd(conn.Name, conn);
     if (res)
         NodeStatus(conn.Name, true, null);
     return res;
 }
Ejemplo n.º 11
0
            public ErlConnection Connection(ErlAtom toNode, ErlAtom? cookie = null)
            {
                ErlConnection c;
                if (m_Connections.TryGetValue(toNode, out c))
                    return c;

                var peer = new ErlRemoteNode(this, toNode, cookie);

                lock (m_Connections)
                {
                    if (m_Connections.TryGetValue(toNode, out c))
                        return c;

                    try     { c = new ErlConnection(this, peer, true); }
                    catch   { return null; }

                    m_Connections.TryAdd(toNode, c);

                    return c;
                }
            }
Ejemplo n.º 12
0
            internal ErlConnection Connection(string toNode, IConfigSectionNode config)
            {
                var peer = new ErlRemoteNode(this, toNode); // This will convert toNode to a valid ErlAtom

                lock (m_Connections)
                {
                    ErlConnection c;

                    if (m_Connections.TryGetValue(peer.NodeName, out c))
                        return c;

                    peer.Configure(config); // Fetch all proper TCP and other settings

                    try { c = new ErlConnection(this, peer, true); }
                    catch { return null; }

                    m_Connections.TryAdd(peer.NodeName, c);

                    return c;
                }
            }
Ejemplo n.º 13
0
 protected internal virtual void OnUnhandledMsg(ErlConnection conn, ErlMsg msg,
     [CallerFilePath]  string file = null,
     [CallerLineNumber]int    line = 0)
 {
     if (UnhandledMsg != null) UnhandledMsg(this, conn, msg);
       if (LogUnhandledMsgs)
     App.Log.Write(new NFX.Log.Message(null, file, line)
     {
       Type = Log.MessageType.TraceErl,
       Topic = CoreConsts.ERLANG_TOPIC,
       From = this.ToString(),
       Text = "Connection {0} couldn't find mbox for: {1}".Args(conn.Name, msg)
     });
 }
Ejemplo n.º 14
0
 protected internal virtual void OnUnhandledMsg(ErlConnection conn, ErlMsg msg, [CallerFilePath]string file = "", [CallerLineNumber]int line = 0)
 {
   if (UnhandledMsg != null) UnhandledMsg(this, conn, msg);
   if (LogUnhandledMsgs)
     Log(MessageType.TraceErl,
         "OnUnhandledMsg",
         "Connection {0} couldn't find mbox for: {1}".Args(conn.Name, msg), 
         file:file, line:line);
 }