Init() public method

public Init ( ) : void
return void
示例#1
0
        async private static void StartGame(string username, string password)
        {
            UserScreen screen     = new UserScreen();
            NetManager netManager = new NetManager(screen);

            netManager.Init();

            if (loginState == LoginState.UNAVAILABLE)
            {
                loginMessage = "The server is unavailable.";
                loginState   = LoginState.MENU;
                return;
            }

            string hashedPassword = Hash(password);

            netManager.Login(username, hashedPassword);

            loginMessage = "Logging in...";

            loginState = LoginState.LOGGING_IN;

            for (int i = 0; i < 1000; i++)
            {
                await Task.Delay(10);

                if (loginState != LoginState.LOGGING_IN)
                {
                    break;
                }
            }
            if (loginState == LoginState.LOGGING_IN)
            {
                loginState   = LoginState.MENU;
                loginMessage = "Login Timeout";
            }
            else if (loginState == LoginState.LOGGED)
            {
                loginMessage      = "";
                currentState      = MenuState.LOGIN;
                screen.netManager = netManager;
                screen.username   = username;
                GuiData.hot       = -1;
                InPasswordMode    = false;
                Hacknet.Gui.TextBox.MaskingText    = false;
                Hacknet.Gui.TextBox.cursorPosition = 0;
                bMenu.ScreenManager.AddScreen(screen, new PlayerIndex?(bMenu.ScreenManager.controllingPlayer));
            }
            else if (loginState == LoginState.INVALID)
            {
                loginMessage = "Invalid Username or Password.";
            }
            else if (loginState == LoginState.UNAVAILABLE)
            {
                loginMessage = "The server is unavailable.";
            }

            loginState = LoginState.MENU;
            ResetForLogin();
        }
示例#2
0
        public void Init()
        {
            ResourceStorage.DecompressMidiBundle();

            jsonStorage = new JsonStorage();
            jsonStorage.Load();

            uiState          = jsonStorage.Get(JsonStorageKeys.V1.UI_STATE, Storage.Protos.Json.V1.UiStateProto.CreateDefault());
            midiSynthConfigs = jsonStorage.Get(JsonStorageKeys.V1.MIDI_SYNTH_CONFIGS, Storage.Protos.Json.V1.MidiSynthConfigsProto.CreateDefault());
            gameplayConfig   = jsonStorage.Get(JsonStorageKeys.V1.GAMEPLAY_CONFIG, Storage.Protos.Json.V1.GameplayConfigProto.CreateDefault());
            appConfig        = jsonStorage.Get(JsonStorageKeys.V1.APP_CONFIG, Storage.Protos.Json.V1.AppConfigProto.CreateDefault());

            localDb = new LocalDb();
            localDb.Init();

            username = PlayerPrefs.GetString("TEMP_USERNAME", null);
            password = PlayerPrefs.GetString("TEMP_PASSWORD", null);

            netManager = new NetManager();
            netManager.Init(this);

            translationSevice = new TranslationService();
            translationSevice.Init(netManager);
            translationSevice.Load();
            translationSevice.lang = appConfig.displayLang;

            resourceStorage = new ResourceStorage();
            resourceStorage.Init(this);

            InitAudioConfig();
            ApplyAppAudioConfig();
        }
    void Awake()
    {
        net = gameObject.AddComponent <NetManager> ();
        net.Init();

        net.messageReceived      += ReceiveMessageFromClient;
        net.onUpdateConnection   += OnUpdateConnection;
        net.onSocketDisconnected += OnSocketDisconnect;
    }
示例#4
0
        public void Init()
        {
            m_net = new NetManager();
            m_net.Init(typeof(KCPConnection), (int)ConnID.ZoneServer, 0);
            m_net.RegisterRPCListener(this);

            m_heartbeat = new HeartBeatHandler();
            m_heartbeat.Init(m_net);
        }
示例#5
0
        public override void Start()
        {
            base.Start();

            m_net = new NetManager();
            m_net.Init(2939);

            m_ipc = new IPCManager();
            m_ipc.Init(id);
        }
    public void Init()
    {
        NetManager.Init();

        Assert.AreEqual(true, NetManager.mIsInitialized);
        Assert.AreNotEqual(null, NetManager.mChannelReliable);
        Assert.AreNotEqual(null, NetManager.mChannelUnreliable);
        Assert.AreNotEqual(null, NetManager.mConnectionConfig);

        NetManager.Shutdown();
    }
        public void Init()
        {
            m_net = new NetManager();
            m_net.Init(typeof(KCPConnection), ServerID.ZoneServer, 0);
            m_net.RegisterRPCListener(this);

            GlobalEvent.onUpdate.AddListener(OnUpdate);

            m_heartbeat = new HeartBeatHandler();
            m_heartbeat.Init(m_net);
            m_heartbeat.onTimeout.AddListener(OnHeartBeatTimeout);
        }
示例#8
0
    void Start()
    {
        //初始化各管理器
        NetMgr = this.gameObject.AddComponent <NetManager>();
        EvtMgr = this.gameObject.AddComponent <EventManager>();
        ResMgr = this.gameObject.AddComponent <ResManager>();

        ResMgr.Init();
        EvtMgr.Init();
        NetMgr.Init(m_defaultZone);
        NetMgr.Connect(ServerIP, ServerPort);
    }
    public void CreateServerWithSim()
    {
        NetManager.Init();

        NetServer s = NetManager.CreateServer(30, 7777, 10, 100);

        Assert.IsNotNull(s);
        Assert.IsTrue(NetUtils.IsSocketValid(s.mSocket));
        Assert.IsTrue(s.mIsRunning);
        Assert.AreEqual(7777, s.mPort);

        NetManager.Shutdown();
    }
    public void CreateServer()
    {
        NetManager.Init();

        NetServer s = NetManager.CreateServer(30, 7777);

        Assert.IsNotNull(s);
        Assert.IsTrue(NetUtils.IsSocketValid(s.mSocket));
        Assert.IsTrue(s.mIsRunning);
        Assert.AreEqual(7777, s.mPort);

        NetworkTransport.RemoveHost(s.mSocket);
        NetManager.Shutdown();
    }
