Exemplo n.º 1
0
        public IEnumerator OnServerStart(Coroutine coroutine, ChatService _this)
        {
            //Thread.Sleep(GlobalVariable.WaitToConnectTimespan);
            ChatServer.Instance.Start(_this);
            ChatManager.Init();
            var __this = (ChatServerControl)_this;

            ChatManager.WebRequestManager = new RequestManager(__this);
            CityChatManager.Init();
            CharacterManager.Instance.Init(ChatServer.Instance.DB, DataCategory.ChatCharacter);
            AnchorManager.Instance.Init();
            ChatServer.Instance.IsReadyToEnter = true;

            _this.TickDuration = 0.5f;

            _this.Started = true;

            Console.WriteLine("ChatServer startOver. [{0}]", ChatServer.Instance.Id);
            yield break;
        }
Exemplo n.º 2
0
        public IEnumerator OnConnected(Coroutine coroutine, ChatCharacterProxy charProxy, AsyncReturnValue <bool> ret)
        {
            ret.Value = false;
            var proxy = (ChatProxy)charProxy;

            Logger.Info("[{0}] has enter connected", proxy.CharacterId);
            var characterId = proxy.CharacterId;

            var obj = CharacterManager.Instance.GetCharacterControllerFromMemroy(proxy.CharacterId);

            if (obj == null)
            {
                Logger.Fatal("onConnected CharacterId={0}", proxy.CharacterId);
                yield break;
            }

            var dbLoginSimple = ChatServer.Instance.LoginAgent.GetLoginSimpleData(proxy.ClientId, characterId);

            yield return(dbLoginSimple.SendAndWaitUntilDone(coroutine));

            if (dbLoginSimple.State != MessageState.Reply || dbLoginSimple.ErrorCode != (int)ErrorCodes.OK)
            {
                yield break;
            }
            proxy.Character = obj;
            obj.ServerId    = dbLoginSimple.Response.ServerId;
            obj.Proxy       = proxy;
            obj.Name        = dbLoginSimple.Response.Name;
            proxy.Connected = true;

            proxy.Character.State = CharacterState.Connected;

            CharacterManager.Instance.UpdateSimpleData(proxy.CharacterId);
            CityChatManager.EnterChannel(1, obj);
            obj.mChat.Online();

            ret.Value = true;
        }