public void SpawnRoom1Elements()
    {
        GameObject   keyProxyObj = PhotonNetwork.Instantiate("KeyProxy", m_key.transform.position, m_key.transform.rotation, 0);
        NetworkProxy keyProxy    = keyProxyObj.GetComponent <NetworkProxy>();

        keyProxy.m_TransformToCopy = m_key.transform;
        keyProxyObj.GetComponent <MeshRenderer>().enabled = false;

        GameObject   doorProxyObj = PhotonNetwork.Instantiate("DoorProxy", m_Door.transform.position, m_Door.transform.rotation, 0);
        NetworkProxy doorProxy    = doorProxyObj.GetComponent <NetworkProxy>();

        doorProxy.m_TransformToCopy = m_Door.transform;

        GameObject   drawerProxyObj = PhotonNetwork.Instantiate("DrawerProxy", m_Drawer.transform.position, m_Drawer.transform.rotation, 0);
        NetworkProxy drawerProxy    = drawerProxyObj.GetComponent <NetworkProxy>();

        drawerProxy.m_TransformToCopy = m_Drawer.transform;

        GameObject   valveProxyObj = PhotonNetwork.Instantiate("KnobProxy", m_Valve.transform.position, m_Valve.transform.rotation, 0);
        NetworkProxy valveProxy    = valveProxyObj.GetComponent <NetworkProxy>();

        valveProxy.m_TransformToCopy = m_Valve.transform;

        foreach (GameObject switchObj in m_Switches)
        {
            GameObject   networkSwitchObj   = PhotonNetwork.Instantiate("SwitchHandleProxy", switchObj.transform.position, switchObj.transform.rotation, 0);
            NetworkProxy networkSwitchProxy = networkSwitchObj.GetComponent <NetworkProxy>();
            networkSwitchProxy.m_TransformToCopy = switchObj.transform;
        }
    }
    public void AddGearPlayer()
    {
        if (PhotonNetwork.room != null)
        {
            int numGearPlayers = 0;
            if (PhotonNetwork.room.customProperties["gearNum"] != null)
            {
                numGearPlayers = (int)PhotonNetwork.room.customProperties["gearNum"];
            }
            numGearPlayers++;

            Hashtable newPlayerProps = new Hashtable();
            newPlayerProps.Add("numGears", numGearPlayers);
            PhotonNetwork.player.SetCustomProperties(newPlayerProps);

            Hashtable newRoomProperties = new Hashtable();
            newRoomProperties.Add("gearNum", numGearPlayers);
            PhotonNetwork.room.SetCustomProperties(newRoomProperties);

            m_Head.transform.position = m_GearVRSpawns[numGearPlayers - 1].position;

            Transform    gearProxyPosition = m_GearProxyPositions[numGearPlayers - 1];
            GameObject   headProxyObj      = PhotonNetwork.Instantiate("GearHeadProxy", gearProxyPosition.position, Quaternion.identity, 0);
            NetworkProxy headProxy         = headProxyObj.GetComponent <NetworkProxy>();
            headProxy.m_TransformToCopy = m_Head;

            GameObject   headProxyObjForGearRoom = PhotonNetwork.Instantiate("GearHeadProxyForGearRoom", m_GearVRSpawns[numGearPlayers - 1].position, Quaternion.identity, 0);
            NetworkProxy headProxyForGearRoom    = headProxyObjForGearRoom.GetComponent <NetworkProxy>();
            headProxyForGearRoom.m_TransformToCopy = m_Head;
        }
    }
