Erlang.NET.OtpNode.getConnection C# (CSharp) Method

getConnection() public method

public getConnection ( String node ) : Erlang.NET.OtpCookedConnection
node String
return Erlang.NET.OtpCookedConnection
        public OtpCookedConnection getConnection(String node)
        {
            OtpPeer peer = null;
            OtpCookedConnection conn = null;

            lock (connections)
            {
                // first just try looking up the name as-is

                if (connections.ContainsKey(node))
                {
                    conn = connections[node];
                }
                else
                {
                    // in case node had no '@' add localhost info and try again
                    peer = new OtpPeer(node);

                    if (connections.ContainsKey(peer.Node))
                    {
                        conn = connections[peer.Node];
                    }
                    else
                    {
                        try
                        {
                            conn = new OtpCookedConnection(this, peer);
                            conn.setFlags(flags);
                            addConnection(conn);
                        }
                        catch (Exception e)
                        {
                            /* false = outgoing */
                            connAttempt(peer.Node, false, e);
                        }
                    }
                }
                return conn;
            }
        }

Usage Example

Ejemplo n.º 1
0
 /**
  * Send a message to a remote {@link OtpErlangPid pid}, representing either
  * another {@link OtpMbox mailbox} or an Erlang process.
  *
  * @param to
  *                the {@link OtpErlangPid pid} identifying the intended
  *                recipient of the message.
  *
  * @param msg
  *                the body of the message to send.
  *
  */
 public void send(OtpErlangPid to, OtpErlangObject msg)
 {
     try
     {
         String node = to.Node;
         if (node.Equals(home.Node))
         {
             home.deliver(new OtpMsg(to, (OtpErlangObject)msg.Clone()));
         }
         else
         {
             OtpCookedConnection conn = home.getConnection(node);
             if (conn == null)
             {
                 return;
             }
             conn.send(self, to, msg);
         }
     }
     catch (Exception)
     {
     }
 }