Ejemplo n.º 1
0
        public void InitSocket()
        {
            network.Init(NetTool.GetIP(serverInfo.Address), NetTool.GetPort(serverInfo.Address));

            Logger.Log("Init Network (Battle) [{0}]", serverInfo.Address);

            network.heartbeat.onTimeout = OnTimeout;
            network.onConnected         = () =>
            {
                Logger.Log("Network Connect Success (Battle Server).");
                if (m_needReconnnect)
                {
                    SendReconnect();
                }
                else
                {
                    Login();
                }
            };
        }
Ejemplo n.º 2
0
        private void InitSocket()
        {
            //Init
            string ip     = NetTool.GetIP(serverInfo.Address);
            int    port   = NetTool.GetPort(serverInfo.Address);
            var    socket = new Plugins.Network.WebSocketClient();

            socket.Setup(ip, port);
            var serializer = new ProtoSerializer();

            serializer.getTypeFunc = (name) => { return(System.Type.GetType(name)); };
            serializer.LoadProtoNum(typeof(ProtoNum));
            network.Init(socket, serializer);

            Debug.Log("Init Network (Battle) [{0}]".FormatStr(serverInfo.Address));

            network.onConnected = () =>
            {
                isConnected = true;
                Debug.Log("Network Connect Success (Battle Server).");
                Login();
            };
        }