コード例 #1
0
ファイル: Connection.cs プロジェクト: ratiel/Vindictus
        private AsyncResult Transmit(Packet packet, string nexonID, string characterID, AsyncCallback callback, object state)
        {
            Log <Connection> .Logger.Info("Transmit - IN");

            AsyncResult asyncResult = new AsyncResult(nexonID, characterID, callback, state);

            Connection.Key key = new Connection.Key
            {
                NexonID     = asyncResult.NexonID,
                CharacterID = asyncResult.CharacterID
            };
            if (!this.Connected)
            {
                asyncResult.Complete(true);
                Log <Connection> .Logger.Info("Transmit - not Connected");

                return(asyncResult);
            }
            if (this.queries.ContainsKey(key))
            {
                asyncResult.Complete(true);
                Log <Connection> .Logger.Info("Transmit - ContainsKey");

                return(asyncResult);
            }
            this.queries.Add(key, asyncResult);
            this.Transmit(packet);
            Log <Connection> .Logger.Info("Transmit - OUT");

            return(asyncResult);
        }
コード例 #2
0
ファイル: Connection.cs プロジェクト: ratiel/Vindictus
        public void Logout(string nexonID, string characterID, IPAddress remoteAddress, bool canTry)
        {
            Logout logout = new Logout(nexonID, characterID, remoteAddress, canTry);

            this.Transmit(logout.Serialize());
            Connection.Key key = new Connection.Key
            {
                NexonID     = nexonID,
                CharacterID = characterID
            };
            AsyncResult asyncResult;

            if (this.queries.TryGetValue(key, out asyncResult))
            {
                this.queries.Remove(key);
                asyncResult.Response = null;
                asyncResult.Complete();
            }
        }
コード例 #3
0
ファイル: Connection.cs プロジェクト: ratiel/Vindictus
        private void Process(LoginResponse response)
        {
            Connection.Key key = new Connection.Key
            {
                NexonID     = response.NexonID,
                CharacterID = response.CharacterID
            };
            AsyncResult asyncResult;

            if (this.queries.TryGetValue(key, out asyncResult) && response.Result != Result.Message)
            {
                this.queries.Remove(key);
                asyncResult.Response = response;
                asyncResult.Complete();
                return;
            }
            if (this.MessageReceived != null)
            {
                this.MessageReceived(response);
            }
        }