Beispiel #3
0
        // TODO: Implement lazy load pattern so each instance creation doesn't create every object instance for no reason")]
        public TMDbClient(ITMDbSettings settings) : base(settings.BaseUrl)
        {
            if (settings.ApiKey.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(settings.ApiKey));
            }

            Settings        = settings;
            Account         = new AccountProxy(this);
            Authentication  = new AuthenticationProxy(this);
            Certifications  = new CertificationsProxy(this);
            Changes         = new ChangesProxy(this);
            Collections     = new CollectionsProxy(this);
            Configuration   = new ConfigurationProxy(this);
            Credits         = new CreditsProxy(this);
            Discover        = new DiscoverProxy(this);
            Exports         = new ExportsProxy(this);
            Find            = new FindProxy(this);
            Genres          = new GenresProxy(this);
            GuestSessions   = new GuestSessionsProxy(this);
            Keywords        = new KeywordsProxy(this);
            Lists           = new ListsProxy(this);
            Movies          = new MoviesProxy(this);
            Network         = new NetworkProxy(this);
            People          = new PeopleProxy(this);
            Reviews         = new ReviewsProxy(this);
            Search          = new SearchProxy(this);
            Trending        = new TrendingProxy(this);
            TVEpisodeGroups = new TVEpisodeGroupsProxy(this);
            TVEpisodes      = new TVEpisodesProxy(this);
            TV        = new TVProxy(this);
            TVSeasons = new TVSeasonsProxy(this);
        }
 public override void End()
 {
     base.End();
     Network.Disconnect();
     MasterServer.UnregisterHost();
     NetworkProxy.End();
 }
Beispiel #5
0
        public StreamSocket(ProtocolInstance instance, NetworkProxy proxy, EndPoint addr, EndPoint sourceAddr)
        {
            _instance   = instance;
            _proxy      = proxy;
            _addr       = addr;
            _sourceAddr = sourceAddr;
            _fd         = Network.createSocket(false, (_proxy != null ? _proxy.getAddress() : _addr).AddressFamily);
            _state      = StateNeedConnect;

            Network.setBlock(_fd, false);
            Network.setTcpBufSize(_fd, _instance);

            _readEventArgs            = new SocketAsyncEventArgs();
            _readEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(ioCompleted);

            _writeEventArgs            = new SocketAsyncEventArgs();
            _writeEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(ioCompleted);

            //
            // For timeouts to work properly, we need to receive/send
            // the data in several chunks. Otherwise, we would only be
            // notified when all the data is received/written. The
            // connection timeout could easily be triggered when
            // receiging/sending large messages.
            //
            _maxSendPacketSize = Math.Max(512, Network.getSendBufferSize(_fd));
            _maxRecvPacketSize = Math.Max(512, Network.getRecvBufferSize(_fd));
        }
Beispiel #6
0
        public static void Main(string[] args)
        {
            //TestNetwork();
            if (args.Length == 0)
            {
                ServerUtil.RunServerInThread(typeof(Lockstep.Server.Servers.Program).Assembly, EServerType.DaemonServer);
                Thread.Sleep(TimeSpan.FromSeconds(3));
            }
            else
            {
                FakeClient._RandomSeed = DateTime.Now.Millisecond;
            }

            client = GetDebugClient();
            ClientUtil.RunClient(client);
            while (true)
            {
                var cmd = Console.ReadLine();
                if (cmd == "kc")
                {
                    client.DoDestroy();
                }

                if (cmd == "nc")
                {
                    client = GetDebugClient();
                    ClientUtil.RunClient(client);
                }
                Thread.Sleep(30);
            }
        }
 public override void Start()
 {
     base.Start();
     NetworkProxy.Start();
     setIncomingPassword();
     Network.InitializeServer(MAX_NUMBER_OF_OTHER_PLAYERS, PORT, USE_NAT_FACILITATOR);
     Exchange();
 }
    public void Connect(int index)
    {
        HostData host = hosts[index];
        int      port = NetworkGameFormatter.ParseCommentPort(host.comment);

        log("Connecting to: " + HostDataFormatter.getDebugName(host));
        NetworkProxy.Connect(port);
    }
        public List <Connector> resolve(string host, int port, Ice.EndpointSelectionType selType, EndpointI endpoint)
        {
            //
            // Try to get the addresses without DNS lookup. If this doesn't
            // work, we retry with DNS lookup (and observer).
            //
            NetworkProxy networkProxy = _instance.networkProxy();

            if (networkProxy == null)
            {
                List <EndPoint> addrs = Network.getAddresses(host, port, _protocol, selType, _preferIPv6, false);
                if (addrs.Count > 0)
                {
                    return(endpoint.connectors(addrs, null));
                }
            }

            Ice.Instrumentation.CommunicatorObserver obsv     = _instance.getObserver();
            Ice.Instrumentation.Observer             observer = null;
            if (obsv != null)
            {
                observer = obsv.getEndpointLookupObserver(endpoint);
                if (observer != null)
                {
                    observer.attach();
                }
            }

            List <Connector> connectors = null;

            try
            {
                if (networkProxy != null)
                {
                    networkProxy = networkProxy.resolveHost();
                }

                connectors = endpoint.connectors(Network.getAddresses(host, port, _protocol, selType, _preferIPv6,
                                                                      true),
                                                 networkProxy);
            }
            catch (Ice.LocalException ex)
            {
                if (observer != null)
                {
                    observer.failed(ex.ice_name());
                }
                throw ex;
            }
            finally
            {
                if (observer != null)
                {
                    observer.detach();
                }
            }
            return(connectors);
        }
