Esempio n. 1
0
        public void Replace(string hostname, ushort port)
        {
            if (addr_list_.Count <= 0)
            {
                return;
            }

            HostAddr addr = addr_list_[0];

            Clear();

            if (addr is HostHttp)
            {
                HostHttp http = (HostHttp)addr;
                Add(hostname, port, http.https);
            }
            else
            {
                Add(hostname, port);
            }
        }
Esempio n. 2
0
        public bool Redirect(TransportProtocol protocol, HostAddr addr, bool keep_session_id = false)
        {
            FunapiTransport transport = GetTransport(protocol);
            if (transport == null)
            {
                DebugUtils.LogWarning("Redirect - Can't find a {0} transport.", protocol);
                return false;
            }

            if (!keep_session_id)
            {
                InitSession();
            }

            transport.Redirect(addr);
            return true;
        }
Esempio n. 3
0
        //---------------------------------------------------------------------
        // Connect-related functions
        //---------------------------------------------------------------------
        // For http transport, Pass a HostHttp instead of HostAddr.
        public bool Connect(TransportProtocol protocol, FunEncoding type, HostAddr addr)
        {
            FunapiTransport transport = GetTransport(protocol);
            if (transport == null)
            {
                DebugUtils.LogWarning("Connect - Can't find a {0} transport.", protocol);
                return false;
            }

            transport.Encoding = type;
            transport.ResetAddress(addr);

            transport.Connect();
            return true;
        }
 internal void Add (HostAddr addr)
 {
     addr_list_.Add(addr);
 }
        internal override void SetAddress(HostAddr addr)
        {
            DebugUtils.Assert(addr is HostHttp);
            HostHttp http = (HostHttp)addr;

            // Url
            host_url_ = String.Format("{0}://{1}:{2}/v{3}/",
                                      (http.https ? "https" : "http"), http.host, http.port,
                                      FunapiVersion.kProtocolVersion);

            Debug.Log(String.Format("SetAddress - {0}:{1}", http.host, http.port));
        }
        internal override void SetAddress(HostAddr addr)
        {
            IPAddress ip = null;
            if (addr is HostIP)
            {
                ip = ((HostIP)addr).ip;
            }
            else
            {
                IPHostEntry host_info = Dns.GetHostEntry(addr.host);
                DebugUtils.Assert(host_info.AddressList.Length > 0);
                ip = host_info.AddressList[0];
            }

            send_ep_ = new IPEndPoint(ip, addr.port);
            receive_ep_ = (EndPoint)new IPEndPoint(IPAddress.Any, addr.port);
            Debug.Log(String.Format("SetAddress - {0}:{1}", ip, addr.port));
        }
 internal abstract void SetAddress(HostAddr addr);
        internal void Redirect(HostAddr addr)
        {
            Debug.Log(String.Format("Redirect {0} [{1}:{2}]", str_protocol, addr.host, addr.port));

            if (Started) {
                Stop();
            }

            AddToEventQueue(
                delegate {
                    cstate_ = ConnectState.kRedirecting;
                    Connect(addr);
                }
            );
        }
 internal void Connect(HostAddr addr)
 {
     SetAddress(addr);
     Connect();
 }
        // Sets address
        public void ResetAddress(HostAddr addr)
        {
            ip_list_.Clear();

            if (addr is HostHttp)
                ip_list_.Add(addr.host, addr.port, ((HostHttp)addr).https);
            else
                ip_list_.Add(addr.host, addr.port);

            SetNextAddress();
        }
        internal override void SetAddress (HostAddr addr)
        {
            IPAddress ip = null;
            if (addr is HostIP)
            {
                ip = ((HostIP)addr).ip;
            }
            else
            {
                IPHostEntry host_info = Dns.GetHostEntry(addr.host);
                DebugUtils.Assert(host_info.AddressList.Length > 0);
                ip = host_info.AddressList[0];
            }

            connect_ep_ = new IPEndPoint(ip, addr.port);
            DebugUtils.Log("SetAddress - {0}:{1}", ip, addr.port);
        }
Esempio n. 12
0
 internal void Add(HostAddr addr)
 {
     addr_list_.Add(addr);
 }