예제 #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);
            }
        }
예제 #2
0
파일: ErlLocalNode.cs 프로젝트: mjaric/nfx
 internal void UnhandledMsg(ErlConnection conn, ErlMsg msg)
 {
     if (m_OnUnhandledMsg != null)
     {
         m_OnUnhandledMsg(conn, msg);
     }
 }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
     }
 }
예제 #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)
         });
     }
 }
예제 #7
0
        /// <summary>
        /// Remove a connection from collection
        /// </summary>
        public void Remove(ErlConnection conn)
        {
            ErlConnection value;

            m_Connections.TryRemove(conn.Name, out value);
        }
예제 #8
0
 internal void UnhandledMsg(ErlConnection conn, ErlMsg msg)
 {
     if (m_OnUnhandledMsg != null)
         m_OnUnhandledMsg(conn, msg);
 }
예제 #9
0
 /// <summary>
 /// Remove a connection from collection
 /// </summary>
 public void Remove(ErlConnection conn)
 {
     ErlConnection value;
     m_Connections.TryRemove(conn.Name, out value);
 }
예제 #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;
 }
예제 #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;
                }
            }
예제 #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;
                }
            }
예제 #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)
     });
 }
예제 #14
0
파일: ErlLocalNode.cs 프로젝트: kinpro/nfx
 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);
 }