Specifies an asynchronous callback that is executed after the completion of a network transaction
Beispiel #1
0
        private void ICreatePlayer()
        {
            pnCli2Auth_PlayerCreateRequest req = new pnCli2Auth_PlayerCreateRequest();
            req.Read(fStream);
            ENetError status = ENetError.kNetPending;

            // An empty Guid signifies we haven't logged in
            if (fAcctGuid == Guid.Empty)
                status = ENetError.kNetErrAuthenticationFailed;

            // Only CCR+ may create special avatars
            if (fPermissions < pnAcctPerms.CCR) {
                if (req.fShape.ToLower() != "male" &&
                    req.fShape.ToLower() != "female")
                    status = ENetError.kNetErrPlayerNameInvalid; // Close enough?
            }

            if (status == ENetError.kNetPending) {
                // Forward to the vault server
                // TODO: Reserved and Blacklisted player name list?
                pnCallback cb = new pnCallback(new pnVaultPlayerCreated(IOnPlayerCreated), req.fTransID);
                fVaultCli.CreatePlayer(fAcctGuid, req.fPlayerName, req.fShape, cb);
            } else {
                // I don't think so...
                pnAuth2Cli_PlayerCreateReply reply = new pnAuth2Cli_PlayerCreateReply();
                reply.fResult = status;
                reply.fTransID = req.fTransID;
                reply.Send(fStream);
            }
        }
Beispiel #2
0
        public void GetBuildId(pnCallback cb = null)
        {
            pnCli2File_BuildIdRequest req = new pnCli2File_BuildIdRequest();
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #3
0
        public void GetAuthSrvIP(pnCallback cb = null)
        {
            pnCli2Gate_AuthSrvIpAddressRequest req = new pnCli2Gate_AuthSrvIpAddressRequest();
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Requests the IP address of an active file server
        /// </summary>
        /// <param name="isPatcher">Specifies whether or not this client is a patcher</param>
        /// <param name="cb">Optional callback descriptor</param>
        /// <seealso cref="pnGateFileIP"/>
        public void GetFileSrvIP(bool isPatcher, pnCallback cb = null)
        {
            pnCli2Gate_FileSrvIpAddressRequest req = new pnCli2Gate_FileSrvIpAddressRequest();
            req.fIsPatcher = isPatcher;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #5
0
        public void FetchVaultNodeRefs(uint nodeID, pnCallback cb = null)
        {
            pnCli2Auth_VaultFetchNodeRefs req = new pnCli2Auth_VaultFetchNodeRefs();
            req.fNodeID = nodeID;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #6
0
        public void FetchNode(uint nodeID, pnCallback cb = null)
        {
            pnCli2Vault_NodeFetch req = new pnCli2Vault_NodeFetch();
            req.fNodeID = nodeID;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #7
0
        public void Ping(uint ms, byte[] payload = null, pnCallback cb = null)
        {
            pnCli2Gate_PingRequest req = new pnCli2Gate_PingRequest();
            req.fPayload = payload;
            req.fPingTimeMs = ms;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #8
0
        public void CreatePlayer(Guid acct, string name, string shape, pnCallback cb = null)
        {
            pnCli2Vault_PlayerCreateRequest req = new pnCli2Vault_PlayerCreateRequest();
            req.fAcctGuid = acct;
            req.fPlayerName = name;
            req.fShape = shape;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #9
0
        public void AddVaultNode(uint parentID, uint childID, uint saverID, pnCallback cb = null)
        {
            pnCli2Auth_VaultNodeAdd req = new pnCli2Auth_VaultNodeAdd();
            req.fChildID = childID;
            req.fParentID = parentID;
            req.fSaverID = saverID;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #10
0
        public void AcctLogin(string user, byte[] hash, uint cliChg, uint srvChg, pnCallback cb = null)
        {
            pnCli2Vault_AcctLoginRequest req = new pnCli2Vault_AcctLoginRequest();
            req.fAccount = user;
            req.fCliChg = cliChg;
            req.fHash = hash;
            req.fSrvChg = srvChg;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #11
0
        public void Login(string user, string pass, pnCallback cb = null)
        {
            // Logging in is a two step process:
            // First, we must register with the server and get a server challenge
            // Then, we actually login.
            // We will make it easy on the programmer and silently register the client :)
            if (fSrvChg.HasValue)
                ILogin(user, pass, cb);
            else {
                // Unfortunately, RegisterRequests have no TransID, so we can't save our
                // params using the normal way... So, we must use this ugly HACK.
                fEvilTemporaryHack = new LoginData(user, pass, cb);

                // Back to the regularly scheduled programming
                pnCli2Auth_ClientRegisterRequest req = new pnCli2Auth_ClientRegisterRequest();
                req.fBuildID = fConnHdr.fBuildID;
                lock (fStream) req.Send(fStream);
            }
        }
Beispiel #12
0
 public LoginData(string user, string pass, pnCallback cb)
 {
     fUser = user;
     fPass = pass;
     fCallback = cb;
 }
Beispiel #13
0
        private void ILogin(string user, string pass, pnCallback cb)
        {
            pnCli2Auth_AcctLoginRequest req = new pnCli2Auth_AcctLoginRequest();
            req.fAccount = user;
            req.fChallenge = BitConverter.ToUInt32(OpenSSL.RNG.Random(4), 0);
            req.fHash = pnHelpers.HashLogin(user, pass, req.fChallenge, fSrvChg.HasValue ? fSrvChg.Value : 0);
            switch (Environment.OSVersion.Platform) {
                case PlatformID.MacOSX:
                    req.fOS = "mac";
                    break;
                case PlatformID.Unix:
                    req.fOS = "nix";
                    break;
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                case PlatformID.WinCE:
                    req.fOS = "win";
                    break;
                case PlatformID.Xbox:
                    req.fOS = "xbox";
                    break;
                default:
                    req.fOS = "unknown";
                    break;
            }
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #14
0
        public void SetPlayer(uint playerID, pnCallback cb = null)
        {
            pnCli2Auth_AcctSetPlayerRequest req = new pnCli2Auth_AcctSetPlayerRequest();
            req.fPlayerID = playerID;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #15
0
        public void SaveVaultNode(pnVaultNode node, pnCallback cb = null)
        {
            pnCli2Auth_VaultNodeSave req = new pnCli2Auth_VaultNodeSave();
            req.fNode = node;
            req.fNodeID = node.NodeID;
            req.fRevision = Guid.NewGuid();
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #16
0
        public void FindNode(pnVaultNode pattern, pnCallback cb = null)
        {
            pnCli2Vault_NodeFind req = new pnCli2Vault_NodeFind();
            req.fPattern = pattern;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #17
0
        public void CreateVaultNode(pnVaultNode node, pnCallback cb = null)
        {
            pnCli2Auth_VaultNodeCreate req = new pnCli2Auth_VaultNodeCreate();
            req.fNode = node;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }
Beispiel #18
0
        public void SetPlayer(uint playerID, Guid acct, pnCallback cb = null)
        {
            pnCli2Vault_PlayerSetRequest req = new pnCli2Vault_PlayerSetRequest();
            req.fAcctGuid = acct;
            req.fPlayerID = playerID;
            req.fTransID = GetTransID();

            lock (fStream) {
                if (cb != null)
                    fCallbacks.Add(req.fTransID, cb);
                req.Send(fStream);
            }
        }