Beispiel #10
0
        public void resolve(string host, int port, Ice.EndpointSelectionType selType, EndpointI endpoint,
                            EndpointI_connectors callback)
        {
            //
            // Try to get the addresses without DNS lookup. If this doesn't work, we queue a resolve
            // entry and the thread will take care of getting the endpoint addresses.
            //
            NetworkProxy networkProxy = _instance.networkProxy();

            if (networkProxy == null)
            {
                try
                {
                    List <EndPoint> addrs = Network.getAddresses(host, port, _protocol, selType, _preferIPv6, false);
                    if (addrs.Count > 0)
                    {
                        callback.connectors(endpoint.connectors(addrs, null));
                        return;
                    }
                }
                catch (Ice.LocalException ex)
                {
                    callback.exception(ex);
                    return;
                }
            }

            _m.Lock();
            try
            {
                Debug.Assert(!_destroyed);

                ResolveEntry entry = new ResolveEntry();
                entry.host     = host;
                entry.port     = port;
                entry.selType  = selType;
                entry.endpoint = endpoint;
                entry.callback = callback;

                Ice.Instrumentation.CommunicatorObserver obsv = _instance.getObserver();
                if (obsv != null)
                {
                    entry.observer = obsv.getEndpointLookupObserver(endpoint);
                    if (entry.observer != null)
                    {
                        entry.observer.attach();
                    }
                }

                _queue.AddLast(entry);
                _m.Notify();
            }
            finally
            {
                _m.Unlock();
            }
        }
Beispiel #11
0
        public virtual List <Connector> connectors(List <EndPoint> addresses, NetworkProxy proxy)
        {
            List <Connector> connectors = new List <Connector>();

            foreach (EndPoint p in addresses)
            {
                connectors.Add(createConnector(p, proxy));
            }
            return(connectors);
        }
Beispiel #12
0
        public override List <Connector> connectors(List <EndPoint> addresses, NetworkProxy networkProxy)
        {
            List <Connector> connectors = new List <Connector>();

            foreach (EndPoint addr in addresses)
            {
                connectors.Add(new UdpConnector(instance_, addr, _mcastInterface, _mcastTtl, connectionId_));
            }
            return(connectors);
        }
Beispiel #13
0
        public StreamSocket(ProtocolInstance instance, NetworkProxy proxy, EndPoint addr, EndPoint sourceAddr)
        {
            _proxy = proxy;
            _addr = addr;
            _sourceAddr = sourceAddr;
            _fd = Network.createSocket(false, (_proxy != null ? _proxy.getAddress() : _addr).AddressFamily);
            _state = StateNeedConnect;

            init(instance);
        }
Beispiel #14
0
        public override List <Connector> connectors(List <EndPoint> addresses, NetworkProxy networkProxy)
        {
            List <Connector> connectors = new List <Connector>();

            foreach (EndPoint addr in addresses)
            {
                connectors.Add(new TcpConnector(_instance, addr, networkProxy, _timeout, connectionId_));
            }
            return(connectors);
        }
Beispiel #15
0
 public static void RunClient(NetworkProxy loginManager)
 {
     clients.Add(loginManager);
     Console.WriteLine(
         "=============== LockstepPlatform FakeClient" + clients.Count + " Start!! ===============");
     if (clients.Count == 1)
     {
         var thread = new Thread(_RunClient);
         thread.Start(true);
     }
 }