示例#11
0
    // Use this for initialization
    void Start()
    {
        NetManager.Init();

        // Set up our console
        DebugConsole.IsOpen = true;
        DebugConsole.RegisterCommand("server.start", ConsoleServerStart);
        DebugConsole.RegisterCommand("client.connect", ConsoleClientConnect);
        DebugConsole.RegisterCommand("client.disconnect", ConsoleClientDisconnect);
        DebugConsole.RegisterCommand("client.send", ConsoleClientSend);
        DebugConsole.RegisterCommand("server.send", ConsoleServerSend);
        DebugConsole.RegisterCommand("server.getclients", ConsoleServerGetClients);
        DebugConsole.RegisterCommand("server.broadcast", ConsoleServerBroadcast);
        DebugConsole.RegisterCommand("server.disconnect", ConsoleServerDisconnect);
        DebugConsole.RegisterCommand("network.test", FullLocalTest);
    }
示例#12
0
    /// <summary>
    /// 全局类初始化
    /// </summary>
    public void Init()
    {
        cfg = this.gameObject.AddComponent <ConfigManager>();
        cfg.Init();
        net = this.gameObject.AddComponent <NetManager>();
        net.Init();
        evt = this.gameObject.AddComponent <EventManager>();
        evt.Init();
        res = this.gameObject.AddComponent <ResManager>();
        res.Init();
        ui = this.gameObject.AddComponent <UIManager>();
        ui.Init();



        Global.Ui.SwitchUI(StartUIName);
    }
示例#13
0
        public override void Start()
        {
            base.Start();

            m_net = new NetManager();
            m_net.Init(4540);

            m_ipc = new IPCManager();
            m_ipc.Init(id);

            m_context     = new ServerContext();
            m_context.net = m_net;
            m_context.ipc = m_ipc;

            //业务逻辑初始化
            OnlineManager.Instance.Init(m_context);
            RoomManager.Instance.Init(m_context);

            ConsoleInput.onInputLine.AddListener(OnInputLine);
            ConsoleInput.onInputKey.AddListener(OnInputKey);
        }
        public override void Start()
        {
            base.Start();
            var net = new NetManager();

            net.Init(port);

            var ipc = new IPCManager();

            ipc.Init(id);

            m_context     = new ServerContext();
            m_context.net = net;
            m_context.ipc = ipc;

            OnlineManager.Instance.Init(m_context);
            RoomManager.Instance.Init(m_context);

            ConsoleInput.onInputLine.AddListener(OnInputLine);
            ConsoleInput.onInputKey.AddListener(OnInputKey);
        }
示例#15
0
        async private static void StartGame(string username, string password)
        {
            UserScreen screen     = new UserScreen();
            NetManager netManager = new NetManager(screen);

            netManager.Init();

            if (loginState == LoginState.UNAVAILABLE)
            {
                loginMessage = "The server is unavailable.";
                loginState   = LoginState.MENU;
                return;
            }

            string hashedPassword = Hash(password);

            netManager.Login(username, hashedPassword);

            loginMessage = "Logging in...";

            loginState = LoginState.LOGGING_IN;

            for (int i = 0; i < 1000; i++)
            {
                await Task.Delay(10);

                if (loginState != LoginState.LOGGING_IN)
                {
                    break;
                }
            }
            if (loginState == LoginState.LOGGING_IN)
            {
                loginState   = LoginState.MENU;
                loginMessage = "Login Timeout";
            }
            else if (loginState == LoginState.LOGGED)
            {
                preset = RPHandler.State.InGame;
                RPCHandler.PresencePresetSet(preset);
                loginMessage      = "";
                currentState      = MenuState.LOGIN;
                screen.netManager = netManager;
                screen.username   = username;
                GuiData.hot       = -1;
                InPasswordMode    = false;
                Hacknet.Gui.TextBox.MaskingText    = false;
                Hacknet.Gui.TextBox.cursorPosition = 0;
                bMenu.ScreenManager.AddScreen(screen, new PlayerIndex?(bMenu.ScreenManager.controllingPlayer));
            }
            else if (loginState == LoginState.INVALID)
            {
                loginMessage = "Invalid Username or Password.";
            }
            else if (loginState == LoginState.UNAVAILABLE)
            {
                loginMessage = "The server is unavailable.";
            }
            else if (loginState == LoginState.SERVER_REJECTED)
            {
                string reason = string.IsNullOrWhiteSpace(serverRejectReason) ? "Server did not provide reason for rejection" : serverRejectReason;
                loginMessage       = "The server rejected the connection: " + reason;
                serverRejectReason = "";
            }

            loginState = LoginState.MENU;
            ResetForLogin();
        }
	void Awake () {
		net = gameObject.AddComponent<NetManager> ();
		net.Init ();

		net.messageReceived += ReceiveMessageFromClient;
		net.onUpdateConnection += OnUpdateConnection;
		net.onSocketDisconnected += OnSocketDisconnect;
	}