예제 #1
0
        public IceClientTransportSink(string url)
        {
            IceChannelUtils.ParseIceURL(url, out _host, out _port, out _objectUri);

            Ice.TcpEndpoint te = new Ice.TcpEndpoint(_host, _port);
            _e = Ice.Manager.GetManager().GetEndpoint(te);
        }
예제 #2
0
 public IceChannel(int port)
 {
     Ice.TcpEndpoint te = new Ice.TcpEndpoint("localhost", port);
     te.Incoming = true;
     _svrChannel = new IceServerChannel(te);
     _cltChannel = new IceClientChannel();
 }
예제 #3
0
    public IceClientTransportSink (string url)
    {
      IceChannelUtils.ParseIceURL (url, out _host, out _port, out _objectUri);

      Ice.TcpEndpoint te = new Ice.TcpEndpoint (_host, _port);
      _e = Ice.Manager.GetManager().GetEndpoint (te);
    }
예제 #4
0
        public virtual void WriteProxy(object o, Type ot)
        {
            if (!RemotingServices.IsTransparentProxy(o))
            {
                Console.WriteLine("o {0} ot {1} is not transparent proxy!", o, ot);
                throw new InvalidOperationException("object which is not a transparent proxy passed to WriteProxy, type " + ot);
            }

            ObjRef or = RemotingServices.GetObjRefForProxy((System.MarshalByRefObject)o);

            Ice.Identity proxy_ident = new Ice.Identity(or.URI.StartsWith("/") ? or.URI.Substring(1) : or.URI);
            Ice.Endpoint proxy_ep    = null;

            foreach (object cdo in or.ChannelInfo.ChannelData)
            {
                ChannelDataStore cd = cdo as ChannelDataStore;
                if (cd == null)
                {
                    continue;
                }
                foreach (string ch_uri in cd.ChannelUris)
                {
                    string host;
                    int    port;
                    string uri;

                    if (IceChannelUtils.ParseIceURL(ch_uri, out host, out port, out uri))
                    {
                        proxy_ep          = new Ice.TcpEndpoint(host, port);
                        proxy_ep.Incoming = true;
                        break;
                    }
                }
            }

            if (proxy_ep == null)
            {
                throw new InvalidOperationException("Couldn't find valid Ice endpoint/channel for " + o);
            }

            Ice.ProxyData pd = new Ice.ProxyData();
            pd.id     = proxy_ident;
            pd.facet  = new string[0];
            pd.mode   = ProxyMode.Twoway; // FIXME -- do I need to send multiple proxy things here?
            pd.secure = false;

            WriteStruct(pd);
            WriteSize(1);       // one endpoint follows

            // tcp endpoint encapsulation
            WriteObject((short)1); // it's a TCP endpoint
            BeginEncapsulation();
            Ice.TcpEndpoint te = proxy_ep as Ice.TcpEndpoint;
            Write(te.host);
            WriteObject(te.port);
            WriteObject(te.timeout);
            WriteObject(te.compress);
            EndEncapsulation();
        }
예제 #5
0
 public string[] GetUrlsForUri(string uri)
 {
     Ice.TcpEndpoint te = _e as Ice.TcpEndpoint;
     if (te == null)
     {
         return(null);
     }
     string[] ret = new string[1];
     ret[0] = "ice://" + te.host + ":" + te.port + "/" + uri;
     return(ret);
 }
예제 #6
0
        public void StartListening(object data)
        {
            Ice.TcpEndpoint te = _e as Ice.TcpEndpoint;

            if (_listenerThread == null)
            {
                _listener.Start();
                if (te.port == 0)
                {
                    te.port = ((IPEndPoint)_listener.LocalEndpoint).Port;
                    _channelData.ChannelUris    = new string[1];
                    _channelData.ChannelUris[0] = "ice://" + te.host + ":" + te.port;
                }

                _listenerThread = new Thread(new ThreadStart(ListenerThread));
                _listenerThread.Start();
            }
        }
예제 #7
0
        private void ListenerThread()
        {
            if (_e is Ice.TcpEndpoint)
            {
                // loop and accept socket connections, then convert them
                // into Endpoints, and instantiate a ReceiverDispatcher for
                // them.
                while (true)
                {
                    Socket clientSocket = _listener.AcceptSocket();

                    Ice.Endpoint    ne    = (Ice.Endpoint)_e.Clone();
                    Ice.TcpEndpoint tcpep = ne as Ice.TcpEndpoint;

                    if (tcpep == null)
                    {
                        throw new NotSupportedException("Only TCP endpoints are supported");
                    }

                    tcpep.Socket = clientSocket;

                    if (tcpep.HasConnection)
                    {
                        // validate the connection
                        MemoryStream       ms = new MemoryStream();
                        Ice.ProtocolWriter pw = new Ice.ProtocolWriter(ms);
                        pw.BeginMessage(MessageType.ValidateConnection);
                        pw.EndMessage();
                        ms.WriteTo(tcpep.Stream);
                    }

                    tcpep.ReceiverDispatcher = new Ice.ReceiverDispatcher(tcpep, new MessageRequestDelegate(MessageRequestHandler));
                }
            }
            else
            {
                throw new NotImplementedException("ListenerThread managed to get a non-Tcp Ice.Endpoint");
            }
        }
예제 #8
0
 public IceChannel(int port) {
   Ice.TcpEndpoint te = new Ice.TcpEndpoint ("localhost", port);
   te.Incoming = true;
   _svrChannel = new IceServerChannel (te);
   _cltChannel = new IceClientChannel ();
 }
예제 #9
0
    public virtual void WriteProxy (object o, Type ot) {
      if (!RemotingServices.IsTransparentProxy (o)) {
        Console.WriteLine ("o {0} ot {1} is not transparent proxy!", o, ot);
        throw new InvalidOperationException ("object which is not a transparent proxy passed to WriteProxy, type " + ot);
      }

      ObjRef or = RemotingServices.GetObjRefForProxy ((System.MarshalByRefObject) o);
      Ice.Identity proxy_ident = new Ice.Identity (or.URI.StartsWith("/") ? or.URI.Substring(1) : or.URI);
      Ice.Endpoint proxy_ep = null;

      foreach (object cdo in or.ChannelInfo.ChannelData) {
        ChannelDataStore cd = cdo as ChannelDataStore;
        if (cd == null)
          continue;
        foreach (string ch_uri in cd.ChannelUris) {
          string host;
          int port;
          string uri;

          if (IceChannelUtils.ParseIceURL (ch_uri, out host, out port, out uri)) {
            proxy_ep = new Ice.TcpEndpoint (host, port);
            proxy_ep.Incoming = true;
            break;
          }
        }
      }
      
      if (proxy_ep == null) {
        throw new InvalidOperationException ("Couldn't find valid Ice endpoint/channel for " + o);
      }

      Ice.ProxyData pd = new Ice.ProxyData();
      pd.id = proxy_ident;
      pd.facet = new string[0];
      pd.mode = ProxyMode.Twoway; // FIXME -- do I need to send multiple proxy things here?
      pd.secure = false;

      WriteStruct (pd);
      WriteSize (1);            // one endpoint follows

      // tcp endpoint encapsulation
      WriteObject ((short) 1);  // it's a TCP endpoint
      BeginEncapsulation();
      Ice.TcpEndpoint te = proxy_ep as Ice.TcpEndpoint;
      Write (te.host);
      WriteObject (te.port);
      WriteObject (te.timeout);
      WriteObject (te.compress);
      EndEncapsulation();
    }