Beispiel #16
0
        public StreamSocket(ProtocolInstance instance, NetworkProxy proxy, EndPoint addr, EndPoint sourceAddr)
        {
            _instance   = instance;
            _proxy      = proxy;
            _addr       = addr;
            _sourceAddr = sourceAddr;
            _fd         = Network.createSocket(false, (_proxy != null ? _proxy.getAddress() : _addr).AddressFamily);
            _state      = StateNeedConnect;

            init();
        }
Beispiel #17
0
        //
        // Only for use by TcpEndpoint
        //
        internal TcpConnector(Instance instance, EndPoint addr, NetworkProxy proxy, int timeout, string connectionId)
        {
            _instance     = instance;
            _traceLevels  = instance.traceLevels();
            _logger       = instance.initializationData().logger;
            _addr         = addr;
            _proxy        = proxy;
            _timeout      = timeout;
            _connectionId = connectionId;

            _hashCode = 5381;
            IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
Beispiel #18
0
        //
        // Only for use by TcpEndpoint
        //
        internal TcpConnector(Instance instance, EndPoint addr, NetworkProxy proxy, int timeout, string connectionId)
        {
            _instance = instance;
            _traceLevels = instance.traceLevels();
            _logger = instance.initializationData().logger;
            _addr = addr;
            _proxy = proxy;
            _timeout = timeout;
            _connectionId = connectionId;

            _hashCode = 5381;
            IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
Beispiel #19
0
        //
        // Only for use by TcpConnector, TcpAcceptor
        //
        internal TcpTransceiver(Instance instance, Socket fd, EndPoint addr, NetworkProxy proxy, bool connected)
        {
            _fd    = fd;
            _addr  = addr;
            _proxy = proxy;

            _traceLevels = instance.traceLevels();
            _logger      = instance.initializationData().logger;
            _stats       = instance.initializationData().stats;
            _state       = connected ? StateConnected : StateNeedConnect;
            _desc        = connected ? Network.fdToString(_fd, _proxy, _addr) : "<not connected>";

#if ICE_SOCKET_ASYNC_API
            _readEventArgs            = new SocketAsyncEventArgs();
            _readEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(ioCompleted);

            _writeEventArgs            = new SocketAsyncEventArgs();
            _writeEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(ioCompleted);
#if SILVERLIGHT
            String policy = instance.initializationData().properties.getProperty("Ice.ClientAccessPolicyProtocol");
            if (policy.Equals("Http"))
            {
                _readEventArgs.SocketClientAccessPolicyProtocol  = SocketClientAccessPolicyProtocol.Http;
                _writeEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http;
            }
            else if (!String.IsNullOrEmpty(policy))
            {
                _logger.warning("Ignoring invalid Ice.ClientAccessPolicyProtocol value `" + policy + "'");
            }
#endif
#endif

            _maxSendPacketSize = Network.getSendBufferSize(fd);
            if (_maxSendPacketSize < 512)
            {
                _maxSendPacketSize = 0;
            }

            _maxReceivePacketSize = Network.getRecvBufferSize(fd);
            if (_maxReceivePacketSize < 512)
            {
                _maxReceivePacketSize = 0;
            }
        }
Beispiel #20
0
        //
        // Only for use by TcpEndpoint
        //
        internal TcpConnector(ProtocolInstance instance, EndPoint addr, NetworkProxy proxy, EndPoint sourceAddr,
                              int timeout, string connectionId)
        {
            _instance     = instance;
            _addr         = addr;
            _proxy        = proxy;
            _sourceAddr   = sourceAddr;
            _timeout      = timeout;
            _connectionId = connectionId;

            _hashCode = 5381;
            HashUtil.hashAdd(ref _hashCode, _addr);
            if (_sourceAddr != null)
            {
                HashUtil.hashAdd(ref _hashCode, _sourceAddr);
            }
            HashUtil.hashAdd(ref _hashCode, _timeout);
            HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
    void SpawnHMDProxy()
    {
        //GameObject leftProxyObj = PhotonNetwork.Instantiate("Whirligig", new Vector3(-1.15f, 1.25f, 0.134f), Quaternion.identity, 0);
        GameObject   leftProxyObj  = PhotonNetwork.Instantiate("NetworkProxy", new Vector3(50f, 50f, 50f), Quaternion.identity, 0);
        GameObject   rightProxyObj = PhotonNetwork.Instantiate("NetworkProxy", new Vector3(50f, 50f, 50f), Quaternion.identity, 0);
        GameObject   headProxyObj  = PhotonNetwork.Instantiate("ViveHeadProxy", new Vector3(50f, 50f, 50f), Quaternion.identity, 0);
        NetworkProxy leftProxy     = leftProxyObj.GetComponent <NetworkProxy>();
        NetworkProxy rightProxy    = rightProxyObj.GetComponent <NetworkProxy>();
        NetworkProxy headProxy     = headProxyObj.GetComponent <NetworkProxy>();

        headProxyObj.GetComponentInChildren <MeshRenderer>().enabled  = false;
        leftProxyObj.GetComponentInChildren <MeshRenderer>().enabled  = false;
        rightProxyObj.GetComponentInChildren <MeshRenderer>().enabled = false;

        leftProxy.m_TransformToCopy  = m_LeftHand;
        rightProxy.m_TransformToCopy = m_RightHand;
        headProxy.m_TransformToCopy  = m_Head;
        headProxy.GetComponent <Camera>().enabled = false;
    }
Beispiel #22
0
        //
        // Only for use by TcpEndpoint
        //
        internal TcpConnector(ProtocolInstance instance, EndPoint addr, NetworkProxy proxy, EndPoint sourceAddr,
                              int timeout, string connectionId)
        {
            _instance = instance;
            _addr = addr;
            _proxy = proxy;
            _sourceAddr = sourceAddr;
            _timeout = timeout;
            _connectionId = connectionId;

            _hashCode = 5381;
            IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
            if(_sourceAddr != null)
            {
                IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr);
            }
            IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
Beispiel #23
0
        public static string fdToString(Socket socket, NetworkProxy proxy, EndPoint target)
        {
            try
            {
                if (socket == null)
                {
                    return("<closed>");
                }

                EndPoint remote = getRemoteAddress(socket);

                System.Text.StringBuilder s = new System.Text.StringBuilder();
                s.Append("local address = " + localAddrToString(getLocalAddress(socket)));
                if (proxy != null)
                {
                    if (remote == null)
                    {
                        remote = proxy.getAddress();
                    }
                    s.Append("\n" + proxy.getName() + " proxy address = " + remoteAddrToString(remote));
                    s.Append("\nremote address = " + remoteAddrToString(target));
                }
                else
                {
                    if (remote == null)
                    {
                        remote = target;
                    }
                    s.Append("\nremote address = " + remoteAddrToString(remote));
                }
                return(s.ToString());
            }
            catch (ObjectDisposedException)
            {
                return("<closed>");
            }
        }
Beispiel #24
0
 protected override Connector createConnector(EndPoint addr, NetworkProxy proxy)
 {
     return(new UdpConnector(instance_, addr, sourceAddr_, _mcastInterface, _mcastTtl, connectionId_));
 }
Beispiel #25
0
 protected abstract Connector createConnector(EndPoint addr, NetworkProxy proxy);
Beispiel #26
0
 public virtual List<Connector> connectors(List<EndPoint> addresses, NetworkProxy proxy)
 {
     List<Connector> connectors = new List<Connector>();
     foreach(EndPoint p in addresses)
     {
         connectors.Add(createConnector(p, proxy));
     }
     return connectors;
 }
        public void run()
        {
            while (true)
            {
                ResolveEntry r;
                Ice.Instrumentation.ThreadObserver threadObserver;

                lock (this)
                {
                    while (!_destroyed && _queue.Count == 0)
                    {
                        Monitor.Wait(this);
                    }

                    if (_destroyed)
                    {
                        break;
                    }

                    r = _queue.First.Value;
                    _queue.RemoveFirst();
                    threadObserver = _observer;
                }

                if (threadObserver != null)
                {
                    threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateIdle,
                                                Ice.Instrumentation.ThreadState.ThreadStateInUseForOther);
                }

                try
                {
                    NetworkProxy networkProxy = _instance.networkProxy();
                    int          protocol     = _protocol;
                    if (networkProxy != null)
                    {
                        networkProxy = networkProxy.resolveHost(protocol);
                        if (networkProxy != null)
                        {
                            protocol = networkProxy.getProtocolSupport();
                        }
                    }

                    List <EndPoint> addrs = Network.getAddresses(r.host, r.port, protocol, r.selType, _preferIPv6, true);
                    if (r.observer != null)
                    {
                        r.observer.detach();
                        r.observer = null;
                    }

                    r.callback.connectors(r.endpoint.connectors(addrs, networkProxy));
                }
                catch (Ice.LocalException ex)
                {
                    if (r.observer != null)
                    {
                        r.observer.failed(ex.ice_id());
                        r.observer.detach();
                    }
                    r.callback.exception(ex);
                }
                finally
                {
                    if (threadObserver != null)
                    {
                        threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateInUseForOther,
                                                    Ice.Instrumentation.ThreadState.ThreadStateIdle);
                    }
                }
            }

            foreach (ResolveEntry entry in _queue)
            {
                Ice.CommunicatorDestroyedException ex = new Ice.CommunicatorDestroyedException();
                if (entry.observer != null)
                {
                    entry.observer.failed(ex.ice_id());
                    entry.observer.detach();
                }
                entry.callback.exception(ex);
            }
            _queue.Clear();

            if (_observer != null)
            {
                _observer.detach();
            }
        }
Beispiel #28
0
 public override List<Connector> connectors(List<EndPoint> addresses, NetworkProxy networkProxy)
 {
     List<Connector> connectors = new List<Connector>();
     foreach(EndPoint addr in addresses)
     {
         connectors.Add(new TcpConnector(_instance, addr, networkProxy, _timeout, connectionId_));
     }
     return connectors;
 }
Beispiel #29
0
        //
        // Only for use by TcpConnector, TcpAcceptor
        //
        internal TcpTransceiver(Instance instance, Socket fd, EndPoint addr, NetworkProxy proxy, bool connected)
        {
            _fd = fd;
            _addr = addr;
            _proxy = proxy;
            
            _traceLevels = instance.traceLevels();
            _logger = instance.initializationData().logger;
            _stats = instance.initializationData().stats;
            _state = connected ? StateConnected : StateNeedConnect;
            _desc = connected ? Network.fdToString(_fd, _proxy, _addr) : "<not connected>";
            
#if ICE_SOCKET_ASYNC_API
            _readEventArgs = new SocketAsyncEventArgs();
            _readEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted);

            _writeEventArgs = new SocketAsyncEventArgs();
            _writeEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted);
