예제 #1
0
        protected Protocol(MineLibClient client, ProtocolPurpose purpose)
        {
            Client = client;
            switch (purpose)
            {
            case ProtocolPurpose.Play:
                State = ClientState.Joining;
                break;

            case ProtocolPurpose.InfoRequest:
                State = ClientState.InfoRequest;
                break;
            }
        }
        public ModularProtocolHandler(MineLibClient client, AssemblyInfo assemblyInfo, string login = "", string password = "") : base(client, assemblyInfo)
        {
            var protocolType = AssemblyParser.FindType <Protocol>(AssemblyInfo, "ProtocolModern_1.7.10");

            if (protocolType == null)
            {
                throw new NetworkHandlerException($"Protocol loading error: {AssemblyInfo.FileName} was not found or corrupted.");
            }

            try { Protocol = (Protocol)Activator.CreateInstance(protocolType, Client, ProtocolPurpose.Play); }
            catch (MissingMemberException) { throw new NetworkHandlerException("Protocol not supported."); }

            if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password))
            {
                if (!Protocol.Login(login, password).Result)
                {
                    throw new NetworkHandlerException("Login Failed");
                }
            }
        }
예제 #3
0
 protected ProtocolHandler(MineLibClient client, AssemblyInfo assemblyInfo)
 {
     Client = client; AssemblyInfo = assemblyInfo;
 }