Пример #1
0
            public bool Link(TPeerCnt PeerNum_, SIPPort IPPort_, Int32 ConnectTimeOut_)
            {
                try
                {
                    var Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    Socket.NoDelay = _NoDelay;

                    SKey Key = _PeerMgr.Link(PeerNum_);
                    if (Key == null)
                    {
                        return(false);
                    }

                    if (!_Peers[Key.PeerNum].Link(Socket, IPPort_, Key, _Worker, ConnectTimeOut_))
                    {
                        _PeerMgr.UnLink(Key.PeerNum);
                        return(false);
                    }

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
Пример #2
0
 public SKey(SKey k1)
 {
     m_key[0] = k1.m_key[0];
     m_key[1] = k1.m_key[1];
     m_key[2] = k1.m_key[2];
     m_key[3] = k1.m_key[3];
 }
Пример #3
0
            TPeerCnt _UnLinkCore()
            {
                if (_Key == null)
                {
                    return(TPeerCnt.MaxValue);
                }

                if (_Socket != null)
                {
                    _Socket.Close();
                    _Socket = null;
                }
                _RecvHeader    = null;
                _StreamSndTail = 0;
                _RecvPacketSeq = 0;
                _SendPacketSeq = 0;
                _StreamRcv.Clear();
                _StreamSnd.Clear();
                _LongIP         = 0;
                _Sending        = false;
                _Connected      = false;
                _ConnectTime    = 0;
                _ConnectTimeOut = 0;
                _Connecting     = false;

                var PeerNum = _Key.PeerNum;

                _Key = null;

                return(PeerNum);
            }
Пример #4
0
            public void Linked(SKey Key_)
            {
                if (!_IsValid(Key_))
                {
                    return;
                }

                _Linked();
            }
Пример #5
0
            public void LinkFailed(SKey Key_)
            {
                if (!Key_.Equals(_Key))
                {
                    return;
                }

                _LinkFailed();
            }
Пример #6
0
            public void UnLink(SKey Key_, Enum NetState_) // Socket 콜백
            {
                if (!_IsValid(Key_))
                {
                    return;
                }

                _UnLink(NetState_);
            }
Пример #7
0
            public void Recved(SKey Key_) // Socket 콜백 처리
            {
                if (!_IsValid(Key_))
                {
                    return;
                }

                _Recved();
            }
Пример #8
0
            public void Sended(SKey Key_)
            {
                if (!_IsValid(Key_))
                {
                    return;
                }

                if (_Sended())
                {
                    if (_StreamSnd.Size > 0)
                    {
                        _SendCore();
                    }
                }
            }
Пример #9
0
        public void GameProtoNetSc(SKey Key_, CStream Stream_)
        {
            var Proto = new SGameProtoNetSc();

            Proto.Push(Stream_);

            if (_Auto)
            {
//                _Log("ScFail CsProto:" + Proto.CsProto.ToString() + " ErrorNo:" + Proto.ErrorNo + " Msg:" + Proto.Msg);
            }
            else
            {
                _Log("GameProtoNetSc");
//                _Log("ScFail CsProto:" + Proto.CsProto.ToString() + " ErrorNo:" + Proto.ErrorNo + " Msg:" + Proto.Msg);
            }
        }
Пример #10
0
            public SKey Link(TPeerCnt PeerNum_)
            {
                SKey Key = new SKey(PeerNum_, _Counter);

                try
                {
                    _PeerList.Add(PeerNum_, Key);
                    Key.PeerNum = PeerNum_;
                    ++_Counter;

                    return(Key);
                }
                catch
                {
                    return(null);
                }
            }
Пример #11
0
            // 유저 호출
            public bool Link(Socket Socket_, SIPPort IPPort_, SKey Key_, TEventHandler RecvEventHandler_, Int32 ConnectTimeOut_)
            {
                if (_Socket != null)
                {
                    return(false);
                }

                _RecvEvent            = new SocketAsyncEventArgs();
                _RecvEvent.Completed += new EventHandler <SocketAsyncEventArgs>(RecvEventHandler_);
                _SendEvent            = new SocketAsyncEventArgs();
                _SendEvent.Completed += new EventHandler <SocketAsyncEventArgs>(RecvEventHandler_);

                _Socket = Socket_;

                _RecvEvent.UserToken      = Key_;
                _RecvEvent.RemoteEndPoint = IPPort_.EndPoint;

                _Key    = Key_;
                _LongIP = IPPort_.IP;

                try
                {
                    if (!_Socket.ConnectAsync(_RecvEvent))  // _Worker 로 통보받을 필요 없음.
                    {
                        _HBRcvPeriod.NextLoose();
                        return(_Linked());
                    }
                    else
                    {
                        _Connecting     = true;
                        _ConnectTime    = Environment.TickCount;
                        _ConnectTimeOut = ConnectTimeOut_;
                    }
                }
                catch
                {
                    _LinkFailed();
                    return(false);
                }

                return(true);
            }
Пример #12
0
        public StandFunBar()
        {
            float left      = 0;
            var   keyString = functionKeys.Split(' ');
            float width     = (float)(14.5 / 16.0);

            for (int i = 0; i < keyString.Length; i++)
            {
                string k = keyString[i];
                if (i < keyString.Length - 4)
                {
                    SKey key = new SKey(k, new System.Drawing.RectangleF(left, 0, width, 1))
                    {
                        Text  = keyString[i],
                        type  = "control",
                        value = keyString[i]
                    };
                    left      += width;
                    key.Click += (m, n) => {
                        KeyClick(key.GetKey());
                    };
                    keys.Add(key);
                }
                else
                {
                    SKey key = new SKey(k, new System.Drawing.RectangleF(left, 0, 1, 1))
                    {
                        Text  = keyString[i],
                        type  = "control",
                        value = keyString[i]
                    };
                    left      += 1;
                    key.Click += (m, n) => {
                        KeyClick(key.GetKey());
                    };
                    keys.Add(key);
                }
            }
            PreparParams();
        }
Пример #13
0
 public void Set(SKey Obj_)
 {
     PeerNum     = Obj_.PeerNum;
     PeerCounter = Obj_.PeerCounter;
 }
Пример #14
0
 public SUdNewChild(SUdNewChild Obj_)
 {
     ClientBindNamePortPub = Obj_.ClientBindNamePortPub;
     SessionCode           = Obj_.SessionCode;
     NewChildKey           = Obj_.NewChildKey;
 }
Пример #15
0
 public SUdNewChild(SNamePort ClientBindNamePortPub_, TSessionCode SessionCode_, SKey NewChildKey_)
 {
     ClientBindNamePortPub = ClientBindNamePortPub_;
     SessionCode           = SessionCode_;
     NewChildKey           = NewChildKey_;
 }
Пример #16
0
 public SDuNewChild(SDuNewChild Obj_)
 {
     NewChildKey = Obj_.NewChildKey;
     SessionCode = Obj_.SessionCode;
 }
Пример #17
0
 public SReLinkCs(SKey ServerExtKey_, TProtoSeq ClientProtoSeqMustRecv_)
 {
     ServerExtKey           = ServerExtKey_;
     ClientProtoSeqMustRecv = ClientProtoSeqMustRecv_;
 }
Пример #18
0
 public SDuNewChild(SKey NewChildKey_, TSessionCode SessionCode_)
 {
     NewChildKey = NewChildKey_;
     SessionCode = SessionCode_;
 }
Пример #19
0
 public SDuNewChildFail(SDuNewChildFail Obj_)
 {
     NewChildKey = Obj_.NewChildKey;
 }
Пример #20
0
 public SDuNewChildFail(SKey NewChildKey_)
 {
     NewChildKey = NewChildKey_;
 }
Пример #21
0
            int _StreamSndTail        = 0; // 전 패킷에 붙여보내기 위한 인덱스

            bool _IsValid(SKey Key_)
            {
                return(_Key != null && _Key.Equals(Key_));
            }
Пример #22
0
 public MessBase(MessType type) : this()
 {
     Type = type;
     Key  = null;
 }
Пример #23
0
 public SKey(SKey Obj_)
 {
     PeerNum     = Obj_.PeerNum;
     PeerCounter = Obj_.PeerCounter;
 }
Пример #24
0
 public MessBase(MessType type, ProcType proc, MarketType market = MarketType.Empty, string pair = null, SysType sys_type = SysType.Empty) : this()
 {
     Type = type;
     Key  = new SKey(proc, market, pair, sys_type);
 }
Пример #25
0
 public CKey(SKey Key_) :
     base(Key_)
 {
 }
Пример #26
0
 public SLinkSc(SKey ServerExtKey_)
 {
     ServerExtKey = ServerExtKey_;
 }
Пример #27
0
 public SLinkSc(SLinkSc Obj_)
 {
     ServerExtKey = Obj_.ServerExtKey;
 }
Пример #28
0
 public SReLinkCs(SReLinkCs Obj_)
 {
     ServerExtKey           = Obj_.ServerExtKey;
     ClientProtoSeqMustRecv = Obj_.ClientProtoSeqMustRecv;
 }