#if SILVERLIGHT
            String policy = instance.initializationData().properties.getProperty("Ice.ClientAccessPolicyProtocol");
            if(policy.Equals("Http"))
            {
                _readEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http;
                _writeEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http;
            }
            else if(!String.IsNullOrEmpty(policy))
            {
                _logger.warning("Ignoring invalid Ice.ClientAccessPolicyProtocol value `" + policy + "'");
            }
#endif
#endif

            _maxSendPacketSize = Network.getSendBufferSize(fd);
            if(_maxSendPacketSize < 512)
            {
                _maxSendPacketSize = 0;
            }

            _maxReceivePacketSize = Network.getRecvBufferSize(fd);
            if(_maxReceivePacketSize < 512)
            {
                _maxReceivePacketSize = 0;
            }
        }
Beispiel #30
0
        private TraceLevels _traceLevels; // Immutable, not reset by destroy().

        #endregion Fields

        #region Constructors

        //
        // Only for use by Ice.CommunicatorI
        //
        public Instance(Ice.Communicator communicator, Ice.InitializationData initData)
        {
            _state = StateActive;
            _initData = initData;

            try
            {
                if(_initData.properties == null)
                {
                    _initData.properties = Ice.Util.createProperties();
                }

                lock(_staticLock)
                {
                    if(!_oneOffDone)
                    {
                        string stdOut = _initData.properties.getProperty("Ice.StdOut");
                        string stdErr = _initData.properties.getProperty("Ice.StdErr");

                        System.IO.StreamWriter outStream = null;

                        if(stdOut.Length > 0)
                        {
                            try
                            {
                                outStream = System.IO.File.AppendText(stdOut);
                            }
                            catch(System.IO.IOException ex)
                            {
                                Ice.FileException fe = new Ice.FileException(ex);
                                fe.path = stdOut;
                                throw fe;
                            }
                            outStream.AutoFlush = true;
                            System.Console.Out.Close();
                            System.Console.SetOut(outStream);
                        }
                        if(stdErr.Length > 0)
                        {
                            if(stdErr.Equals(stdOut))
                            {
                                System.Console.SetError(outStream);
                            }
                            else
                            {
                                System.IO.StreamWriter errStream = null;
                                try
                                {
                                    errStream = System.IO.File.AppendText(stdErr);
                                }
                                catch(System.IO.IOException ex)
                                {
                                    Ice.FileException fe = new Ice.FileException(ex);
                                    fe.path = stdErr;
                                    throw fe;
                                }
                                errStream.AutoFlush = true;
                                System.Console.Error.Close();
                                System.Console.SetError(errStream);
                            }
                        }

                        _oneOffDone = true;
                    }
                }

                if(_initData.logger == null)
                {
                    string logfile = _initData.properties.getProperty("Ice.LogFile");
                    if(_initData.properties.getPropertyAsInt("Ice.UseSyslog") > 0 &&
                       AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows)
                    {
                        if(logfile.Length != 0)
                        {
                            throw new Ice.InitializationException("Ice.LogFile and Ice.UseSyslog cannot both be set.");
                        }
                        _initData.logger = new Ice.SysLoggerI(_initData.properties.getProperty("Ice.ProgramName"),
                            _initData.properties.getPropertyWithDefault("Ice.SyslogFacility", "LOG_USER"));
                    }
                    else if(logfile.Length != 0)
                    {

                        _initData.logger =
                            new Ice.FileLoggerI(_initData.properties.getProperty("Ice.ProgramName"), logfile);
                    }
                    else if(Ice.Util.getProcessLogger() is Ice.LoggerI)
                    {
                        //
                        // Ice.ConsoleListener is enabled by default.
                        //
                        bool console =
                            _initData.properties.getPropertyAsIntWithDefault("Ice.ConsoleListener", 1) > 0;
                        _initData.logger =
                            new Ice.TraceLoggerI(_initData.properties.getProperty("Ice.ProgramName"), console);
                    }

                    if(Ice.Util.getProcessLogger() is Ice.LoggerI)
                    {
                        _initData.logger =
                            new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName"));
                    }
                    else
                    {
                        _initData.logger = Ice.Util.getProcessLogger();
                    }
                }

                _traceLevels = new TraceLevels(_initData.properties);

                _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger);

                _clientACM = new ACMConfig(_initData.properties,
                                           _initData.logger,
                                           "Ice.ACM.Client",
                                           new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM",
                                                         new ACMConfig(false)));

                _serverACM = new ACMConfig(_initData.properties,
                                           _initData.logger,
                                           "Ice.ACM.Server",
                                           new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM",
                                                         new ACMConfig(true)));

                {
                    const int defaultMessageSizeMax = 1024;
                    int num =
                        _initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
                    if(num < 1 || num > 0x7fffffff / 1024)
                    {
                        _messageSizeMax = 0x7fffffff;
                    }
                    else
                    {
                        _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
                    }
                }

                if(_initData.properties.getProperty("Ice.BatchAutoFlushSize").Length == 0 &&
                   _initData.properties.getProperty("Ice.BatchAutoFlush").Length > 0)
                {
                    if(_initData.properties.getPropertyAsInt("Ice.BatchAutoFlush") > 0)
                    {
                        _batchAutoFlushSize = _messageSizeMax;
                    }
                }
                else
                {
                    int num = _initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB
                    if(num < 1)
                    {
                        _batchAutoFlushSize = num;
                    }
                    else if(num > 0x7fffffff / 1024)
                    {
                        _batchAutoFlushSize = 0x7fffffff;
                    }
                    else
                    {
                        _batchAutoFlushSize = num * 1024; // Property is in kilobytes, _batchAutoFlushSize in bytes
                    }
                }

                _cacheMessageBuffers = _initData.properties.getPropertyAsIntWithDefault("Ice.CacheMessageBuffers", 2);

                _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getProperty("Ice.ImplicitContext"));
                _routerManager = new RouterManager();

                _locatorManager = new LocatorManager(_initData.properties);

                _referenceFactory = new ReferenceFactory(this, communicator);

                _proxyFactory = new ProxyFactory(this);

                _requestHandlerFactory = new RequestHandlerFactory(this);

                bool isIPv6Supported = Network.isIPv6Supported();
                bool ipv4 = _initData.properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0;
                bool ipv6 = _initData.properties.getPropertyAsIntWithDefault("Ice.IPv6", isIPv6Supported ? 1 : 0) > 0;
                if(!ipv4 && !ipv6)
                {
                    throw new Ice.InitializationException("Both IPV4 and IPv6 support cannot be disabled.");
                }
                else if(ipv4 && ipv6)
                {
                    _protocolSupport = Network.EnableBoth;
                }
                else if(ipv4)
                {
                    _protocolSupport = Network.EnableIPv4;
                }
                else
                {
                    _protocolSupport = Network.EnableIPv6;
                }
                _preferIPv6 = _initData.properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0;

                _networkProxy = createNetworkProxy(_initData.properties, _protocolSupport);

                _endpointFactoryManager = new EndpointFactoryManager(this);

                ProtocolInstance tcpInstance = new ProtocolInstance(this, Ice.TCPEndpointType.value, "tcp", false);
                _endpointFactoryManager.add(new TcpEndpointFactory(tcpInstance));

                ProtocolInstance udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false);
                _endpointFactoryManager.add(new UdpEndpointFactory(udpInstance));
                _pluginManager = new Ice.PluginManagerI(communicator);

                if(_initData.valueFactoryManager == null)
                {
                    _initData.valueFactoryManager = new ValueFactoryManagerI();
                }

                _outgoingConnectionFactory = new OutgoingConnectionFactory(communicator, this);

                _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);

                _retryQueue = new RetryQueue(this);
            }
            catch(Ice.LocalException)
            {
                destroy();
                throw;
            }
        }
