コード例 #1
0
ファイル: Protocol.cs プロジェクト: MineLib/MineLib.Core
        protected Protocol(MineLibClient client, ProtocolPurpose purpose)
        {
            Client = client;
            switch (purpose)
            {
            case ProtocolPurpose.Play:
                State = ClientState.Joining;
                break;

            case ProtocolPurpose.InfoRequest:
                State = ClientState.InfoRequest;
                break;
            }
        }
コード例 #2
0
        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;
 }