Beispiel #31
0
 protected override Connector createConnector(EndPoint addr, NetworkProxy proxy)
 {
     return new TcpConnector(instance_, addr, proxy, sourceAddr_, _timeout, connectionId_);
 }
Beispiel #32
0
 protected abstract Connector createConnector(EndPoint addr, NetworkProxy proxy);
Beispiel #33
0
 public virtual void Start()
 {
     log("Network started");
     NetworkProxy.Initialize();
 }
Beispiel #34
0
 protected override Connector createConnector(EndPoint addr, NetworkProxy proxy)
 {
     return(new TcpConnector(instance_, addr, proxy, sourceAddr_, _timeout, connectionId_));
 }
Beispiel #35
0
 public virtual List <Connector> connectors(List <EndPoint> addresses, NetworkProxy proxy)
 {
     Debug.Assert(false);
     return(null);
 }
Beispiel #36
0
 protected override Connector createConnector(EndPoint addr, NetworkProxy proxy)
 {
     return new UdpConnector(instance_, addr, sourceAddr_, _mcastInterface, _mcastTtl, connectionId_);
 }
Beispiel #37
0
 public override List<Connector> connectors(List<EndPoint> addresses, NetworkProxy networkProxy)
 {
     List<Connector> connectors = new List<Connector>();
     foreach(EndPoint addr in addresses)
     {
         connectors.Add(new UdpConnector(instance_, addr, _mcastInterface, _mcastTtl, connectionId_));
     }
     return connectors;
 }